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


Java InventoryCloseEvent類代碼示例

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


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

示例1: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
    UUID uuid = event.getPlayer().getUniqueId();
    if (currentTrade.containsKey(uuid)) {
        UUID other = currentTrade.remove(uuid);
        Player otherP = plugin.getServer().getPlayer(other);
        if (otherP != null && otherP.isOnline() && otherP.isValid()) {
            if (currentTrade.containsKey(other))
                currentTrade.remove(other);
            event.getPlayer().sendMessage(ChatColor.RED + "The trade with " + otherP.getName() + " was canceled.");
            otherP.sendMessage(ChatColor.RED + "The trade with " + event.getPlayer().getName() + " was canceled.");
            otherP.closeInventory();
        } else {
            event.getPlayer().sendMessage(ChatColor.RED + "The trade was canceled.");
        }
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:18,代碼來源:TradeManager.java

示例2: 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

示例3: onInventoryCloseEvent

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent e) {
	if (e.getPlayer().getGameMode() == GameMode.SPECTATOR) {
		if (e.getInventory().getName().equalsIgnoreCase(wm1.inv.getName())) {
			Bukkit.getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
				@Override
				public void run() {
					e.getPlayer().openInventory(wm2.inv);
				}
			}, 1);

		}

		else if (e.getInventory().getName().equalsIgnoreCase(wm2.inv.getName())) {
			if (e.getInventory().getName().equalsIgnoreCase(wm2.inv.getName())) {
				Bukkit.getScheduler().scheduleSyncDelayedTask(SuperiorCraft.plugin, new Runnable() {
					@Override
					public void run() {
						e.getPlayer().setGameMode(GameMode.ADVENTURE);
					}
				}, 1);

			}		
		}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:27,代碼來源:SuperiorCraft.java

示例4: 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

示例5: 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

示例6: onSupplyDropInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onSupplyDropInventoryClose(InventoryCloseEvent e) {
	Location loc = e.getInventory().getLocation();
	Block b = loc.getBlock();

	if (b.getType() == Material.CHEST) {

		if (core.getSupplyDropManager().isSupplyDrop(b.getLocation())) {
			if (core.getSupplyDropManager().isEmpty(loc)) {
				core.getSupplyDropManager().removeSupplyDrop(loc);
				
				b.setType(Material.AIR);
				loc.getWorld().playSound(loc, Sound.BLOCK_WOOD_BREAK, 1, 1);
			}

		}
	}
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:19,代碼來源:SupplyDropListener.java

示例7: 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

示例8: onClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onClose(InventoryCloseEvent event) {
	if (!(event.getInventory().getHolder() instanceof MenuLink))
		return;
	final VPPlayer player = VanillaPlusCore.getPlayerManager().getPlayer((Player) event.getPlayer());
	final MenuLink menu = ((MenuLink) event.getInventory().getHolder());
	Bukkit.getScheduler().scheduleSyncDelayedTask(VanillaPlus.getInstance(), new Runnable() {
		@Override
		public void run() {
			if(player.getPlayer().getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING){
				menu.getIconMenu().closed(player, menu);
			}else{
				menu.getIconMenu().changed(player, menu);
			}
		}
	});
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:18,代碼來源:MenuManager.java

示例9: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
    UUID uuid = event.getPlayer().getUniqueId();
    if (invClickables.containsKey(uuid)) {
        HashMap<String, HashMap<String, Runnable>> invs = invClickables.get(uuid);
        String invName = event.getInventory().getName();
        if (invName != null && invs.containsKey(invName)) {
            HashMap<String, Runnable> map = invs.remove(invName);
            map.clear();
            map = null;
        }
        generalClickables.remove(uuid);
    }
    if (plugin.getPD((Player) event.getPlayer()) != null)
        plugin.getPD((Player) event.getPlayer()).currentModifiableInventory = null;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:17,代碼來源:MenuManager.java

示例10: 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

示例11: 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

示例12: 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

示例13: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryClose(InventoryCloseEvent event){
	for(Anvil an : animating){
		if(event.getPlayer().equals(an.getPlayer())){
			return;
		}
	}
	for(Anvil anvil : anvils){
		if(event.getPlayer().equals(anvil.getPlayer())){
			event.getPlayer().getInventory().setItemInMainHand(anvil.getItemStack());
			anvil.deleteShowItem();
			anvils.remove(anvil);
			return;
		}
	}
}
 
開發者ID:DamoclesProject,項目名稱:Damocles,代碼行數:17,代碼來源:AnvilHandler.java

示例14: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryClose(InventoryCloseEvent event)
{
    Inventory bottomInventory = event.getView().getBottomInventory();
    if(bottomInventory == null) return;
    if(bottomInventory.getType() != InventoryType.PLAYER) return;
    
    HumanEntity holder = ((PlayerInventory)bottomInventory).getHolder();
    if(!(holder instanceof Player)) return;
    
    Player player = (Player)holder;
    PlayerData playerData = PlayerData.FromPlayer(player);
    
    sortPlayerIfEnabled(player, playerData, bottomInventory);
    
    if(player.getGameMode() != GameMode.CREATIVE && Math.random() < .1 && !playerData.isGotDepositAllInfo() && featureEnabled(Features.DepositAll, player))
    {
        Inventory topInventory = event.getView().getTopInventory();
        if(topInventory != null && topInventory.getType() == InventoryType.CHEST)
        {
            AutomaticInventory.sendMessage(player, TextMode.Instr, Messages.DepositAllAdvertisement);
            playerData.setGotDepositAllInfo(true);
        }
    }
}
 
開發者ID:BigScary,項目名稱:AutomaticInventory,代碼行數:26,代碼來源:AIEventHandler.java

示例15: 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


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