mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Remove unnecessary synchronized block and allow for custom drop amount
This commit is contained in:
parent
99f4c8f2d3
commit
716e2ea5ef
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user