From 4faede4abf7d6465bcf1efa848c49fe197ec0804 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 7 Mar 2021 16:19:46 +0100 Subject: [PATCH] Update RedstoneListener core feature Add plugin.yml redstonetester -> rt --- .../bausystem/world/RedstoneListener.java | 38 +++++++++---------- BauSystem_Main/src/plugin.yml | 3 +- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java index 8c87368..43a7fb0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RedstoneListener.java @@ -59,32 +59,30 @@ public class RedstoneListener implements Listener { private Location loc1 = null; private Location loc2 = null; - private Location activated = null; - private long tick = 0; + private long lastTick = 0; + private Long tick = null; public RedstoneTester(Player player) { this.player = player; } private void activate(Location location) { - if (loc1 != null && loc1.equals(location)) { - if (activated != null && !activated.equals(location)) { - player.sendMessage(BauSystem.PREFIX + "Aktivierungsdifferenz§8: §e" + (currentTick - tick)); - player.sendMessage(BauSystem.PREFIX + "Reihenfolge§8: §7" + locationToString(activated) + " §8->§7 " + locationToString(location)); - activated = null; - return; + if (loc1 == null || loc2 == null) { + tick = null; + return; + } + if (loc1.equals(location)) { + if (currentTick - lastTick > 100) { + tick = null; } - activated = loc1; - tick = currentTick; - } else if (loc2 != null && loc2.equals(location)) { - if (activated != null && !activated.equals(location)) { - player.sendMessage(BauSystem.PREFIX + "Aktivierungsdifferenz§8: §e" + (currentTick - tick)); - player.sendMessage(BauSystem.PREFIX + "Reihenfolge§8: §7" + locationToString(activated) + " §8->§7 " + locationToString(location)); - activated = null; - return; + lastTick = currentTick; + if (tick == null) { + tick = currentTick; } - activated = loc2; - tick = currentTick; + return; + } + if (tick != null && loc2.equals(location)) { + player.sendMessage(BauSystem.PREFIX + "Differenz§8: §e" + (currentTick - tick) + "§8 - §7in GameTicks"); } } @@ -107,12 +105,12 @@ public class RedstoneListener implements Listener { player.sendMessage(BauSystem.PREFIX + "Positionen gelöscht§8."); } break; - case RIGHT_CLICK_BLOCK: + case LEFT_CLICK_BLOCK: if (!validBlock(event.getPlayer(), block.getBlockData())) return; playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc1 = block.getLocation(); sendLocation(event.getPlayer(), "POS1", block.getLocation()); break; - case LEFT_CLICK_BLOCK: + case RIGHT_CLICK_BLOCK: if (!validBlock(event.getPlayer(), block.getBlockData())) return; playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc2 = block.getLocation(); sendLocation(event.getPlayer(), "POS2", block.getLocation()); diff --git a/BauSystem_Main/src/plugin.yml b/BauSystem_Main/src/plugin.yml index 4ab7a2c..5bb49e5 100644 --- a/BauSystem_Main/src/plugin.yml +++ b/BauSystem_Main/src/plugin.yml @@ -39,4 +39,5 @@ commands: simulator: aliases: sim gui: - redstonetester: \ No newline at end of file + redstonetester: + aliases: rt \ No newline at end of file