Hi, I have a plugin that allows blocks to go into your inventory instead of dropping on the ground but here is the issue GIF WITHOUT PLUGIN INSTALLED https://gyazo.com/590403c057a37231aa6b51c66a3dba96 GIF WITH PLUGIN INSTALLED https://gyazo.com/2e06528ba40e47bd28c26211345dacbf Can you see how in the second gif it doesn't allow you to keep moving unless the blocks were broken or something? How can I fix this? Thank you! CODE: https://pastebin.com/GjY9iLix
this.plugin.getBlocks().containsKey() If this is not a Hash based collection i got bad news for you... Show the MinePickup.class pls Also you dont need to parse the inventory for empty slots by yourself. Inventory#addItem(ItemStack...) returns a Map<ItemStack, Integer> of every item that did not fit. You can just do ItemStack item; Consumer<ItemStack> overheadConsumer; player.getInventory().addItem(item).values().forEach(overheadConsumer); or player.getInventory().addItem(item).values().forEach(left -> player.getLocation().getWorld().dropItemNaturally(player.getLocation, left)); PS: I wrote this to get the drops of a Block with any item respecting enchantments etc: Code (Java): public class BlockBreak_1_14 implements BreakEvaluator{ @Override public List<ItemStack> evaluate(World world, ItemStack breakItem, BlockState blockToBreak) { WorldServer ws = ((CraftWorld) world).getHandle(); IBlockData data = ((CraftBlockState)blockToBreak).getHandle(); BlockPosition position = ((CraftBlockState)blockToBreak).getBlock().getPosition(); LootTableInfo.Builder info = new LootTableInfo.Builder(ws) .set(LootContextParameters.POSITION, position) .set(LootContextParameters.BLOCK_STATE, data) .setOptional(LootContextParameters.BLOCK_ENTITY, ws.getTileEntity(position)) .setOptional(LootContextParameters.TOOL, CraftItemStack.asNMSCopy(breakItem)); return data.a(info).stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()); } } You also don't really need the worldguard hook. Just check if the event is cancelled. Otherwise you will duplicate blocks from other plugins that cancel block break. I know of some plugins that use diamond or emerald blocks. This could destroy a whole servers economy by itself. Also what is up with the whole this.plugin.getBlocks().put(player.getUniqueId(), Double.valueOf(((Double)this.plugin.getBlocks().get(player.getUniqueId())).doubleValue() + 1.0D)); stuff? Incrementing should be done with a long or int. You need to organize your code more. This stuff can be done in 6 lines including all checks. Create new classes that have isolated tasks. Create a BlockCounter class for example that has the purpose of counting up. Spoiler: Maybe like this