sponge: Fix claim create triggering twice in claim mode.

* Fix some issues with visuals while claiming.
This commit is contained in:
bloodshot 2019-12-24 00:12:42 -05:00
parent 8e6d2671f3
commit ff82031cdd

View File

@ -752,6 +752,18 @@ public void onPlayerChangeHeldItem(ChangeInventoryEvent.Held event, @First Playe
GriefDefenderPlugin.sendMessage(player, message);
}
} else if (!playerData.claimMode) {
if (playerData.lastShovelLocation != null) {
playerData.revertActiveVisual(player);
// check for any active WECUI visuals
if (this.worldEditProvider != null) {
this.worldEditProvider.revertVisuals(player, playerData, null);
}
}
playerData.lastShovelLocation = null;
playerData.endShovelLocation = null;
playerData.claimResizing = null;
playerData.shovelMode = ShovelTypes.BASIC;
}
count++;
}
@ -797,7 +809,7 @@ public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand eve
if (handleItemInteract(event, player, player.getWorld(), itemInHand).isCancelled()) {
return;
}
} else if (playerData.claimMode) {
} else {
if (investigateClaim(event, player, event.getTargetBlock(), itemInHand)) {
event.setCancelled(true);
}
@ -955,7 +967,14 @@ public InteractEvent handleItemInteract(InteractEvent event, Player player, Worl
return event;
}
if (!primaryEvent) {
onPlayerHandleClaimCreateAction(event, blockSnapshot, player, itemInHand, playerData);
if (playerData.claimMode && event instanceof HandInteractEvent) {
final HandInteractEvent handInteractEvent = (HandInteractEvent) event;
if (handInteractEvent.getHandType() == HandTypes.MAIN_HAND) {
onPlayerHandleClaimCreateAction(event, blockSnapshot, player, itemInHand, playerData);
}
} else {
onPlayerHandleClaimCreateAction(event, blockSnapshot, player, itemInHand, playerData);
}
}
return event;
}
@ -1539,9 +1558,6 @@ private boolean investigateClaim(InteractEvent event, Player player, BlockSnapsh
// claim mode inspects with left-click
return false;
}
if (!playerData.claimMode && (itemInHand.isEmpty() || itemInHand.getType() != GriefDefenderPlugin.getInstance().investigationTool.getType())) {
return false;
}
if (event instanceof InteractItemEvent.Primary || event instanceof InteractBlockEvent.Primary) {
if (!playerData.claimMode || !playerData.visualBlocks.isEmpty()) {
@ -1554,6 +1570,10 @@ private boolean investigateClaim(InteractEvent event, Player player, BlockSnapsh
}
}
if (!playerData.claimMode && (itemInHand.isEmpty() || itemInHand.getType() != GriefDefenderPlugin.getInstance().investigationTool.getType())) {
return false;
}
GDTimings.PLAYER_INVESTIGATE_CLAIM.startTimingIfSync();
// if holding shift (sneaking), show all claims in area
GDClaim claim = null;