This commit fixes 2 things:
1. A redundant check that was completely unnecessary
2. A loophole in my original bugfix commit I didn't initially discover until afterwards which enables players to do the same thing except with right clicking instead

The block inspector should be completely rewritten in the future, but for now it works.
This commit is contained in:
Video 2021-11-13 02:35:30 -07:00
parent a728ec24d4
commit abfa3b977c

View File

@ -276,17 +276,14 @@ public class CoreProtectBridge extends FreedomService
Block block = event.getClickedBlock();
final CoreProtectAPI coreProtect = getCoreProtectAPI();
// TODO: Rewrite this
if (data.hasInspection())
{
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (block != null)
{
event.setCancelled(true);
int cooldownTime = 3;
if (cooldown.containsKey(player.getName()))
// Cooldown check
if ((event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)
&& cooldown.containsKey(player.getName()))
{
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
if (secondsLeft > 0L)
@ -297,6 +294,12 @@ public class CoreProtectBridge extends FreedomService
}
}
// Actual lookup time
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (block != null)
{
event.setCancelled(true);
List<String[]> lookup = coreProtect.blockLookup(block, -1);
if (!plugin.al.isAdmin(player))
@ -364,8 +367,6 @@ public class CoreProtectBridge extends FreedomService
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if (block != null)
{
if (data.hasInspection())
{
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
Block placedBlock = blockState.getBlock();
@ -377,19 +378,6 @@ public class CoreProtectBridge extends FreedomService
lookup = coreProtect.blockLookup(block, -1);
}
int cooldownTime = 3;
if (cooldown.containsKey(player.getName()))
{
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
if (secondsLeft > 0L)
{
event.setCancelled(true);
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
return;
}
}
if (!plugin.al.isAdmin(player))
{
cooldown.put(player.getName(), System.currentTimeMillis());
@ -455,4 +443,3 @@ public class CoreProtectBridge extends FreedomService
}
}
}
}