From b3b7b5e601f90293d711915a2c6ecf468602a40e Mon Sep 17 00:00:00 2001 From: PhiRobot Date: Sun, 26 Oct 2025 12:50:44 +0000 Subject: [PATCH 1/5] Add TLS Feature --- .../BauSystem_Main/src/BauSystem.properties | 7 +- .../features/tntlistener/TLSCommand.java | 39 +++++ .../features/tntlistener/TLSListener.java | 162 ++++++++++++++++++ .../tntlistener/TLSScoreboardElement.java | 46 +++++ 4 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index aea72646..e8b74647 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -1027,4 +1027,9 @@ XRAY_OFF=§cXray deactivated COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another TYPEREPLACE_HELP=§8//§etypereplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another # Schematic -SCHEMATIC_GUI_ITEM=§eSchematics \ No newline at end of file +SCHEMATIC_GUI_ITEM=§eSchematics +# TNTListener +TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0}§8: §e{1} §7TNT +TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0}§8: §e{1} §7TNT §8(§e{2} §7with Fuse 80§8) +TLS_START_HELP=§7Start the TNT Listener +TLS_STOP_HELP=§7Stop the TNT Listener \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java new file mode 100644 index 00000000..9336ea39 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java @@ -0,0 +1,39 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2025 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tntlistener; + +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; + +@Linked +public class TLSCommand extends SWCommand { + public TLSCommand() { super("tntlistener", "tls"); } + + @Register(value = "start", description = "TLS_START_HELP") + public void start(@Validator Player player) { + TLSListener.instance.startListening(player); + } + + @Register(value = "stop", description = "TLS_STOP_HELP") + public void stop(@Validator Player player) { + TLSListener.instance.stopListening(player); + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java new file mode 100644 index 00000000..806fec7f --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java @@ -0,0 +1,162 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2025 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tntlistener; + +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.entity.Player; + +import java.util.*; + +@Linked +public class TLSListener implements Listener { + + @LinkedInstance + BauSystem bauSystem; + + /** + * Expose an instance to the TLS Command so it can access it + */ + @LinkedInstance + public static TLSListener instance; + + private final Map> primedTNT = new HashMap<>(); + + private final Map regionSheduled = new HashMap<>(); + + private final Map regionReferenceTick = new HashMap<>(); + + private final List listeningPlayers = new ArrayList<>(); + + private boolean listening = false; + + private final long maxDelay = 120; + + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + public void onTNTSpawn(EntitySpawnEvent event) { + if (!(event.getEntity() instanceof TNTPrimed tnt)) return; + if (!(listening)) return; + + Region eventRegion = Region.getRegion(event.getLocation()); + + // Add tnt to the list + if (!primedTNT.containsKey(eventRegion)) { + primedTNT.put(eventRegion, new ArrayList<>()); + } + primedTNT.get(eventRegion).add(tnt); + + // Update the realtiveTick + long currentTick = TPSUtils.currentRealTick.get(); + + long referenceTick = regionReferenceTick.getOrDefault(eventRegion, 0L); + if (currentTick - referenceTick > maxDelay) { + referenceTick = currentTick; + regionReferenceTick.put(eventRegion, referenceTick); + } + long relativeTick = currentTick - referenceTick; + + this.messageNextTick(eventRegion, relativeTick); + } + + public void messageNextTick(Region region, long relativeTick) { + /* + * Some TNT can be spawned so late in the gt, that they do not get processed, + * essentially lengthening their fuse by 1gt. To detect this, shedule the + * message at the start of the next (server side) gt. If the tnt got processed it has a + * Fuse of 79, else 80. + */ + + if (regionSheduled.getOrDefault(region, false)) { + return; + } + regionSheduled.put(region, true); + + new BukkitRunnable() { + @Override + public void run() { + + regionSheduled.remove(region); + + int primed80 = 0; + int primed79 = 0; + //tntFuse79.put(region, 0); + //tntFuse80.put(region, 0); + for (TNTPrimed tnt : primedTNT.get(region)) { + if (tnt.getFuseTicks() == 80) { + primed80++; + //tntFuse80.put(region, tntFuse80.getOrDefault(region, 0) + 1); + } else if (tnt.getFuseTicks() == 79) { + primed79++; + //tntFuse79.getOrDefault(region, tntFuse79.getOrDefault(region, 0) + 1); + } + } + //primedTNT.get(region).removeIf(t -> t.getFuseTicks() <= 78 || t.isDead()); + primedTNT.get(region).clear(); + + /* + * Message the player, if there are tnt with Fuse 80 use special message + */ + for (Player p : listeningPlayers) { + if (region.getArea().inRegion(p.getLocation(), false)) { + if (primed80 > 0) { + // Foreach throws IDE errors: variables in lambda expressions should be final + //p.sendMessage(String.format("§7TLS§8> §7Tick §e%d§8: §e%d §7TNT §8(§e%d §7with Fuse 80§8)", relativeTick, primed79 + primed80, primed80)); + BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_80", p, relativeTick, primed79 + primed80, primed80); + } else { + BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_79", p, relativeTick, primed79); + //p.sendMessage(String.format("§7TLS§8> §7Tick §e%d§8: §e%d §7TNT", relativeTick, primed79)); + } + } + } + } + }.runTaskLater(bauSystem.getInstance(), 1); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + listeningPlayers.remove(event.getPlayer()); + } + + public void startListening(Player player) { + this.listening = true; + listeningPlayers.add(player); + } + + public void stopListening(Player player) { + listeningPlayers.remove(player); + if (listeningPlayers.toArray().length == 0) { + this.listening = false; + } + } + + public boolean isActiveFor(Player player) { + return listeningPlayers.contains(player); + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java new file mode 100644 index 00000000..61f842e5 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java @@ -0,0 +1,46 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2025 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tntlistener; + +import de.steamwar.linkage.Linked; +import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.utils.ScoreboardElement; +import org.bukkit.entity.Player; + +@Linked +public class TLSScoreboardElement implements ScoreboardElement { + + @Override + public ScoreboardGroup getGroup() { return ScoreboardGroup.OTHER; } + + @Override + public int order() { return 2; } + + @Override + public String get(Region region, Player p) { + if (!Permission.BUILD.hasPermission(p)) return null; + if (TLSListener.instance.isActiveFor(p)) { + return "§e" + "TLS" + "§8: " + "§aon"; + } else { + return null; + } + } +} From 3b87a18a5f574be37316f2008c1e2665d7e05325 Mon Sep 17 00:00:00 2001 From: PhiRobot Date: Sun, 26 Oct 2025 13:03:00 +0000 Subject: [PATCH 2/5] Modified Format of the TLS Message --- BauSystem/BauSystem_Main/src/BauSystem.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index e8b74647..e258d2e6 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -1029,7 +1029,7 @@ TYPEREPLACE_HELP=§8//§etypereplace §8[§7type§8] §8[§7type§8] §8- §7Rep # Schematic SCHEMATIC_GUI_ITEM=§eSchematics # TNTListener -TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0}§8: §e{1} §7TNT -TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0}§8: §e{1} §7TNT §8(§e{2} §7with Fuse 80§8) +TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} +TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} §8(§e{2} §7with Fuse 80§8) TLS_START_HELP=§7Start the TNT Listener TLS_STOP_HELP=§7Stop the TNT Listener \ No newline at end of file From 442ef71a17d5cbd78f3c045697cbb712304ff1ff Mon Sep 17 00:00:00 2001 From: PhiRobot Date: Sun, 26 Oct 2025 14:22:20 +0000 Subject: [PATCH 3/5] Fix PR Comments --- .../BauSystem_Main/src/BauSystem.properties | 5 +- .../src/BauSystem_de.properties | 7 +- .../features/tntlistener/TLSCommand.java | 13 ++- .../features/tntlistener/TLSListener.java | 86 +++++++++++-------- .../tntlistener/TLSScoreboardElement.java | 21 +++-- .../de/steamwar/linkage/AbstractLinker.java | 2 +- 6 files changed, 84 insertions(+), 50 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index e258d2e6..432ac00a 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -1031,5 +1031,6 @@ SCHEMATIC_GUI_ITEM=§eSchematics # TNTListener TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} §8(§e{2} §7with Fuse 80§8) -TLS_START_HELP=§7Start the TNT Listener -TLS_STOP_HELP=§7Stop the TNT Listener \ No newline at end of file +TLS_START_HELP=§8/§etls start §8: §7Start the TNT Listener +TLS_STOP_HELP=§8/§etls stop §8: §7Stop the TNT Listener +TLS_SCOREBOARD_ELEMENT=§eTLS§8: §aon \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index e96c9316..8e88f01f 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -959,4 +959,9 @@ XRAY_OFF=§cXray deaktiviert COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen TYPEREPLACE_HELP=§8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen # Schematics -SCHEMATIC_GUI_ITEM=§eSchematics \ No newline at end of file +SCHEMATIC_GUI_ITEM=§eSchematics +TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} +TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} §8(§e{2} §7mit Fuse 80§8) +TLS_START_HELP=§8/§etls start §8: §7Starte den TNT Listener +TLS_STOP_HELP=§8/§etls stop §8: §7Stope den TNT Listener +TLS_SCOREBOARD_ELEMENT=§eTLS§8: §aan \ No newline at end of file diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java index 9336ea39..355803dc 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSCommand.java @@ -21,19 +21,26 @@ package de.steamwar.bausystem.features.tntlistener; import de.steamwar.command.SWCommand; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.entity.Player; @Linked public class TLSCommand extends SWCommand { - public TLSCommand() { super("tntlistener", "tls"); } + + @LinkedInstance + private TLSListener listener; + + public TLSCommand() { + super("tntlistener", "tls"); + } @Register(value = "start", description = "TLS_START_HELP") public void start(@Validator Player player) { - TLSListener.instance.startListening(player); + listener.startListening(player); } @Register(value = "stop", description = "TLS_STOP_HELP") public void stop(@Validator Player player) { - TLSListener.instance.stopListening(player); + listener.stopListening(player); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java index 806fec7f..17952e1d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java @@ -19,19 +19,18 @@ package de.steamwar.bausystem.features.tntlistener; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.entity.Player; import java.util.*; @@ -39,38 +38,30 @@ import java.util.*; public class TLSListener implements Listener { @LinkedInstance - BauSystem bauSystem; - - /** - * Expose an instance to the TLS Command so it can access it - */ - @LinkedInstance - public static TLSListener instance; + private BauSystem bauSystem; private final Map> primedTNT = new HashMap<>(); - private final Map regionSheduled = new HashMap<>(); + private final Set regionSheduled = new HashSet<>(); private final Map regionReferenceTick = new HashMap<>(); - private final List listeningPlayers = new ArrayList<>(); + private final Set listeningPlayers = new HashSet<>(); private boolean listening = false; + //TODO: Make adjustable per region private final long maxDelay = 120; - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler(ignoreCancelled = true) public void onTNTSpawn(EntitySpawnEvent event) { if (!(event.getEntity() instanceof TNTPrimed tnt)) return; - if (!(listening)) return; + if (!listening) return; Region eventRegion = Region.getRegion(event.getLocation()); // Add tnt to the list - if (!primedTNT.containsKey(eventRegion)) { - primedTNT.put(eventRegion, new ArrayList<>()); - } - primedTNT.get(eventRegion).add(tnt); + primedTNT.computeIfAbsent(eventRegion, rg -> new ArrayList<>()).add(tnt); // Update the realtiveTick long currentTick = TPSUtils.currentRealTick.get(); @@ -93,11 +84,13 @@ public class TLSListener implements Listener { * Fuse of 79, else 80. */ - if (regionSheduled.getOrDefault(region, false)) { + if (!regionSheduled.add(region)) { return; } - regionSheduled.put(region, true); + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> messagePlayer(region, relativeTick), 1); + + /* new BukkitRunnable() { @Override public void run() { @@ -106,52 +99,71 @@ public class TLSListener implements Listener { int primed80 = 0; int primed79 = 0; - //tntFuse79.put(region, 0); - //tntFuse80.put(region, 0); - for (TNTPrimed tnt : primedTNT.get(region)) { + for (TNTPrimed tnt : primedTNT.getOrDefault(region, Collections.emptyList())) { if (tnt.getFuseTicks() == 80) { primed80++; - //tntFuse80.put(region, tntFuse80.getOrDefault(region, 0) + 1); } else if (tnt.getFuseTicks() == 79) { primed79++; - //tntFuse79.getOrDefault(region, tntFuse79.getOrDefault(region, 0) + 1); } } - //primedTNT.get(region).removeIf(t -> t.getFuseTicks() <= 78 || t.isDead()); - primedTNT.get(region).clear(); + primedTNT.remove(region); - /* * Message the player, if there are tnt with Fuse 80 use special message - */ for (Player p : listeningPlayers) { if (region.getArea().inRegion(p.getLocation(), false)) { if (primed80 > 0) { - // Foreach throws IDE errors: variables in lambda expressions should be final - //p.sendMessage(String.format("§7TLS§8> §7Tick §e%d§8: §e%d §7TNT §8(§e%d §7with Fuse 80§8)", relativeTick, primed79 + primed80, primed80)); BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_80", p, relativeTick, primed79 + primed80, primed80); } else { BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_79", p, relativeTick, primed79); - //p.sendMessage(String.format("§7TLS§8> §7Tick §e%d§8: §e%d §7TNT", relativeTick, primed79)); } } } } - }.runTaskLater(bauSystem.getInstance(), 1); + }.runTaskLater(bauSystem.getInstance(), 1);*/ + } + + private void messagePlayer(Region region, long relativeTick) { + + regionSheduled.remove(region); + + int primed80 = 0; + int primed79 = 0; + for (TNTPrimed tnt : primedTNT.getOrDefault(region, Collections.emptyList())) { + if (tnt.getFuseTicks() == 80) { + primed80++; + } else if (tnt.getFuseTicks() == 79) { + primed79++; + } + } + primedTNT.remove(region); + + /* + * Message the player, if there are tnt with Fuse 80 use special message + */ + for (Player p : listeningPlayers) { + if (region.getArea().inRegion(p.getLocation(), false)) { + if (primed80 > 0) { + BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_80", p, relativeTick, primed79 + primed80, primed80); + } else { + BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_79", p, relativeTick, primed79); + } + } + } } @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - listeningPlayers.remove(event.getPlayer()); + stopListening(event.getPlayer()); } public void startListening(Player player) { - this.listening = true; listeningPlayers.add(player); + this.listening = true; } public void stopListening(Player player) { listeningPlayers.remove(player); - if (listeningPlayers.toArray().length == 0) { + if (listeningPlayers.isEmpty()) { this.listening = false; } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java index 61f842e5..0dec6609 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSScoreboardElement.java @@ -19,26 +19,35 @@ package de.steamwar.bausystem.features.tntlistener; -import de.steamwar.linkage.Linked; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.entity.Player; @Linked public class TLSScoreboardElement implements ScoreboardElement { - @Override - public ScoreboardGroup getGroup() { return ScoreboardGroup.OTHER; } + @LinkedInstance + private TLSListener listener; @Override - public int order() { return 2; } + public ScoreboardGroup getGroup() { + return ScoreboardGroup.OTHER; + } + + @Override + public int order() { + return 2; + } @Override public String get(Region region, Player p) { if (!Permission.BUILD.hasPermission(p)) return null; - if (TLSListener.instance.isActiveFor(p)) { - return "§e" + "TLS" + "§8: " + "§aon"; + if (listener.isActiveFor(p)) { + return BauSystem.MESSAGE.parse("TLS_SCOREBOARD_ELEMENT", p); } else { return null; } diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java index 4f86602d..cf88d488 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -99,7 +99,7 @@ public abstract class AbstractLinker { try { instances.forEach((clazz, o) -> { - for (Field field : clazz.getFields()) { + for (Field field : clazz.getDeclaredFields()) { if (field.getAnnotation(LinkedInstance.class) != null) { try { field.setAccessible(true); From ef75c35809a3a4481392da641b923b905a5f21c5 Mon Sep 17 00:00:00 2001 From: PhiRobot Date: Sun, 26 Oct 2025 14:24:29 +0000 Subject: [PATCH 4/5] Remove unnecessary translation --- BauSystem/BauSystem_Main/src/BauSystem_de.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index 8e88f01f..453b4079 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -960,7 +960,6 @@ COLORREPLACE_HELP=§8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- § TYPEREPLACE_HELP=§8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen # Schematics SCHEMATIC_GUI_ITEM=§eSchematics -TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} §8(§e{2} §7mit Fuse 80§8) TLS_START_HELP=§8/§etls start §8: §7Starte den TNT Listener TLS_STOP_HELP=§8/§etls stop §8: §7Stope den TNT Listener From 57c8e3319a93f5a74bea0ec2110431593a954901 Mon Sep 17 00:00:00 2001 From: PhiRobot Date: Sun, 26 Oct 2025 14:29:48 +0000 Subject: [PATCH 5/5] Remove dead code --- .../features/tntlistener/TLSListener.java | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java index 17952e1d..9b587d8f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tntlistener/TLSListener.java @@ -63,7 +63,7 @@ public class TLSListener implements Listener { // Add tnt to the list primedTNT.computeIfAbsent(eventRegion, rg -> new ArrayList<>()).add(tnt); - // Update the realtiveTick + // Update the relativeTick long currentTick = TPSUtils.currentRealTick.get(); long referenceTick = regionReferenceTick.getOrDefault(eventRegion, 0L); @@ -89,37 +89,6 @@ public class TLSListener implements Listener { } Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> messagePlayer(region, relativeTick), 1); - - /* - new BukkitRunnable() { - @Override - public void run() { - - regionSheduled.remove(region); - - int primed80 = 0; - int primed79 = 0; - for (TNTPrimed tnt : primedTNT.getOrDefault(region, Collections.emptyList())) { - if (tnt.getFuseTicks() == 80) { - primed80++; - } else if (tnt.getFuseTicks() == 79) { - primed79++; - } - } - primedTNT.remove(region); - - * Message the player, if there are tnt with Fuse 80 use special message - for (Player p : listeningPlayers) { - if (region.getArea().inRegion(p.getLocation(), false)) { - if (primed80 > 0) { - BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_80", p, relativeTick, primed79 + primed80, primed80); - } else { - BauSystem.MESSAGE.sendPrefixless("TLS_MESSAGE_79", p, relativeTick, primed79); - } - } - } - } - }.runTaskLater(bauSystem.getInstance(), 1);*/ } private void messagePlayer(Region region, long relativeTick) {