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); 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++; count++;
} }
@ -797,7 +809,7 @@ public void onPlayerInteractBlockPrimary(InteractBlockEvent.Primary.MainHand eve
if (handleItemInteract(event, player, player.getWorld(), itemInHand).isCancelled()) { if (handleItemInteract(event, player, player.getWorld(), itemInHand).isCancelled()) {
return; return;
} }
} else if (playerData.claimMode) { } else {
if (investigateClaim(event, player, event.getTargetBlock(), itemInHand)) { if (investigateClaim(event, player, event.getTargetBlock(), itemInHand)) {
event.setCancelled(true); event.setCancelled(true);
} }
@ -955,8 +967,15 @@ public InteractEvent handleItemInteract(InteractEvent event, Player player, Worl
return event; return event;
} }
if (!primaryEvent) { if (!primaryEvent) {
if (playerData.claimMode && event instanceof HandInteractEvent) {
final HandInteractEvent handInteractEvent = (HandInteractEvent) event;
if (handInteractEvent.getHandType() == HandTypes.MAIN_HAND) {
onPlayerHandleClaimCreateAction(event, blockSnapshot, player, itemInHand, playerData); onPlayerHandleClaimCreateAction(event, blockSnapshot, player, itemInHand, playerData);
} }
} else {
onPlayerHandleClaimCreateAction(event, blockSnapshot, player, itemInHand, playerData);
}
}
return event; return event;
} }
@ -1539,9 +1558,6 @@ private boolean investigateClaim(InteractEvent event, Player player, BlockSnapsh
// claim mode inspects with left-click // claim mode inspects with left-click
return false; 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 (event instanceof InteractItemEvent.Primary || event instanceof InteractBlockEvent.Primary) {
if (!playerData.claimMode || !playerData.visualBlocks.isEmpty()) { 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(); GDTimings.PLAYER_INVESTIGATE_CLAIM.startTimingIfSync();
// if holding shift (sneaking), show all claims in area // if holding shift (sneaking), show all claims in area
GDClaim claim = null; GDClaim claim = null;