SteamWar/FightSystem
Archiviert
13
1

HullHider v2 #408

Zusammengeführt
Lixfel hat 9 Commits von hullhiderv2 nach master 2024-01-03 16:26:05 +01:00 zusammengeführt
4 geänderte Dateien mit 22 neuen und 27 gelöschten Zeilen
Nur Änderungen aus Commit 65028799b0 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -56,7 +56,10 @@ public class EnternCountdown extends Countdown {
@Override
public void countdownFinished() {
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, chunkPos, false));
fightPlayer.ifPlayer(player -> {
FightSystem.getHullHider().updatePlayer(player);
FightSystem.getTechHider().reloadChunks(player, chunkPos, false);
});
}
@Override

Datei anzeigen

@ -275,7 +275,7 @@ public class FightTeam {
BountifulWrapper.impl.setAttackSpeed(player);
player.setFoodLevel(20);
player.getInventory().clear();
FightSystem.getHullHider().removePlayer(this, player);
FightSystem.getHullHider().updatePlayer(player);
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
@ -319,7 +319,7 @@ public class FightTeam {
player.getInventory().clear();
if(player.isOnline()){
FightSystem.getHullHider().addPlayer(this, player);
FightSystem.getHullHider().updatePlayer(player);
FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
if(ArenaMode.VariableTeams.contains(Config.mode))

Datei anzeigen

@ -89,8 +89,8 @@ public class Hull {
}
@SuppressWarnings("deprecation")
public void addPlayer(Player player, boolean activeHiding) {
if(players.add(player) && activeHiding) {
public void addPlayer(Player player) {
if(players.add(player)) {
for(Entity entity : entities)
player.hideEntity(FightSystem.getPlugin(), entity); //TODO 1.15-
}

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.fightsystem.utils;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.states.FightState;
@ -62,7 +63,7 @@ public class HullHider implements Listener {
new StateDependent(ENABLED, FightState.Schem) {
@Override
public void enable() {
Bukkit.getOnlinePlayers().forEach(player -> addPlayer(player, true));
Bukkit.getOnlinePlayers().forEach(player -> updatePlayer(player));
}
@Override
@ -81,23 +82,9 @@ public class HullHider implements Listener {
}
public void addPlayer(FightTeam team, Player player) {
if(!ENABLED)
return;
hulls.get(team).addPlayer(player, true);
}
public void removePlayer(FightTeam team, Player player) {
if(!ENABLED)
return;
hulls.get(team).removePlayer(player, true);
}
@EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) {
addPlayer(e.getPlayer(), false);
updatePlayer(e.getPlayer());
}
@EventHandler
@ -105,13 +92,18 @@ public class HullHider implements Listener {
removePlayer(e.getPlayer(), false);
}
private void addPlayer(Player player, boolean activeHiding) {
FightTeam team = Fight.getPlayerTeam(player);
for(Map.Entry<FightTeam, Hull> hull : hulls.entrySet()) {
if(hull.getKey() == team)
continue;
public void updatePlayer(Player player) {
if(!ENABLED)
return;
hull.getValue().addPlayer(player, activeHiding);
FightTeam team = Fight.getPlayerTeam(player);
FightPlayer fp = Fight.getFightPlayer(player);
for(Map.Entry<FightTeam, Hull> hull : hulls.entrySet()) {
if(hull.getKey() == team || (fp != null && fp.canEntern())) {
hull.getValue().removePlayer(player, true);
} else {
hull.getValue().addPlayer(player);
}
}
}