SteamWar/FightSystem
Archiviert
13
1

Add spectate team to hide nametags #384

Zusammengeführt
Lixfel hat 1 Commits von spectate nach master 2023-03-04 11:31:01 +01:00 zusammengeführt
3 geänderte Dateien mit 19 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.GUI; import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.listener.FightScoreboard; import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.Permanent;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
@ -121,11 +122,7 @@ public class FightTeam {
new KitLoader(); new KitLoader();
new SpectateHandler(); new SpectateHandler();
if(FightScoreboard.getBukkit().getTeam(name) == null) team = FightScoreboard.getBukkitTeam(name);
team = FightScoreboard.getBukkit().registerNewTeam(name);
else
team = FightScoreboard.getBukkit().getTeam(name);
assert team != null;
WorldOfColorWrapper.impl.setTeamColor(team, color); WorldOfColorWrapper.impl.setTeamColor(team, color);
BountifulWrapper.impl.setNametagVisibility(team); BountifulWrapper.impl.setNametagVisibility(team);
team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS);
@ -252,6 +249,7 @@ public class FightTeam {
FightPlayer fightPlayer = new FightPlayer(player, this); FightPlayer fightPlayer = new FightPlayer(player, this);
players.put(player, fightPlayer); players.put(player, fightPlayer);
invited.remove(player); invited.remove(player);
Permanent.getSpectatorTeam().removeEntry(player.getName());
team.addEntry(player.getName()); team.addEntry(player.getName());
Fight.setPlayerGamemode(player, GameMode.SURVIVAL); Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
@ -277,6 +275,7 @@ public class FightTeam {
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true); List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
players.remove(player); players.remove(player);
team.removeEntry(player.getName()); team.removeEntry(player.getName());
Permanent.getSpectatorTeam().addEntry(player.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName()); FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName());

Datei anzeigen

@ -30,14 +30,20 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects; import java.util.Objects;
public class FightScoreboard implements Listener, ScoreboardCallback { public class FightScoreboard implements Listener, ScoreboardCallback {
public static Scoreboard getBukkit() { public static Team getBukkitTeam(String name) {
return Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard(); Scoreboard scoreboard = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
Team team = scoreboard.getTeam(name);
if(team != null)
return team;
return scoreboard.registerNewTeam(name);
} }
private static FightScoreboard scoreboard; private static FightScoreboard scoreboard;

Datei anzeigen

@ -46,9 +46,15 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.scoreboard.Team;
public class Permanent implements Listener { public class Permanent implements Listener {
private static final Team spectatorTeam = FightScoreboard.getBukkitTeam("Spectator");
public static Team getSpectatorTeam() {
return spectatorTeam;
}
public Permanent() { public Permanent() {
new StateDependentListener(ArenaMode.All, FightState.All, this); new StateDependentListener(ArenaMode.All, FightState.All, this);
} }
@ -81,6 +87,7 @@ public class Permanent implements Listener {
if (!Config.ArenaLeaveable && !Fight.fighting(player)) { if (!Config.ArenaLeaveable && !Fight.fighting(player)) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
spectatorTeam.addEntry(player.getName());
player.teleport(Config.SpecSpawn); player.teleport(Config.SpecSpawn);
} }
} }