Permalink
Browse files

Potentially fix ITEM_PICKUP consume item command loop.

  • Loading branch information...
me4502 committed Mar 6, 2017
1 parent aa049d9 commit 39daf745b329765281567bcfd8af7ecb88663d36
@@ -273,7 +273,7 @@ public void save() {
if(type != RecipeType.SHAPED) {
LinkedHashMap<String, Integer> resz = new LinkedHashMap<String, Integer>();
for(CraftingItemStack stack : ingredients) {
- resz.put(stack.toString(), stack.getItemStack().getAmount());
+ resz.put(stack.toString() + ' ', stack.getItemStack().getAmount());
}
config.setProperty("crafting-recipes." + id + ".ingredients", resz);
} else {
@@ -377,8 +377,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
@SuppressWarnings("deprecation")
public void performCommandItems(ItemStack item, final Player player, final Event event) {
-
- if (event != null && !EventUtil.passesFilter(event))
+ if (event == null || !EventUtil.passesFilter(event))
return;
LocalPlayer lplayer = CraftBookPlugin.inst().wrapPlayer(player);
@@ -478,6 +477,9 @@ public void performCommandItems(ItemStack item, final Player player, final Event
player.getInventory().getItemInOffHand().setAmount(player.getInventory().getItemInOffHand().getAmount() - 1);
else
player.getInventory().setItemInOffHand(null);
+ } else if (event instanceof PlayerPickupItemEvent) {
+ ((PlayerPickupItemEvent) event).getItem().remove();
+ ((PlayerPickupItemEvent) event).setCancelled(true);
} else {
if (player.getInventory().getItemInMainHand().getAmount() > 1)
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);

0 comments on commit 39daf74

Please sign in to comment.