From a9fbb4cd8d35e4fa60ff09e47144f930c1af8f71 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 31 Oct 2026 15:36:02 +0100 Subject: [PATCH] Combine techhider, xray and hullhider scoreboard lines As only one of /techhider, /xray and /hullhider can be active per region, the scoreboard shows them in a single "View" line naming the active one. --- .../BauSystem_Main/src/BauSystem.properties | 4 +- .../src/BauSystem_de.properties | 4 +- .../features/hullhider/HullHiderCommand.java | 19 +---- .../features/techhider/TechHiderCommand.java | 19 +---- .../techhider/ViewScoreboardElement.java | 70 +++++++++++++++++++ .../bausystem/features/xray/XrayCommand.java | 19 +---- 6 files changed, 81 insertions(+), 54 deletions(-) create mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/ViewScoreboardElement.java diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index 80e591d9..fdbe8ff3 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -35,9 +35,7 @@ SCOREBOARD_LOADER = Loader SCOREBOARD_TPS = TPS SCOREBOARD_TPS_FROZEN = §eFrozen SCOREBOARD_TRACE_TICKS = Ticks -SCOREBOARD_TECHHIDER = TechHider§8: §aOn -SCOREBOARD_XRAY = XRay§8: §aOn -SCOREBOARD_HULLHIDER = HullHider§8: §aOn +SCOREBOARD_VIEW = View§8: §a{0} SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam SCOREBOARD_LOCK_SUPERVISOR = Bau Lock§8: §eSupervisor SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server) Team diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index e08803a9..3fb95eb8 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -35,9 +35,7 @@ SCOREBOARD_LOADER = Loader SCOREBOARD_TPS = TPS SCOREBOARD_TPS_FROZEN = §eEingefroren SCOREBOARD_TRACE_TICKS = Ticks -SCOREBOARD_TECHHIDER = TechHider§8: §aAn -SCOREBOARD_XRAY = XRay§8: §aAn -SCOREBOARD_HULLHIDER = HullHider§8: §aAn +SCOREBOARD_VIEW = Ansicht§8: §a{0} SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server-) Team SCOREBOARD_LOCK_SERVERTEAM = Bau Lock§8: §eServerteam diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/hullhider/HullHiderCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/hullhider/HullHiderCommand.java index b8ad87de..76f333d1 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/hullhider/HullHiderCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/hullhider/HullHiderCommand.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.techhider.TechHiderCommand; import de.steamwar.bausystem.features.xray.XrayCommand; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.command.SWCommand; import de.steamwar.hullhider.Hull; import de.steamwar.hullhider.HullHider; @@ -53,7 +52,7 @@ import java.util.concurrent.ConcurrentHashMap; * Hides the inside of the build area hull of a region from the players who toggle it, as the hull hider of a fight would. */ @Linked -public class HullHiderCommand extends SWCommand implements Listener, ScoreboardElement { +public class HullHiderCommand extends SWCommand implements Listener { public HullHiderCommand() { super("hullhider"); @@ -161,19 +160,7 @@ public class HullHiderCommand extends SWCommand implements Listener, ScoreboardE } } - @Override - public ScoreboardGroup getGroup() { - return ScoreboardGroup.OTHER; - } - - @Override - public int order() { - return 0; - } - - @Override - public String get(Region region, Player p) { - if (!hidden.getOrDefault(region, Collections.emptySet()).contains(p)) return null; - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_HULLHIDER", p); + public boolean isActive(Region region, Player player) { + return hidden.getOrDefault(region, Collections.emptySet()).contains(player); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 89956fe2..0548e99a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.hullhider.HullHiderCommand; import de.steamwar.bausystem.features.world.SpectatorListener; import de.steamwar.bausystem.features.xray.XrayCommand; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -46,7 +45,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @Linked -public class TechHiderCommand extends SWCommand implements Listener, ScoreboardElement { +public class TechHiderCommand extends SWCommand implements Listener { public TechHiderCommand() { super("techhider", "hider", "obfuscate", "hide", "hide-tech"); @@ -143,19 +142,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE }); } - @Override - public ScoreboardGroup getGroup() { - return ScoreboardGroup.OTHER; - } - - @Override - public int order() { - return 0; - } - - @Override - public String get(Region region, Player p) { - if (!hidden.getOrDefault(region, Collections.emptySet()).contains(p)) return null; - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TECHHIDER", p); + public boolean isActive(Region region, Player player) { + return hidden.getOrDefault(region, Collections.emptySet()).contains(player); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/ViewScoreboardElement.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/ViewScoreboardElement.java new file mode 100644 index 00000000..6b9dab13 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/ViewScoreboardElement.java @@ -0,0 +1,70 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2026 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.techhider; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.hullhider.HullHiderCommand; +import de.steamwar.bausystem.features.xray.XrayCommand; +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; + +/** + * Shows which of /techhider, /xray and /hullhider is active, at most one of them can be per region. + */ +@Linked +public class ViewScoreboardElement implements ScoreboardElement { + + @LinkedInstance + public TechHiderCommand techHiderCommand; + + @LinkedInstance + public XrayCommand xrayCommand; + + @LinkedInstance + public HullHiderCommand hullHiderCommand; + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.OTHER; + } + + @Override + public int order() { + return 0; + } + + @Override + public String get(Region region, Player p) { + String view; + if (techHiderCommand.isActive(region, p)) { + view = "TechHider"; + } else if (xrayCommand.isActive(region, p)) { + view = "XRay"; + } else if (hullHiderCommand.isActive(region, p)) { + view = "HullHider"; + } else { + return null; + } + return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_VIEW", p, view); + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index 9e0742d0..c8f01679 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.hullhider.HullHiderCommand; import de.steamwar.bausystem.features.techhider.HidingRule; import de.steamwar.bausystem.features.techhider.TechHiderCommand; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.command.SWCommand; import de.steamwar.core.CraftbukkitWrapper; import de.steamwar.linkage.Linked; @@ -49,7 +48,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiFunction; @Linked -public class XrayCommand extends SWCommand implements Listener, ScoreboardElement { +public class XrayCommand extends SWCommand implements Listener { public XrayCommand() { super("xray"); @@ -167,19 +166,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen }); } - @Override - public ScoreboardGroup getGroup() { - return ScoreboardGroup.OTHER; - } - - @Override - public int order() { - return 0; - } - - @Override - public String get(Region region, Player p) { - if (!hidden.getOrDefault(region, Collections.emptySet()).contains(p)) return null; - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_XRAY", p); + public boolean isActive(Region region, Player player) { + return hidden.getOrDefault(region, Collections.emptySet()).contains(player); } }