SteamWar/BauSystem
Archiviert
13
0

Update RedstoneListener core feature

Add plugin.yml redstonetester -> rt
Dieser Commit ist enthalten in:
yoyosource 2021-03-07 16:19:46 +01:00
Ursprung 6d8faea32e
Commit 4faede4abf
2 geänderte Dateien mit 20 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -59,32 +59,30 @@ public class RedstoneListener implements Listener {
private Location loc1 = null; private Location loc1 = null;
private Location loc2 = null; private Location loc2 = null;
private Location activated = null; private long lastTick = 0;
private long tick = 0; private Long tick = null;
public RedstoneTester(Player player) { public RedstoneTester(Player player) {
this.player = player; this.player = player;
} }
private void activate(Location location) { private void activate(Location location) {
if (loc1 != null && loc1.equals(location)) { if (loc1 == null || loc2 == null) {
if (activated != null && !activated.equals(location)) { tick = null;
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; return;
} }
activated = loc1; if (loc1.equals(location)) {
if (currentTick - lastTick > 100) {
tick = null;
}
lastTick = currentTick;
if (tick == null) {
tick = currentTick; 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; return;
} }
activated = loc2; if (tick != null && loc2.equals(location)) {
tick = currentTick; 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."); player.sendMessage(BauSystem.PREFIX + "Positionen gelöscht§8.");
} }
break; break;
case RIGHT_CLICK_BLOCK: case LEFT_CLICK_BLOCK:
if (!validBlock(event.getPlayer(), block.getBlockData())) return; if (!validBlock(event.getPlayer(), block.getBlockData())) return;
playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc1 = block.getLocation(); playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc1 = block.getLocation();
sendLocation(event.getPlayer(), "POS1", block.getLocation()); sendLocation(event.getPlayer(), "POS1", block.getLocation());
break; break;
case LEFT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
if (!validBlock(event.getPlayer(), block.getBlockData())) return; if (!validBlock(event.getPlayer(), block.getBlockData())) return;
playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc2 = block.getLocation(); playerMap.computeIfAbsent(event.getPlayer(), RedstoneTester::new).loc2 = block.getLocation();
sendLocation(event.getPlayer(), "POS2", block.getLocation()); sendLocation(event.getPlayer(), "POS2", block.getLocation());

Datei anzeigen

@ -40,3 +40,4 @@ commands:
aliases: sim aliases: sim
gui: gui:
redstonetester: redstonetester:
aliases: rt