SteamWar/BauSystem
Archiviert
13
0
Dieser Commit ist enthalten in:
yoyosource 2021-03-20 13:09:25 +01:00
Ursprung e3c471d13d
Commit 6b44f12659
2 geänderte Dateien mit 37 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -45,43 +45,8 @@ import java.util.Map;
public class RedstoneListener implements Listener {
private static class RedstoneTester {
private final Player player;
private Location loc1 = null;
private Location loc2 = null;
private long lastTick = 0;
private Long tick = null;
public RedstoneTester(Player player) {
this.player = player;
}
private void activate(Location location) {
if (loc1 == null || loc2 == null) {
tick = null;
return;
}
if (loc1.equals(location)) {
if (TPSUtils.currentTick.get() - lastTick > 100) {
tick = null;
}
lastTick = TPSUtils.currentTick.get();
if (tick == null) {
tick = TPSUtils.currentTick.get();
}
return;
}
if (tick != null && loc2.equals(location)) {
player.sendMessage(BauSystem.PREFIX + "Differenz§8: §e" + (TPSUtils.currentTick.get() - tick) + "§8 - §7in GameTicks");
}
}
}
private Map<Player, RedstoneTester> playerMap = new HashMap<>();
public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack();
private static Map<Player, RedstoneTester> playerMap = new HashMap<>();
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.build)) {
@ -171,4 +136,40 @@ public class RedstoneListener implements Listener {
redstoneTester.activate(e.getBlock().getLocation());
});
}
private static class RedstoneTester {
private final Player player;
private Location loc1 = null;
private Location loc2 = null;
private long lastTick = 0;
private Long tick = null;
public RedstoneTester(Player player) {
this.player = player;
}
private void activate(Location location) {
if (loc1 == null || loc2 == null) {
tick = null;
return;
}
if (loc1.equals(location)) {
if (TPSUtils.currentTick.get() - lastTick > 100) {
tick = null;
}
lastTick = TPSUtils.currentTick.get();
if (tick == null) {
tick = TPSUtils.currentTick.get();
}
return;
}
if (tick != null && loc2.equals(location)) {
player.sendMessage(BauSystem.PREFIX + "Differenz§8: §e" + (TPSUtils.currentTick.get() - tick) + "§8 - §7in GameTicks");
}
}
}
}

Datei anzeigen

@ -39,7 +39,6 @@ public class TPSUtils {
private static long nanoDOffset = 0;
private static long ticksSinceServerStart = 0;
@SuppressWarnings("java:S4276")
public static final Supplier<Long> currentTick = () -> ticksSinceServerStart;
public static void init() {