Merge pull request #167 from AtlasMediaGroup/whoops

Fixes an oopsie I made whilst sleep deprived
This commit is contained in:
Video 2021-11-13 02:48:51 -07:00 committed by GitHub
commit 3f690e2ca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -276,17 +276,14 @@ public class CoreProtectBridge extends FreedomService
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
final CoreProtectAPI coreProtect = getCoreProtectAPI(); final CoreProtectAPI coreProtect = getCoreProtectAPI();
// TODO: Rewrite this
if (data.hasInspection()) if (data.hasInspection())
{ {
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (block != null)
{
event.setCancelled(true);
int cooldownTime = 3; 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); long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
if (secondsLeft > 0L) 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); List<String[]> lookup = coreProtect.blockLookup(block, -1);
if (!plugin.al.isAdmin(player)) if (!plugin.al.isAdmin(player))
@ -364,8 +367,6 @@ public class CoreProtectBridge extends FreedomService
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{ {
if (block != null) if (block != null)
{
if (data.hasInspection())
{ {
BlockState blockState = block.getRelative(event.getBlockFace()).getState(); BlockState blockState = block.getRelative(event.getBlockFace()).getState();
Block placedBlock = blockState.getBlock(); Block placedBlock = blockState.getBlock();
@ -377,19 +378,6 @@ public class CoreProtectBridge extends FreedomService
lookup = coreProtect.blockLookup(block, -1); 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)) if (!plugin.al.isAdmin(player))
{ {
cooldown.put(player.getName(), System.currentTimeMillis()); cooldown.put(player.getName(), System.currentTimeMillis());
@ -454,5 +442,4 @@ public class CoreProtectBridge extends FreedomService
} }
} }
} }
}
} }