Java Code Examples for org.bukkit.event.inventory.InventoryType#MERCHANT
The following examples show how to use
org.bukkit.event.inventory.InventoryType#MERCHANT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExploitEvents.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onVillagerTrade(InventoryOpenEvent event) { if (!plugin.getWorldManager().isSkyAssociatedWorld(event.getPlayer().getWorld())) { return; } if (!(event.getPlayer() instanceof Player)) { return; } if (!anyVillagerTradingAllowed && event.getInventory().getType() == InventoryType.MERCHANT) { event.setCancelled(true); event.getPlayer().sendMessage(tr("\u00a7eVillager-trading isn't allowed.")); return; } if (visitorVillagerTradingProtected && event.getPlayer() instanceof Player && !(event.getPlayer().hasPermission("usb.mod.bypassprotection")) && event.getInventory().getType() == InventoryType.MERCHANT && !plugin.playerIsOnIsland((Player)event.getPlayer())) { event.setCancelled(true); event.getPlayer().sendMessage(tr("\u00a7eTrading isn't allowed on other islands. Do it in spawn.")); } }
Example 2
Source File: CraftInventory.java From Kettle with GNU General Public License v3.0 | 5 votes |
public InventoryType getType() { // Thanks to Droppers extending Dispensers, order is important. if (inventory instanceof InventoryCrafting) { return inventory.getSizeInventory() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; } else if (inventory instanceof InventoryPlayer) { return InventoryType.PLAYER; } else if (inventory instanceof TileEntityDropper) { return InventoryType.DROPPER; } else if (inventory instanceof TileEntityDispenser) { return InventoryType.DISPENSER; } else if (inventory instanceof TileEntityFurnace) { return InventoryType.FURNACE; } else if (this instanceof CraftInventoryEnchanting) { return InventoryType.ENCHANTING; } else if (inventory instanceof TileEntityBrewingStand) { return InventoryType.BREWING; } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) { return ((CraftInventoryCustom.MinecraftInventory) inventory).getType(); } else if (inventory instanceof InventoryEnderChest) { return InventoryType.ENDER_CHEST; } else if (inventory instanceof InventoryMerchant) { return InventoryType.MERCHANT; } else if (inventory instanceof TileEntityBeacon) { return InventoryType.BEACON; } else if (this instanceof CraftInventoryAnvil) { return InventoryType.ANVIL; } else if (inventory instanceof IHopper) { return InventoryType.HOPPER; } else if (inventory instanceof TileEntityShulkerBox) { return InventoryType.SHULKER_BOX; } else { return InventoryType.CHEST; } }
Example 3
Source File: VillagerTradesListener.java From Statz with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onVillagerTrade(final InventoryClickEvent event) { final PlayerStat stat = PlayerStat.VILLAGER_TRADES; // Thanks to Lolmewn for this code (https://bitbucket // .org/Lolmewn/stats/src/4eae2db1b21038a91b7d39181f27bdd3cd987324/src/main/java/nl/lolmewn/stats/stats/bukkit // /BukkitTrades.java?at=3.0&fileviewer=file-view-default) if (event.getInventory().getType() != InventoryType.MERCHANT) { return; } if (!event.getSlotType().equals(SlotType.RESULT)) { return; } if (!event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) && !event.getAction().equals(InventoryAction.PICKUP_ALL)) { return; } if (!(event.getWhoClicked() instanceof Player)) { return; } Player player = (Player) event.getWhoClicked(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; ItemStack item = event.getCurrentItem(); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", item.getAmount(), "world", player.getWorld().getName(), "trade", item.getType().toString())); }
Example 4
Source File: CraftInventory.java From Thermos with GNU General Public License v3.0 | 5 votes |
public InventoryType getType() { // Thanks to Droppers extending Dispensers, order is important. if (inventory instanceof net.minecraft.inventory.InventoryCrafting) { return inventory.getSizeInventory() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING; } else if (inventory instanceof net.minecraft.entity.player.InventoryPlayer) { return InventoryType.PLAYER; } else if (inventory instanceof net.minecraft.tileentity.TileEntityDropper) { return InventoryType.DROPPER; } else if (inventory instanceof net.minecraft.tileentity.TileEntityDispenser) { return InventoryType.DISPENSER; } else if (inventory instanceof net.minecraft.tileentity.TileEntityFurnace) { return InventoryType.FURNACE; } else if (inventory instanceof net.minecraft.inventory.ContainerEnchantTableInventory) { return InventoryType.ENCHANTING; } else if (inventory instanceof net.minecraft.tileentity.TileEntityBrewingStand) { return InventoryType.BREWING; } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) { return ((CraftInventoryCustom.MinecraftInventory) inventory).getType(); } else if (inventory instanceof net.minecraft.inventory.InventoryEnderChest) { return InventoryType.ENDER_CHEST; } else if (inventory instanceof net.minecraft.inventory.InventoryMerchant) { return InventoryType.MERCHANT; } else if (inventory instanceof net.minecraft.tileentity.TileEntityBeacon) { return InventoryType.BEACON; } else if (inventory instanceof net.minecraft.inventory.ContainerRepairInventory) { return InventoryType.ANVIL; } else if (inventory instanceof net.minecraft.tileentity.IHopper) { return InventoryType.HOPPER; } else { return InventoryType.CHEST; } }
Example 5
Source File: TrMenuNmsModern.java From TrMenu with MIT License | 4 votes |
private Containers<?> getByInventory(Inventory inventory) { InventoryType type = inventory.getType(); int size = inventory.getSize(); if (type == InventoryType.CHEST) { if (size == 9) { return Containers.GENERIC_9X1; } else if (size == 18) { return Containers.GENERIC_9X2; } else if (size == 27) { return Containers.GENERIC_9X3; } else if (size == 36) { return Containers.GENERIC_9X4; } else if (size == 45) { return Containers.GENERIC_9X5; } else { return Containers.GENERIC_9X6; } } else if (type == InventoryType.DROPPER || type == InventoryType.DISPENSER) { return Containers.GENERIC_3X3; } else if (type == InventoryType.BARREL || type == InventoryType.ENDER_CHEST) { return Containers.GENERIC_9X3; } else if (type == InventoryType.CRAFTING || type == InventoryType.WORKBENCH) { return Containers.CRAFTING; } else if (type == InventoryType.HOPPER) { return Containers.HOPPER; } else if (type == InventoryType.LOOM) { return Containers.LOOM; } else if (type == InventoryType.ANVIL) { return Containers.ANVIL; } else if (type == InventoryType.BEACON) { return Containers.BEACON; } else if (type == InventoryType.SMOKER) { return Containers.SMOKER; } else if (type == InventoryType.BREWING) { return Containers.BREWING_STAND; } else if (type == InventoryType.FURNACE) { return Containers.FURNACE; } else if (type == InventoryType.LECTERN) { return Containers.LECTERN; } else if (type == InventoryType.MERCHANT) { return Containers.MERCHANT; } else if (type == InventoryType.ENCHANTING) { return Containers.ENCHANTMENT; } else if (type == InventoryType.GRINDSTONE) { return Containers.GRINDSTONE; } else if (type == InventoryType.CARTOGRAPHY) { return Containers.CARTOGRAPHY_TABLE; } else if (type == InventoryType.SHULKER_BOX) { return Containers.SHULKER_BOX; } else if (type == InventoryType.STONECUTTER) { return Containers.STONECUTTER; } else if (type == InventoryType.BLAST_FURNACE) { return Containers.BLAST_FURNACE; } else { return Containers.GENERIC_3X3; } }