當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryOpenEvent.getPlayer方法代碼示例

本文整理匯總了Java中org.bukkit.event.inventory.InventoryOpenEvent.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryOpenEvent.getPlayer方法的具體用法?Java InventoryOpenEvent.getPlayer怎麽用?Java InventoryOpenEvent.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.inventory.InventoryOpenEvent的用法示例。


在下文中一共展示了InventoryOpenEvent.getPlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
    Inventory inventory = event.getInventory();
    HumanEntity player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (InventoryAPI.isRPGInventory(inventory)) {
        PlayerWrapper playerWrapper = (PlayerWrapper) inventory.getHolder();
        InventoryManager.syncQuickSlots(playerWrapper);
        InventoryManager.syncInfoSlots(playerWrapper);
        InventoryManager.syncShieldSlot(playerWrapper);
        InventoryManager.syncArmor(playerWrapper);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:18,代碼來源:InventoryListener.java

示例2: onPetInventoryOpened

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onPetInventoryOpened(InventoryOpenEvent event) {
    Player player = (Player) event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    final PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && event.getInventory().getHolder() == playerWrapper.getPet()) {
        playerWrapper.openInventory();
        event.setCancelled(true);

        new BukkitRunnable() {
            @Override
            public void run() {
                HorseInventory horseInv = ((Horse) playerWrapper.getPet()).getInventory();
                horseInv.setSaddle(new ItemStack(Material.SADDLE));
            }
        }.runTaskLater(RPGInventory.getInstance(), 1);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:22,代碼來源:PetListener.java

示例3: checkWorth

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkWorth(InventoryOpenEvent event) {
    // Do nothing if a player did not open the inventory or if chest events
    // are disabled.
    if (!(event.getPlayer() instanceof Player) || plugin.getSettings().isDisableChestEvents()) {
        return;
    }

    Inventory inventory = event.getInventory();

    // Set all default worth values for this chest.
    if (inventory.getHolder() instanceof DoubleChest) {
        DoubleChest chest = (DoubleChest) inventory.getHolder();
        checkWorth((Chest) chest.getLeftSide());
        checkWorth((Chest) chest.getRightSide());
    }

    if (inventory.getHolder() instanceof Chest) {
        checkWorth((Chest) inventory.getHolder());
    }
}
 
開發者ID:novucs,項目名稱:factions-top,代碼行數:22,代碼來源:WorthListener.java

示例4: onVillagerTrade

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler
public void onVillagerTrade(InventoryOpenEvent event) {
    if (!plugin.isSkyAssociatedWorld(event.getPlayer().getWorld())) {
        return;
    }
    if (!(event.getPlayer() instanceof Player)) {
        return;
    }
    if (villagerTradingEnabled
            && event.getPlayer() instanceof Player
            && !(hasPermission(event.getPlayer(), "usb.mod.bypassprotection"))
            && event.getInventory().getType() == InventoryType.MERCHANT
            && !plugin.playerIsOnIsland((Player)event.getPlayer())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(tr("\u00a7eTrading isn't allowed on other islands. Do it in spawn."));
        return;
    }
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:19,代碼來源:ExploitEvents.java

示例5: onInventoryOpenEvent

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
	if (event.getInventory() instanceof DoubleChestInventory) {
		DoubleChestInventory doubleInv = (DoubleChestInventory)event.getInventory();
					
		Chest leftChest = (Chest)doubleInv.getHolder().getLeftSide();			
		/*Generate a new player 'switch' event for the left and right chests. */
		PlayerInteractEvent interactLeft = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, leftChest.getBlock(), null);
		BlockListener.OnPlayerSwitchEvent(interactLeft);
		
		if (interactLeft.isCancelled()) {
			event.setCancelled(true);
			return;
		}
		
		Chest rightChest = (Chest)doubleInv.getHolder().getRightSide();
		PlayerInteractEvent interactRight = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, rightChest.getBlock(), null);
		BlockListener.OnPlayerSwitchEvent(interactRight);
		
		if (interactRight.isCancelled()) {
			event.setCancelled(true);
			return;
		}			
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:26,代碼來源:PlayerListener.java

示例6: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
    Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());

    if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
        return;
    }

    HumanEntity player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player)) {
        return;
    }

    furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:17,代碼來源:InventoryListener.java

示例7: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event)
{
    if (event.getPlayer() instanceof Player)
    {
        if (this.isActive(ItemInsert.class, event.getPlayer().getWorld())
         || this.isActive(ItemRemove.class, event.getPlayer().getWorld()))
        {
            /* TODO
            ContainerType type = new ContainerType(event.getInventory().getHolder());
            if (!config.container.CONTAINER_ignore.contains(type))
             */
            this.inventoryChanges.put(event.getPlayer().getUniqueId(), new HashMap<ItemData, Integer>());
        }
    }
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:17,代碼來源:ListenerContainerItem.java

示例8: PlayerInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void PlayerInventoryOpen(final InventoryOpenEvent event)
{
	if (!(event.getPlayer() instanceof Player))
		return;
	final Player player = (Player) event.getPlayer();
	if (plugin.isLoggedIn(player))
	{
		final LoginPlayerData playerdata = plugin.getPlayerData(player);
		if (playerdata != null)
			playerdata.notifyAction();
		return;
	}
	event.setCancelled(true);
	player.closeInventory();
	plugin.sendAuthReminderMessage(player);
}
 
開發者ID:ST-DDT,項目名稱:CrazyLogin,代碼行數:18,代碼來源:DynamicPlayerListener.java

示例9: onInventoryOpening

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
/**
 * Controls chest ownership for carts.
 *
 * @param e The {@link InventoryMoveItemEvent} associated with the chest.
 */
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
    Inventory inv = e.getInventory();
    if (e.getPlayer() instanceof Player) {
        Player p = (Player) e.getPlayer();
        if (inv.getHolder() instanceof Minecart) {
            Minecart cart = (Minecart) inv.getHolder();
            MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
            if (toCheck != null && !toCheck.isDerailed()) {
                CartProperties cp = toCheck.getProperties();
                if (!cp.getOwners().contains(p.getName().toLowerCase())) {
                    p.sendMessage(ChatColor.RED + "You do not own this chest!");
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
開發者ID:GoldRushMC,項目名稱:GoldRushPlugin,代碼行數:24,代碼來源:TrainStationLis.java

示例10: onInventoryOpenEvent

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
/**
 * Event handler to watch whenever a chest is opened.
 * This will prevent the opening of the chest if necessary.
 *  
 * @param event inventoryOpenEvent representing the inventory object that was just opened. We care about a Chest inventory being opened
 */
@EventHandler (ignoreCancelled=true)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
    //get the destination inventory
    InventoryHolder holder = event.getInventory().getHolder();
    //Make sure it is a chest
    if (holder instanceof Chest) {
        Location chestLocation = ((Chest) holder).getLocation();
        //see if a filter is around the location
        if (plugin.isChestNextToHopper(chestLocation)) {
            Player player = (Player) event.getPlayer();
            if (!player.hasPermission("hopperfiltersimplified.build.alter.chest")) {
                plugin.sendMessageInfo(player, "You do not have rights to alter this hopper filter chest.");
                event.setCancelled(true);
            }

            //debug if requested
            if (plugin.debugLevel_get() > 0) plugin.getLogger().info("Chest next to hopper opened at (" + chestLocation.toString() + ")");
        }            
    }
}
 
開發者ID:TheNut,項目名稱:HopperFilterSimplified,代碼行數:27,代碼來源:HfsBlockListener.java

示例11: onInventoryOpen

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(final InventoryOpenEvent e) {
    if (e.getView() instanceof LocaleInventory)
        return;
    if (e.getInventory().getType() != InventoryType.CHEST || !useLocaleInv) {
        Inventory in = e.getInventory();
        Iterator<ItemStack> it = in.iterator();
        String locale = Locale.getPlayerLocale((Player) e.getPlayer());
        try {
            while (it.hasNext()) {
                ItemStack item = it.next();
                if (ItemManager.toRPGItem(item) != null)
                    RPGItem.updateItem(item, locale);
            }
        } catch (ArrayIndexOutOfBoundsException ex) {
            // Fix for the bug with anvils in craftbukkit
        }
    } else if (useLocaleInv) {
        LocaleInventory localeInv = new LocaleInventory((Player) e.getPlayer(), e.getView());
        e.setCancelled(true);
        e.getPlayer().openInventory(localeInv);
        localeInventories.add(localeInv);
    }
}
 
開發者ID:Thinkofname,項目名稱:RPG-Items,代碼行數:25,代碼來源:Events.java

示例12: protectHorseInventory

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler
public void protectHorseInventory(InventoryOpenEvent event){
	if(event.getInventory().getHolder() instanceof Horse){
		Horse h = (Horse)event.getInventory().getHolder();
		Player p = (Player) event.getPlayer();
		String playername = event.getPlayer().getName();
		if(p.isOp() || p.hasPermission("echorse.override")){ //Op & permission check
			return;
		}
		if(!(h.getOwner().getName() == playername)){ //Not the horse owner, cancel event
				
			event.setCancelled(true);
			p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.RED + " You dont have permission to open " + h.getOwner().getName() + "'s horse inventory!");
			return;
		}
		return;
	}
	return;	
}
 
開發者ID:ekiminatorn,項目名稱:ECHorses,代碼行數:20,代碼來源:ECHorsesListeners.java

示例13: onInventoryOpening

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
/**
 * This will facilitate the need to update the {@link TrainFactory#ownerStorage} list, because if the inventory changes, the instance changes.
 * 
 * @param e The {@link InventoryMoveItemEvent} associated with the chest.
 */
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
	Inventory inv = e.getInventory();
	if(e.getPlayer() instanceof Player) {
		Player p = (Player) e.getPlayer();
		if(inv.getHolder() instanceof Minecart) {
			Minecart cart = (Minecart) inv.getHolder();
			MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
			if(toCheck != null) {
				CartProperties cp = toCheck.getProperties();
				if(!cp.getOwners().contains(p.getName().toLowerCase())) {
					p.sendMessage(ChatColor.RED + "You do not own this chest!");
					e.setCancelled(true);
				}
			}
		}
	}
}
 
開發者ID:lexwebb,項目名稱:GoldRushMC,代碼行數:24,代碼來源:TrainStationLis.java

示例14: onChestClick

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
/**
 * This will be used to facilitate the permissions of chest minecarts.
 * 
 * @param event The {@link InventoryOpenEvent} associated with the chest.
 */
public void onChestClick(InventoryOpenEvent event) {

	event.setCancelled(true);

	Player p = (Player) event.getPlayer();
	Inventory i = event.getInventory();

	if(TrainFactory.ownerStorage.containsKey(p)) {
		for(MinecartMemberChest chest : TrainFactory.getInventoryList(p)) {
			if(chest.getEntity().getInventory() == i) {
				event.setCancelled(false);
				break;
			}
		}
	}
}
 
開發者ID:lexwebb,項目名稱:GoldRushMC,代碼行數:22,代碼來源:TrainLis.java

示例15: onInventoryOpenEvent

import org.bukkit.event.inventory.InventoryOpenEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryOpenEvent(InventoryOpenEvent event) {
    final Player player = (Player) event.getPlayer();
    if (this.manager.carryingPet.contains(player)) {
        event.setCancelled(true);
        event.getPlayer().closeInventory();
    }
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:9,代碼來源:PetBlockListener.java


注:本文中的org.bukkit.event.inventory.InventoryOpenEvent.getPlayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。