当前位置: 首页>>代码示例>>Java>>正文


Java InventoryCloseEvent.getInventory方法代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryCloseEvent.getInventory方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryCloseEvent.getInventory方法的具体用法?Java InventoryCloseEvent.getInventory怎么用?Java InventoryCloseEvent.getInventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.inventory.InventoryCloseEvent的用法示例。


在下文中一共展示了InventoryCloseEvent.getInventory方法的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: 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

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

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

示例5: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event)
{
    Inventory inventory = event.getInventory();

    try
    {
        InventoryGui gui = getInventoryGuiById(HiddenId.grabId(inventory.getTitle()));

        guis.remove(gui);
    }
    catch (Exception ignored)
    {
        //inventory is not a gui -> do nothing
    }
}
 
开发者ID:robzen,项目名称:ProSpam,代码行数:17,代码来源:GuiManager.java

示例6: onCloseInventory

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onCloseInventory(InventoryCloseEvent event) {
	String[] title = event.getInventory().getTitle().split("·");
	if (title[0].equals("远程箱子")) {
		String chestType;
		if (title[1].equals("私有")) {
			chestType = "Private";
		} else {
			chestType = "Public";
		}
		String chestName = title[2];
		Inventory inventory = event.getInventory();
		if (doChest
				.saveChest(chestType, chestName.toLowerCase(), inventory)) {
		} else {
			getLogger().info("远程箱子保存失败");
		}
	}
}
 
开发者ID:caoli5288,项目名称:ChestSQL,代码行数:20,代码来源:ChestSQL.java

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

示例8: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(final InventoryCloseEvent event) {
	try {
		InventoryViewManager.debug("onInventoryClose", "onInventoryClose(" + event.getPlayer().getName() + ", " + event.getInventory() + ") called!");

		final Inventory inv = event.getInventory();
		if (!this.invMap.containsKey(inv)) { return; }

		if (inv.getViewers().size() > 1) { InventoryViewManager.debug("onInventoryClose", "Returning because inv still has viewers..."); return; }

		final int invId = this.invMap.get(inv);
		this.saveInventoryView(invId, inv);

		InventoryViewManager.debug("onInventoryClose", "Saved inventory '" + invId + "'");
	}
	catch (final Exception e) { CraftoMessenger.report(this, "Failed to handle InventoryCloseEvent!", e); }
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:18,代码来源:InventoryViewManager.java

示例9: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
    Inventory inventory = event.getInventory();
    boolean isOurs = openChests.containsKey(inventory.getTitle());
    boolean isOutOfView = inventory.getViewers().size() - 1 == 0;
    trace("Inventory closed: " + inventory.getName() + ", isOurs: " + isOurs + ", isOutOfView: " + isOutOfView);
    if (isOurs && isOutOfView) {
        CKUser user = openChests.get(inventory.getTitle());
        openChests.remove(user);
        if (user.save(inventory)) {
            trace("Save successful, queueing");
            plugin.queueUser(user);
        } else {
            trace("Save failed");
        }
    }
}
 
开发者ID:jjkoletar,项目名称:ChestKeeper,代码行数:18,代码来源:CKFacilitator.java

示例10: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
    if (event.getInventory().getHolder() instanceof FurnaceRecipeHolder) {
        FurnaceRecipeHolder holder = (FurnaceRecipeHolder) event.getInventory().getHolder();
        if (holder != this) return;

        Inventory inventory = event.getInventory();
        if (InventoryUtils.isEmpty(inventory)) {
            holder.callbackPlayer.sendMessage(ChatColor.RED + "please put an ingredient int he inventory.");
            HandlerList.unregisterAll(holder);
            return;
        }

        org.bukkit.inventory.ItemStack ingredient = null;
        for (org.bukkit.inventory.ItemStack first : inventory) {
            if (!InventoryUtils.isEmptyStack(first)) {
                ingredient = first;
                break;
            }
        }

        CRFurnaceRecipe furnaceRecipe = new CRFurnaceRecipe(registerRecipe());
        String ingredientString = InventoryUtils.getItemName(ingredient);

        String recipeString = ingredientString + "" + ChatColor.RESET + " -> "
                + InventoryUtils.getItemName(furnaceRecipe.getResult());
        if (holder.xp > 0) {
            DecimalFormat decimalFormat = new DecimalFormat("##.##");
            String xpString = decimalFormat.format(holder.xp);
            recipeString += ChatColor.RESET + " (" + xpString + " xp)";
        }

        holder.callbackPlayer.sendMessage(String.format("%sAdded furnace recipe: %s%s%s!",
                ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
        plugin.saveFurnaceRecipeFile(furnaceRecipe);

        HandlerList.unregisterAll(holder);
    }
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:40,代码来源:FurnaceAdder.java

示例11: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof WorldRecipeHolder) {
		WorldRecipeHolder holder = (WorldRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		WorldRecipe nmsRecipe = holder.toRecipe();
		CRWorldRecipe worldRecipe = new CRWorldRecipe(nmsRecipe);
		List<List<String>> recipeIngredients = worldRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(worldRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, worldRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded world recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("world", worldRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a world recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:35,代码来源:WorldAdder.java

示例12: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof NBTRecipeHolder) {
		NBTRecipeHolder holder = (NBTRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		NBTRecipe nmsRecipe = holder.toRecipe();
		CRNBTRecipe nbtRecipe = new CRNBTRecipe(nmsRecipe);
		List<List<String>> recipeIngredients = nbtRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(nbtRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, nbtRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded NBT recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("nbt", nbtRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create an NBT recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:35,代码来源:NBTAdder.java

示例13: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof CountRecipeHolder) {
		CountRecipeHolder holder = (CountRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		CountRecipe nmsRecipe = holder.toRecipe();
		CRCountRecipe countRecipe = new CRCountRecipe(nmsRecipe);
		List<List<String>> recipeIngredients = countRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(countRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, countRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded count recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("count", countRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a count recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:35,代码来源:CountAdder.java

示例14: onInventoryClick

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof PermissionRecipeHolder) {
		PermissionRecipeHolder holder = (PermissionRecipeHolder) event.getView().getTopInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		PermissionRecipe nmsRecipe = holder.toRecipe();
		CRPermissionRecipe permissionRecipe = new CRPermissionRecipe(nmsRecipe);

		List<List<String>> recipeIngredients = permissionRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(permissionRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, permissionRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded a permission recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("permission", permissionRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a permission recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:36,代码来源:PermissionAdder.java

示例15: onInventoryClose

import org.bukkit.event.inventory.InventoryCloseEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof ShapedRecipeHolder) {
		ShapedRecipeHolder holder = (ShapedRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		ShapedRecipes nmsRecipe = holder.toRecipe();
		CRShapedRecipe<ShapedRecipes> shapedRecipe = new CRShapedRecipe<>(nmsRecipe);
		List<List<String>> recipeIngredients = shapedRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(shapedRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, shapedRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded shaped recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("shaped", shapedRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a shaped recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:35,代码来源:ShapedAdder.java


注:本文中的org.bukkit.event.inventory.InventoryCloseEvent.getInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。