Java Code Examples for org.bukkit.entity.Player#getItemInHand()

The following examples show how to use org.bukkit.entity.Player#getItemInHand() . 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: PlayerEvents.java    From uSkyBlock with GNU General Public License v3.0 7 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onClickOnObsidian(final PlayerInteractEvent event) {
    if (!plugin.getWorldManager().isSkyWorld(event.getPlayer().getWorld())) {
        return;
    }
    long now = System.currentTimeMillis();
    Player player = event.getPlayer();
    PlayerInventory inventory = player.getInventory();
    Block block = event.getClickedBlock();
    Long lastClick = obsidianClick.get(player.getUniqueId());
    if (lastClick != null && (lastClick + OBSIDIAN_SPAM) >= now) {
        plugin.notifyPlayer(player, tr("\u00a74You can only convert obsidian once every 10 seconds"));
        return;
    }
    if (Settings.extras_obsidianToLava && plugin.playerIsOnIsland(player)
            && plugin.getWorldManager().isSkyWorld(player.getWorld())
            && event.getAction() == Action.RIGHT_CLICK_BLOCK
            && player.getItemInHand() != null
            && player.getItemInHand().getType() == Material.BUCKET
            && block != null
            && block.getType() == Material.OBSIDIAN
            && !testForObsidian(block)) {
        if (inventory.firstEmpty() != -1) {
            obsidianClick.put(player.getUniqueId(), now);
            player.sendMessage(tr("\u00a7eChanging your obsidian back into lava. Be careful!"));
            inventory.removeItem(new ItemStack(Material.BUCKET, 1));
            inventory.addItem(new ItemStack(Material.LAVA_BUCKET, 1));
            player.updateInventory();
            block.setType(Material.AIR);
            event.setCancelled(true); // Don't execute the click anymore (since that would re-place the lava).
        } else {
            player.sendMessage(tr("\u00a7eYour inventory must have another empty space!"));
        }
    }
}
 
Example 2
Source File: Util.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Results a list of items in a player's hands. Works for older versions of servers
 * @param player
 * @return list of itemstacks
 */
@SuppressWarnings("deprecation")
public static List<ItemStack> getPlayerInHandItems(Player player) {
    List<ItemStack> result = new ArrayList<ItemStack>(2);
    if (plugin.getServer().getVersion().contains("(MC: 1.7")
            || plugin.getServer().getVersion().contains("(MC: 1.8")) {
        if (player.getItemInHand() != null)
            result.add(player.getItemInHand());
        return result;
    }
    if (player.getInventory().getItemInMainHand() != null)
        result.add(player.getInventory().getItemInMainHand());
    if (player.getInventory().getItemInOffHand() != null)
        result.add(player.getInventory().getItemInOffHand());
    return result;
}
 
Example 3
Source File: ItemShortcut.java    From Minepacks with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onItemFrameInteract(PlayerInteractEntityEvent event)
{
	Player player = event.getPlayer();
	ItemStack item;
	if(MCVersion.isDualWieldingMC())
	{
		item = (event.getHand() == EquipmentSlot.HAND) ? player.getInventory().getItemInMainHand() : player.getInventory().getItemInOffHand();
	}
	else
	{
		item = player.getItemInHand();
	}
	if(isItemShortcut(item))
	{
		event.getPlayer().performCommand(openCommand);
		event.setCancelled(true);
	}
}
 
Example 4
Source File: GrenadeListener.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onGrenadeLaunch(final ProjectileLaunchEvent event) {
    if (event.getEntity().getShooter() instanceof Player) {
        Player player = (Player) event.getEntity().getShooter();
        ItemStack stack = player.getItemInHand();

        if(stack != null) {
            // special case for grenade arrows
            if (stack.getType() == Material.BOW) {
                int arrows = player.getInventory().first(Material.ARROW);
                if (arrows == -1) return;
                stack = player.getInventory().getItem(arrows);
            }

            Grenade grenade = Grenade.ITEM_TAG.get(stack);
            if(grenade != null) {
                grenade.set(plugin, event.getEntity());
            }
        }
    }
}
 
Example 5
Source File: SilentOpenChest.java    From SuperVanish with Mozilla Public License 2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChestInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    if (!plugin.getVanishStateMgr().isVanished(p.getUniqueId())) return;
    if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
    if (p.getGameMode() == GameMode.SPECTATOR) return;
    //noinspection deprecation
    if (p.isSneaking() && p.getItemInHand() != null
            && (p.getItemInHand().getType().isBlock() || p.getItemInHand().getType() == ITEM_FRAME)
            && p.getItemInHand().getType() != Material.AIR)
        return;
    Block block = e.getClickedBlock();
    if (block == null) return;
    if (block.getType() == ENDER_CHEST) {
        e.setCancelled(true);
        p.openInventory(p.getEnderChest());
        return;
    }
    if (!(block.getType() == CHEST || block.getType() == TRAPPED_CHEST
            || plugin.getVersionUtil().isOneDotXOrHigher(11) && shulkerBoxes.contains(block.getType())))
        return;
    StateInfo stateInfo = StateInfo.extract(p);
    playerStateInfoMap.put(p, stateInfo);
    p.setGameMode(GameMode.SPECTATOR);
}
 
Example 6
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void colorme_cmd() throws CivException {
	Player player = getPlayer();
	String hex = getNamedString(1, "color code");
	long value = Long.decode(hex);
	
	ItemStack inHand = player.getItemInHand();
	if (inHand == null || ItemManager.getId(inHand) == CivData.AIR) {
		throw new CivException("please have an item in your hand.");
	}
	
	AttributeUtil attrs = new AttributeUtil(inHand);
	attrs.setColor(value);		
	player.setItemInHand(attrs.getStack());
	CivMessage.sendSuccess(player, "Set color.");
}
 
Example 7
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void setspecial_cmd() throws CivException {
	Player player = getPlayer();
	ItemStack inHand = player.getItemInHand();
	if (inHand == null) {
		throw new CivException("You need an item in your hand.");
	}
	
//	AttributeUtil attrs = new AttributeUtil(inHand);
//	attrs.setCivCraftProperty("customId", "testMyCustomId");
	ItemStack stack = LoreMaterial.addEnhancement(inHand, new LoreEnhancementSoulBound());
	player.setItemInHand(stack);
	CivMessage.send(player, "Set it.");
}
 
Example 8
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void getspecial_cmd() throws CivException {
	Player player = getPlayer();
	ItemStack inHand = player.getItemInHand();
	if (inHand == null) {
		throw new CivException("You need an item in your hand.");
	}
	
	AttributeUtil attrs = new AttributeUtil(inHand);
	String value = attrs.getCivCraftProperty("soulbound");
	
	CivMessage.send(player, "Got:"+value);
}
 
Example 9
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void dupe_cmd() throws CivException {
	Player player = getPlayer();
	
	if (player.getItemInHand() == null || ItemManager.getId(player.getItemInHand()) == 0) {
		throw new CivException("No item in hand.");
	}
	
	player.getInventory().addItem(player.getItemInHand());
	CivMessage.sendSuccess(player, player.getItemInHand().getType().name()+ "duplicated.");
}
 
Example 10
Source File: ItemsListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onRightClickItem(PlayerInteractEvent event){
	if (
			event.getAction() != Action.RIGHT_CLICK_AIR &&
			event.getAction() != Action.RIGHT_CLICK_BLOCK
	){
		return;
	}

	Player player = event.getPlayer();
	GameManager gm = GameManager.getGameManager();
	UhcPlayer uhcPlayer = gm.getPlayersManager().getUhcPlayer(player);
	ItemStack hand = player.getItemInHand();

	if (GameItem.isGameItem(hand)){
		event.setCancelled(true);
		GameItem gameItem = GameItem.getGameItem(hand);
		handleGameItemInteract(gameItem, player, uhcPlayer, hand);
		return;
	}

	if ( (gm.getGameState().equals(GameState.PLAYING) || gm.getGameState().equals(GameState.DEATHMATCH))
			&& UhcItems.isRegenHeadItem(hand)
			&& uhcPlayer.getState().equals(PlayerState.PLAYING)
			&& (event.getAction() == Action.RIGHT_CLICK_AIR
			|| event.getAction() == Action.RIGHT_CLICK_BLOCK)
	) {
		event.setCancelled(true);
		uhcPlayer.getTeam().regenTeam(gm.getConfiguration().getEnableDoubleRegenHead());
		player.getInventory().remove(hand);
	}
}
 
Example 11
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void loretest_cmd() throws CivException {
	Player player = getPlayer();
	
	org.bukkit.inventory.ItemStack inHand = player.getItemInHand();
	if (inHand != null) {
		ItemMeta meta = inHand.getItemMeta();
		List<String> newLore = meta.getLore();
		if (newLore != null && newLore.size() > 0 && newLore.get(0).equalsIgnoreCase("RJMAGIC")) {
			CivMessage.sendSuccess(player, "found magic lore");
		} else {
			CivMessage.sendSuccess(player, "No magic lore.");
		}
	}
}
 
Example 12
Source File: PlayerListener.java    From ObsidianDestroyer with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    ItemStack inHand = player.getItemInHand();
    // They no longer throw the interact event if the player is in creative, so lets do right click.
    if (inHand == null || event.getAction() != Action.RIGHT_CLICK_BLOCK || !event.hasBlock()
            || !player.hasPermission("obsidiandestroyer.check")) {
        return;
    }

    Material type = inHand.getType();
    Block block = event.getClickedBlock();
    if (!ConfigManager.getInstance().getDurabilityCheckItem().equals(type)) {
        return;
    }

    MaterialManager mm = MaterialManager.getInstance();
    if (block != null && mm.getDurabilityEnabled(block.getType().name())) {
        int amount = ChunkManager.getInstance().getMaterialDurability(block);
        double mult = Util.getMultiplier(block.getLocation());
        if (mult == 0) {
            player.sendMessage(ConfigManager.getInstance().getDurabilityMessage().replace("{DURABILITY}", "∞"));
        } else {
            int max = (int) Math.round(mm.getDurability(block.getType().name(), block.getData()) * Util.getMultiplier(block.getLocation()));
            player.sendMessage(ConfigManager.getInstance().getDurabilityMessage().replace("{DURABILITY}", !mm.isDestructible(block.getType().name(), block.getData()) ? "∞" : (max - amount) + "/" + max));
        }
    }
}
 
Example 13
Source File: Grenade.java    From QualityArmory with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public boolean onRMB(Player thrower, ItemStack usedItem) {
	if (throwItems.containsKey(thrower)) {
		ThrowableHolder holder = throwItems.get(thrower);
		ItemStack grenadeStack = thrower.getItemInHand();
		ItemStack temp = grenadeStack.clone();
		temp.setAmount(1);
		if (thrower.getGameMode() != GameMode.CREATIVE) {
			if (grenadeStack.getAmount() > 1) {
				grenadeStack.setAmount(grenadeStack.getAmount() - 1);
			} else {
				grenadeStack = null;
			}
			thrower.setItemInHand(grenadeStack);
		}
		Item grenade = holder.getHolder().getWorld().dropItem(holder.getHolder().getLocation().add(0, 1.5, 0),
				temp);
		grenade.setPickupDelay(Integer.MAX_VALUE);
		grenade.setVelocity(thrower.getLocation().getDirection().normalize().multiply(1.2));
		holder.setHolder(grenade);
		thrower.getWorld().playSound(thrower.getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1.5f);

		throwItems.put(grenade, holder);
		throwItems.remove(thrower);
		QAMain.DEBUG("Throw grenade");
	} else {
		thrower.sendMessage(QAMain.prefix + QAMain.S_GRENADE_PULLPIN);
	}
	return true;
}
 
Example 14
Source File: BookFormatter.java    From TabooLib with MIT License 5 votes vote down vote up
public static void forceOpen(Player player, ItemStack book) {
    ItemStack hand = player.getItemInHand();
    player.setItemInHand(book);
    try {
        NMS.handle().openBook(player, book);
    } catch (Throwable t) {
        t.printStackTrace();
    }
    player.setItemInHand(hand);
}
 
Example 15
Source File: DebugCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void getdura_cmd() throws CivException {
	Player player = getPlayer();
	ItemStack inHand = player.getItemInHand();
	CivMessage.send(player, "Durability:"+inHand.getDurability());
	CivMessage.send(player, "MaxDura:"+inHand.getType().getMaxDurability());
	
}
 
Example 16
Source File: VeinMinerListener.java    From UhcCore with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onBlockBreak(BlockBreakEvent e){
    Player player = e.getPlayer();

    if (!player.isSneaking()){
        return;
    }

    Block block = e.getBlock();
    ItemStack tool = player.getItemInHand();

    if (block.getType() == UniversalMaterial.GLOWING_REDSTONE_ORE.getType()){
        block.setType(Material.REDSTONE_ORE);
    }

    if (!UniversalMaterial.isCorrectTool(block.getType(), player.getItemInHand().getType())){
        return;
    }

    // find all surrounding blocks
    Vein vein = new Vein(block);
    vein.process();

    player.getWorld().dropItem(player.getLocation().getBlock().getLocation().add(.5,.5,.5), vein.getDrops(getVeinMultiplier(vein.getDropType())));

    if (vein.getTotalXp() != 0){
        UhcItems.spawnExtraXp(player.getLocation(), vein.getTotalXp());
    }

    // Process blood diamonds.
    if (isActivated(Scenario.BLOODDIAMONDS) && vein.getDropType() == Material.DIAMOND){
        player.getWorld().playSound(player.getLocation(), UniversalSound.PLAYER_HURT.getSound(), 1, 1);

        if (player.getHealth() < vein.getOres()){
            player.setHealth(0);
        }else {
            player.setHealth(player.getHealth() - vein.getOres());
        }
    }

    int newDurability = tool.getDurability()-vein.getOres();
    if (newDurability<1) newDurability = 1;

    tool.setDurability((short) newDurability);
    player.setItemInHand(tool);
}
 
Example 17
Source File: Version_Util.java    From CratesPlus with GNU General Public License v3.0 4 votes vote down vote up
public ItemStack getItemInPlayersHand(Player player) {
    return player.getItemInHand();
}
 
Example 18
Source File: KitLoading.java    From AnnihilationPro with MIT License 4 votes vote down vote up
@EventHandler(priority=EventPriority.HIGHEST)
public void navCompassCheck(PlayerInteractEvent event)
{
	if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
	{
		final Player player = event.getPlayer();
		ItemStack item = player.getItemInHand();
		String name = null;
		Loc target = null;
		if(KitUtils.itemHasName(item, CustomItem.NAVCOMPASS.getName()))
		{
			name = redcompass;
			target = AnniTeam.Red.getNexus().getLocation();
		}
		else if(KitUtils.itemHasName(item, redcompass))
		{
			name = bluecompass;
			target = AnniTeam.Blue.getNexus().getLocation();
		}
		else if(KitUtils.itemHasName(item, bluecompass))
		{
			name = greencompass;
			target = AnniTeam.Green.getNexus().getLocation();
		}
		else if(KitUtils.itemHasName(item, greencompass))
		{
			name = yellowcompass;
			target = AnniTeam.Yellow.getNexus().getLocation();
		}
		else if(KitUtils.itemHasName(item, yellowcompass))
		{
			name = redcompass;
			target = AnniTeam.Red.getNexus().getLocation();
		}
		
		if(name != null && target != null)
		{
			ItemMeta m = item.getItemMeta();
			m.setDisplayName(name);
			item.setItemMeta(m);
			player.setCompassTarget(target.toLocation());
		}
	}
}
 
Example 19
Source File: CommandClaimBan.java    From GriefDefender with MIT License 4 votes vote down vote up
@CommandCompletion("@gdbantypes @gdmcids @gddummy")
@CommandAlias("claimban")
@Description("Bans target id from all usage.")
@Syntax("hand | <type> <target> [<message>]")
@Subcommand("ban")
public void execute(Player player, String type, @Optional String id, @Optional String message) {
    Component component = null;
    if (type.equalsIgnoreCase("block")) {
        if (!BlockTypeRegistryModule.getInstance().getById(id).isPresent()) {
            TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.REGISTRY_BLOCK_NOT_FOUND,
                    ImmutableMap.of("id", TextComponent.of(id, TextColor.LIGHT_PURPLE))));
            return;
        }
        if (message == null) {
            component = TextComponent.empty();
        } else {
            component = LegacyComponentSerializer.legacy().deserialize(message, '&');
        }
        GriefDefenderPlugin.getGlobalConfig().getConfig().bans.addBlockBan(id, component);
        GriefDefenderPlugin.getGlobalConfig().save();
        TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_CLAIMBAN_SUCCESS_BLOCK,
                ImmutableMap.of("id", TextComponent.of(id, TextColor.LIGHT_PURPLE))));
    } else if (type.equalsIgnoreCase("entity")) {
        if (!EntityTypeRegistryModule.getInstance().getById(id).isPresent()) {
            TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.REGISTRY_ENTITY_NOT_FOUND,
                    ImmutableMap.of("id", TextComponent.of(id, TextColor.LIGHT_PURPLE))));
            return;
        }
        if (message == null) {
            component = TextComponent.empty();
        } else {
            component = LegacyComponentSerializer.legacy().deserialize(message, '&');
        }
        GriefDefenderPlugin.getGlobalConfig().getConfig().bans.addEntityBan(id, component);
        GriefDefenderPlugin.getGlobalConfig().save();
        TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_CLAIMBAN_SUCCESS_ENTITY,
                ImmutableMap.of("id", TextComponent.of(id, TextColor.LIGHT_PURPLE))));
    } else if (type.equalsIgnoreCase("item")) {
        if (!ItemTypeRegistryModule.getInstance().getById(id).isPresent()) {
            TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.REGISTRY_ITEM_NOT_FOUND,
                    ImmutableMap.of("id", TextComponent.of(id, TextColor.LIGHT_PURPLE))));
            return;
        }
        if (message == null) {
            component = TextComponent.empty();
        } else {
            component = LegacyComponentSerializer.legacy().deserialize(message, '&');
        }
        GriefDefenderPlugin.getGlobalConfig().getConfig().bans.addItemBan(id, component);
        GriefDefenderPlugin.getGlobalConfig().save();
        TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_CLAIMBAN_SUCCESS_ITEM,
                ImmutableMap.of("id", TextComponent.of(id, TextColor.LIGHT_PURPLE))));
    } else if (type.equalsIgnoreCase("hand")) {
        final ItemStack itemInHand = player.getItemInHand();
        final String handItemId = ItemTypeRegistryModule.getInstance().getNMSKey(itemInHand);
        if (message == null) {
            component = TextComponent.empty();
        } else {
            component = LegacyComponentSerializer.legacy().deserialize(message, '&');
        }
        GriefDefenderPlugin.getGlobalConfig().getConfig().bans.addItemBan(handItemId, component);
        GriefDefenderPlugin.getGlobalConfig().save();
        TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_CLAIMBAN_SUCCESS_ITEM,
                ImmutableMap.of("id", TextComponent.of(handItemId, TextColor.LIGHT_PURPLE))));
    }
    if (component == null) {
        TextAdapter.sendComponent(player, MessageStorage.MESSAGE_DATA.getMessage(MessageStorage.COMMAND_INVALID_TYPE,
                ImmutableMap.of("type", type)));
    }
}
 
Example 20
Source File: PlayerInteractListener.java    From IridiumSkyblock with GNU General Public License v2.0 4 votes vote down vote up
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    try {
        final Player player = event.getPlayer();
        final Location playerLocation = player.getLocation();
        final IslandManager islandManager = IridiumSkyblock.getIslandManager();
        if (!islandManager.isIslandWorld(playerLocation)) return;

        final User user = User.getUser(player);
        final Block block = event.getClickedBlock();

        if (event.getAction().toString().startsWith("RIGHT_CLICK")) {
            if (player.getItemInHand() != null) {
                int crystals = Utils.getCrystals(player.getItemInHand()) * player.getItemInHand().getAmount();
                if (crystals != 0) {
                    player.setItemInHand(null);
                    user.getIsland().setCrystals(user.getIsland().getCrystals() + crystals);
                    player.sendMessage(Utils.color(IridiumSkyblock.getMessages().depositedCrystals.replace("%amount%", crystals + "").replace("%prefix%", IridiumSkyblock.getConfiguration().prefix)));
                }
            }
        }

        if (block != null) {
            final Location location = block.getLocation();
            final Island island = islandManager.getIslandViaLocation(location);
            if (island != null) {
                if (!island.getPermissions(user).interact) {
                    event.setCancelled(true);
                    return;
                }
                final ItemStack itemInHand = player.getItemInHand();
                if (itemInHand.getType().equals(Material.BUCKET) && island.failedGenerators.remove(location)) {
                    if (itemInHand.getAmount() == 1)
                        itemInHand.setType(Material.LAVA_BUCKET);
                    else {
                        player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
                        player.getItemInHand().setAmount(itemInHand.getAmount() - 1);
                    }
                    block.setType(Material.AIR);
                }
            } else if (!user.bypassing) {
                event.setCancelled(true);
                return;
            }
        }

        final ItemStack item = event.getItem();
        if (IridiumSkyblock.getConfiguration().allowWaterInNether
                && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
                && item != null
                && block != null) {
            final World world = block.getWorld();
            if (!world.getEnvironment().equals(World.Environment.NETHER)) return;
            if (!item.getType().equals(Material.WATER_BUCKET)) return;

            event.setCancelled(true);

            final BlockFace face = event.getBlockFace();
            block.getRelative(face).setType(Material.WATER);

            final Block relative = block.getRelative(face);
            final BlockPlaceEvent blockPlaceEvent = new BlockPlaceEvent(relative, relative.getState(), block, item, player, false);
            if (blockPlaceEvent.isCancelled()) {
                block.getRelative(face).setType(Material.AIR);
            } else if (player.getGameMode().equals(GameMode.SURVIVAL)) {
                if (item.getAmount() == 1) {
                    item.setType(Material.BUCKET);
                } else {
                    item.setAmount(item.getAmount() - 1);
                    player.getInventory().addItem(new ItemStack(Material.BUCKET));
                }
            }
        }
    } catch (Exception e) {
        IridiumSkyblock.getInstance().sendErrorMessage(e);
    }
}