Remove unnecessary synchronized block and allow for custom drop amount

This commit is contained in:
Felix Cravic 2020-12-08 00:12:49 +01:00
parent 99f4c8f2d3
commit 716e2ea5ef

View File

@ -102,7 +102,7 @@ public class PlayerDiggingListener {
final StackingRule stackingRule = handItem.getStackingRule();
final int handAmount = stackingRule.getAmount(handItem);
if (handAmount == dropAmount) {
if (handAmount <= dropAmount) {
// Drop the whole item without copy
dropItem(player, handItem, ItemStack.getAirItem());
} else {
@ -132,10 +132,8 @@ public class PlayerDiggingListener {
case SWAP_ITEM_HAND:
PlayerSwapItemEvent swapItemEvent = new PlayerSwapItemEvent(player, offHand, mainHand);
player.callCancellableEvent(PlayerSwapItemEvent.class, swapItemEvent, () -> {
synchronized (playerInventory) {
playerInventory.setItemInMainHand(swapItemEvent.getMainHandItem());
playerInventory.setItemInOffHand(swapItemEvent.getOffHandItem());
}
playerInventory.setItemInMainHand(swapItemEvent.getMainHandItem());
playerInventory.setItemInOffHand(swapItemEvent.getOffHandItem());
});
break;
}