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


Java InventoryCloseEvent.getPlayer方法代碼示例

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


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

示例1: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
	if(!(e.getPlayer() instanceof Player))
		return;
	
	Inventory inv = e.getInventory();
	InventoryHolder holder = inv.getHolder();
	if(holder != null && holder instanceof Menu)
	{
		Menu menu = (Menu) holder;
		menu.viewers.remove(e.getPlayer());
		if(menu.viewers.size() == 0)
			openMenus.remove(menu);
	}
}
 
開發者ID:timtomtim7,項目名稱:SparseBukkitAPI,代碼行數:17,代碼來源:MenuManager.java

示例2: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInventoryClose(InventoryCloseEvent e) {
    Player p = (Player) e.getPlayer();

    if(!inventories.containsKey(p))
        return;

    SmartInventory inv = inventories.get(p);

    inv.getListeners().stream()
            .filter(listener -> listener.getType() == InventoryCloseEvent.class)
            .forEach(listener -> ((InventoryListener<InventoryCloseEvent>) listener).accept(e));

    if(inv.isCloseable()) {
        e.getInventory().clear();
        inventories.remove(p);
    }
    else
        Bukkit.getScheduler().runTask(plugin, () -> p.openInventory(e.getInventory()));
}
 
開發者ID:MinusKube,項目名稱:SmartInvs,代碼行數:21,代碼來源:InventoryManager.java

示例3: onBackpackClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onBackpackClose(InventoryCloseEvent event) {
    Inventory inventory = event.getInventory();
    Player player = (Player) event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)
            || !(inventory.getHolder() instanceof BackpackHolder)) {
        return;
    }

    PlayerWrapper playerWrapper = InventoryManager.get(player);
    Backpack backpack = playerWrapper.getBackpack();

    if (backpack == null) {
        return;
    }

    backpack.onUse();
    playerWrapper.setBackpack(null);
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:21,代碼來源:BackpackListener.java

示例4: onClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onClose(InventoryCloseEvent e) {
    Player p = (Player) e.getPlayer();
    if (ChatColor.stripColor(e.getInventory().getTitle()).equals("장신구 장착")) {
        ItemStack slot1 = e.getInventory().getItem(20);
        ItemMeta slot1m = slot1.getItemMeta();
        ArrayList list = Effect.effects;
        Iterator<Effect> i = list.iterator();
        while (i.hasNext()) {
            try {
                Effect ee = i.next();
                String lastWord = slot1m.getLore().get(0).substring(slot1m.getLore().get(0).lastIndexOf(" ")+1);
                if (ChatColor.stripColor(ee.getDisplayName()).equals(ChatColor.stripColor(slot1m.getLore().get(0).replace(lastWord,"{0}")))) {
                    Effect.eventType(p,ee,"summon");
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
}
 
開發者ID:SkyLightQP,項目名稱:ArmorPlus,代碼行數:22,代碼來源:GUIEvent.java

示例5: onClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onClose(InventoryCloseEvent event)
{
	final Player player = (Player) event.getPlayer();
	User user = userManager.get(player.getUniqueId());
	
	if(user.isFrozen() && options.modeFreezePrompt)
	{
		new BukkitRunnable()
		{
			@Override
			public void run()
			{
				new FreezeGui(player, options.modeFreezePromptTitle);					
			}
		}.runTaskLater(StaffPlus.get(), 1L);
		return;
	}else if(user.getCurrentGui() != null)
	{
		user.setCurrentGui(null);
	}
}
 
開發者ID:Shortninja66,項目名稱:StaffPlus,代碼行數:23,代碼來源:InventoryClose.java

示例6: updateWorth

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

    // Get cached values from when chest was opened and add the difference
    // to the worth manager.
    if (event.getInventory().getHolder() instanceof DoubleChest) {
        DoubleChest chest = (DoubleChest) event.getInventory().getHolder();
        updateWorth((Chest) chest.getLeftSide());
        updateWorth((Chest) chest.getRightSide());
    }

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

示例7: onClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onClose(InventoryCloseEvent event){
	Inventory inv = event.getInventory();
	if(inv.getName().equals("Equip Inventory")){
		Player player = (Player) event.getPlayer();
		Account account = new Account(player);
		ca.damocles.accountsystem.Character character = account.getLoadedCharacter();
		player.getInventory().setHelmet(inv.getItem(1));
		character.setEquip(Slot.HELMET, inv.getItem(1));
		player.getInventory().setChestplate(inv.getItem(2));
		character.setEquip(Slot.CHESTPLATE, inv.getItem(2));
		player.getInventory().setLeggings(inv.getItem(6));
		character.setEquip(Slot.LEGGINGS, inv.getItem(6));
		player.getInventory().setBoots(inv.getItem(7));
		character.setEquip(Slot.BOOTS, inv.getItem(7));
		character.setEquip(Slot.BELT, inv.getItem(19));
		character.setEquip(Slot.GLOVES, inv.getItem(20));
		character.setEquip(Slot.RING1, inv.getItem(24));
		character.setEquip(Slot.RING2, inv.getItem(25));
		character.setEquip(Slot.SPELLBOOK, inv.getItem(37));
		character.setEquip(Slot.BANK, inv.getItem(38));
		character.setEquip(Slot.RING3, inv.getItem(42));
		character.setEquip(Slot.RING4, inv.getItem(43));
	}
}
 
開發者ID:DamoclesProject,項目名稱:Damocles,代碼行數:26,代碼來源:EquipHandler.java

示例8: restoreWoolChests

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void restoreWoolChests(InventoryCloseEvent event) {
    HumanEntity human = event.getPlayer();

    if (human instanceof Player) {
        GamePlayer player = this.game.getGame().getPlayer((Player) human);
        if (player == null) {
            return;
        }

        List<GamePlayer> viewers = new ArrayList<>();
        for (HumanEntity humanViewer : event.getViewers()) {
            if (humanViewer instanceof Player) {
                GamePlayer viewer = this.game.getGame().getPlayer((Player) humanViewer);

                if (viewer != null) {
                    viewers.add(viewer);
                }
            }
        }

        this.restoreWoolChest(event.getInventory().getHolder(), player, viewers);
    }
}
 
開發者ID:ShootGame,項目名稱:Arcade2,代碼行數:25,代碼來源:WoolChestTracker.java

示例9: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
	if (e.getInventory().getName() == null || !e.getInventory().getName().equals(inventory.getName())) {
		return;
	}
	
	if (!(e.getPlayer() instanceof Player) || !(((Player) e.getPlayer()).getUniqueId().equals(
			player.getPlayer().getUniqueId()))) {
		QuestManagerPlugin.logger.warning("Inventory menu event matched names,"
				+ " but not players! [" + e.getPlayer().getName() + "]");
		return;
	}
	

	if (gui instanceof CloseableGui)  {
		((CloseableGui) gui).onClose();
	}
	
	//our inventory is closing
	//unregister ourselves, unregister with handler, end
	HandlerList.unregisterAll(this);
	
	
	QuestManagerPlugin.questManagerPlugin.getInventoryGuiHandler().closeMenu((Player) e.getPlayer());
	
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:27,代碼來源:InventoryMenu.java

示例10: inventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void inventoryClose(InventoryCloseEvent e) {
    Player p = (Player) e.getPlayer();
    UUID uuid = p.getUniqueId();
    if (p != null && p.isOnline()) {
        if (this.guiManager.isGUIEnabled() && this.guiManager.containsPlayer(uuid)) {
            if (!this.guiManager.isAllowedToClose()) {
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        Inventory inv = guiManager.refreshPersonalGUI(uuid);
                        if (inv != null) {
                            p.openInventory(inv);
                        }
                    }
                }.runTaskLater(this.plugin, 0L);

            } else {
                this.guiManager.removePlayer(uuid);
            }
        }
    }
}
 
開發者ID:7rory768,項目名稱:SimpleFreeze,代碼行數:24,代碼來源:InventoryCloseListener.java

示例11: onClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onClose(InventoryCloseEvent e) {
	final Player player = (Player) e.getPlayer();
	if (openSelling.containsKey(player)) {
		Inventory inv = e.getInventory();
		final ItemStack[] contents = inv.getContents();
		int count = itemAmount(contents);
		if (count > 1) {
			Bukkit.getScheduler().scheduleSyncDelayedTask(Util.getMain(), new Runnable() {
				@Override
				public void run() {
					openSell(player);
					openSelling.get(player).setContents(contents);
					player.sendMessage(ChatColor.RED + "Please click the sell button or remove your items before closing!");
				}
			});
		} else {
			openSelling.remove(player);
		}
	}
}
 
開發者ID:bobmandude9889,項目名稱:iZenith-PVP,代碼行數:22,代碼來源:ShopManager.java

示例12: onChestClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChestClose(InventoryCloseEvent e) {
    if (!(e.getPlayer() instanceof Player))
        return;
    final Player p = (Player) e.getPlayer();
    if (!playerStateInfoMap.containsKey(p)) return;
    if (!(p.getInventory().getType() == InventoryType.CHEST ||
            plugin.getVersionUtil().isOneDotXOrHigher(11)
                    && isShulkerBox(p.getInventory()))) {
        return;
    }
    new BukkitRunnable() {
        @Override
        public void run() {
            StateInfo stateInfo = playerStateInfoMap.get(p);
            if (stateInfo == null) return;
            restoreState(stateInfo, p);
            playerStateInfoMap.remove(p);
        }
    }.runTaskLater(plugin, 1);
}
 
開發者ID:MyzelYam,項目名稱:SuperVanish,代碼行數:22,代碼來源:SilentOpenChest.java

示例13: closeMenu

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
private void closeMenu(InventoryCloseEvent event) {
	if (!(event.getPlayer() instanceof Player))
		return;
	
	BTPlayer ply;
	try{
		ply = plugin.getPlayerData().getBTPlayer((Player)event.getPlayer());
	}
	catch (UnknownBTPlayerException e){
		return;
	}
	
	MenuSession session = ply.getMenuSession();
	if (session == null) {
		return;
	}
	
	session.current.onCloseMenu(ply);
	
	if (!ply.getNoClose()) {
		ply.setMenuSession(null);
	}
}
 
開發者ID:AddstarMC,項目名稱:BuildTools,代碼行數:25,代碼來源:MenuListener.java

示例14: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入方法依賴的package包/類
@EventHandler
public void onInventoryClose(final InventoryCloseEvent event) {
	final Inventory inventory = event.getInventory();
	if (inventory.getName().equals(ONI)) {
		final HumanEntity entity = event.getPlayer();
		if (entity instanceof Player) {
			final Player player = (Player) entity;
			playerManager.completeChallenge(player, inventory);
			
			// Drop remaining contents
			for (final ItemStack itemStack : inventory.getContents()) {
				if (itemStack != null) {
					worldManager.getWorld().dropItemNaturally(oniLocation, itemStack);// .setPickupDelay(20);
				}
			}
		}
	}
}
 
開發者ID:toddharrison,項目名稱:5min2live,代碼行數:19,代碼來源:OniManager.java

示例15: onInventoryClose

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

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

    HumanEntity player = event.getPlayer();

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

    furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin);
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:17,代碼來源:InventoryListener.java


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