forked from SteamWar/SteamWar
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:
@@ -35,9 +35,7 @@ SCOREBOARD_LOADER = Loader
|
|||||||
SCOREBOARD_TPS = TPS
|
SCOREBOARD_TPS = TPS
|
||||||
SCOREBOARD_TPS_FROZEN = §eFrozen
|
SCOREBOARD_TPS_FROZEN = §eFrozen
|
||||||
SCOREBOARD_TRACE_TICKS = Ticks
|
SCOREBOARD_TRACE_TICKS = Ticks
|
||||||
SCOREBOARD_TECHHIDER = TechHider§8: §aOn
|
SCOREBOARD_VIEW = View§8: §a{0}
|
||||||
SCOREBOARD_XRAY = XRay§8: §aOn
|
|
||||||
SCOREBOARD_HULLHIDER = HullHider§8: §aOn
|
|
||||||
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
||||||
SCOREBOARD_LOCK_SUPERVISOR = Bau Lock§8: §eSupervisor
|
SCOREBOARD_LOCK_SUPERVISOR = Bau Lock§8: §eSupervisor
|
||||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server) Team
|
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server) Team
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ SCOREBOARD_LOADER = Loader
|
|||||||
SCOREBOARD_TPS = TPS
|
SCOREBOARD_TPS = TPS
|
||||||
SCOREBOARD_TPS_FROZEN = §eEingefroren
|
SCOREBOARD_TPS_FROZEN = §eEingefroren
|
||||||
SCOREBOARD_TRACE_TICKS = Ticks
|
SCOREBOARD_TRACE_TICKS = Ticks
|
||||||
SCOREBOARD_TECHHIDER = TechHider§8: §aAn
|
SCOREBOARD_VIEW = Ansicht§8: §a{0}
|
||||||
SCOREBOARD_XRAY = XRay§8: §aAn
|
|
||||||
SCOREBOARD_HULLHIDER = HullHider§8: §aAn
|
|
||||||
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
SCOREBOARD_LOCK_TEAM = Bau Lock§8: §eTeam
|
||||||
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server-) Team
|
SCOREBOARD_LOCK_TEAM_AND_SERVERTEAM = Bau Lock§8: §e(Server-) Team
|
||||||
SCOREBOARD_LOCK_SERVERTEAM = Bau Lock§8: §eServerteam
|
SCOREBOARD_LOCK_SERVERTEAM = Bau Lock§8: §eServerteam
|
||||||
|
|||||||
+3
-16
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
|||||||
import de.steamwar.bausystem.features.xray.XrayCommand;
|
import de.steamwar.bausystem.features.xray.XrayCommand;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.hullhider.Hull;
|
import de.steamwar.hullhider.Hull;
|
||||||
import de.steamwar.hullhider.HullHider;
|
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.
|
* 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
|
@Linked
|
||||||
public class HullHiderCommand extends SWCommand implements Listener, ScoreboardElement {
|
public class HullHiderCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
public HullHiderCommand() {
|
public HullHiderCommand() {
|
||||||
super("hullhider");
|
super("hullhider");
|
||||||
@@ -161,19 +160,7 @@ public class HullHiderCommand extends SWCommand implements Listener, ScoreboardE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isActive(Region region, Player player) {
|
||||||
public ScoreboardGroup getGroup() {
|
return hidden.getOrDefault(region, Collections.emptySet()).contains(player);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-16
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.features.hullhider.HullHiderCommand;
|
|||||||
import de.steamwar.bausystem.features.world.SpectatorListener;
|
import de.steamwar.bausystem.features.world.SpectatorListener;
|
||||||
import de.steamwar.bausystem.features.xray.XrayCommand;
|
import de.steamwar.bausystem.features.xray.XrayCommand;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
@@ -46,7 +45,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TechHiderCommand extends SWCommand implements Listener, ScoreboardElement {
|
public class TechHiderCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
public TechHiderCommand() {
|
public TechHiderCommand() {
|
||||||
super("techhider", "hider", "obfuscate", "hide", "hide-tech");
|
super("techhider", "hider", "obfuscate", "hide", "hide-tech");
|
||||||
@@ -143,19 +142,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isActive(Region region, Player player) {
|
||||||
public ScoreboardGroup getGroup() {
|
return hidden.getOrDefault(region, Collections.emptySet()).contains(player);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+70
@@ -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.HidingRule;
|
||||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.core.CraftbukkitWrapper;
|
import de.steamwar.core.CraftbukkitWrapper;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
@@ -49,7 +48,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class XrayCommand extends SWCommand implements Listener, ScoreboardElement {
|
public class XrayCommand extends SWCommand implements Listener {
|
||||||
|
|
||||||
public XrayCommand() {
|
public XrayCommand() {
|
||||||
super("xray");
|
super("xray");
|
||||||
@@ -167,19 +166,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean isActive(Region region, Player player) {
|
||||||
public ScoreboardGroup getGroup() {
|
return hidden.getOrDefault(region, Collections.emptySet()).contains(player);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user