本文整理匯總了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);
}
}
示例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);
}
示例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));
}
}
示例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);
}
}
}
示例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
}
}
示例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("遠程箱子保存失敗");
}
}
}
示例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);
}
}
}
}
}
示例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); }
}
示例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");
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}