mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 11:38:03 +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 StackingRule stackingRule = handItem.getStackingRule();
|
||||||
final int handAmount = stackingRule.getAmount(handItem);
|
final int handAmount = stackingRule.getAmount(handItem);
|
||||||
|
|
||||||
if (handAmount == dropAmount) {
|
if (handAmount <= dropAmount) {
|
||||||
// Drop the whole item without copy
|
// Drop the whole item without copy
|
||||||
dropItem(player, handItem, ItemStack.getAirItem());
|
dropItem(player, handItem, ItemStack.getAirItem());
|
||||||
} else {
|
} else {
|
||||||
@ -132,10 +132,8 @@ public class PlayerDiggingListener {
|
|||||||
case SWAP_ITEM_HAND:
|
case SWAP_ITEM_HAND:
|
||||||
PlayerSwapItemEvent swapItemEvent = new PlayerSwapItemEvent(player, offHand, mainHand);
|
PlayerSwapItemEvent swapItemEvent = new PlayerSwapItemEvent(player, offHand, mainHand);
|
||||||
player.callCancellableEvent(PlayerSwapItemEvent.class, swapItemEvent, () -> {
|
player.callCancellableEvent(PlayerSwapItemEvent.class, swapItemEvent, () -> {
|
||||||
synchronized (playerInventory) {
|
playerInventory.setItemInMainHand(swapItemEvent.getMainHandItem());
|
||||||
playerInventory.setItemInMainHand(swapItemEvent.getMainHandItem());
|
playerInventory.setItemInOffHand(swapItemEvent.getOffHandItem());
|
||||||
playerInventory.setItemInOffHand(swapItemEvent.getOffHandItem());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user