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.
This commit is contained in:
2026-10-31 15:36:02 +01:00
parent f02f356b2b
commit a9fbb4cd8d
6 changed files with 81 additions and 54 deletions
@@ -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
@@ -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
@@ -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);
}
}
@@ -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);
}
}
@@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}
@@ -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);
}
}