当前位置: 首页>>代码示例>>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;未经允许,请勿转载。