SteamWar/FightSystem
Archiviert
13
1

Correct HullHider behaviour for boarding
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-12-19 22:18:16 +01:00
Ursprung 9b78103592
Commit 65028799b0
4 geänderte Dateien mit 22 neuen und 27 gelöschten Zeilen

Datei anzeigen

@ -56,7 +56,10 @@ public class EnternCountdown extends Countdown {
@Override @Override
public void countdownFinished() { public void countdownFinished() {
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR); 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 @Override

Datei anzeigen

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

Datei anzeigen

@ -89,8 +89,8 @@ public class Hull {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void addPlayer(Player player, boolean activeHiding) { public void addPlayer(Player player) {
if(players.add(player) && activeHiding) { if(players.add(player)) {
for(Entity entity : entities) for(Entity entity : entities)
player.hideEntity(FightSystem.getPlugin(), entity); //TODO 1.15- 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.core.Core;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
@ -62,7 +63,7 @@ public class HullHider implements Listener {
new StateDependent(ENABLED, FightState.Schem) { new StateDependent(ENABLED, FightState.Schem) {
@Override @Override
public void enable() { public void enable() {
Bukkit.getOnlinePlayers().forEach(player -> addPlayer(player, true)); Bukkit.getOnlinePlayers().forEach(player -> updatePlayer(player));
} }
@Override @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) @EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
addPlayer(e.getPlayer(), false); updatePlayer(e.getPlayer());
} }
@EventHandler @EventHandler
@ -105,13 +92,18 @@ public class HullHider implements Listener {
removePlayer(e.getPlayer(), false); removePlayer(e.getPlayer(), false);
} }
private void addPlayer(Player player, boolean activeHiding) { public void updatePlayer(Player player) {
FightTeam team = Fight.getPlayerTeam(player); if(!ENABLED)
for(Map.Entry<FightTeam, Hull> hull : hulls.entrySet()) { return;
if(hull.getKey() == team)
continue;
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);
}
} }
} }