Gracefully handle null or offline players in game phases.
Added checks to ensure players are online and not null before interacting with them during the game phases. This prevents potential null pointer exceptions and improves overall code robustness. Also added a null check for the executorService in the CombatPhase end method.
This commit is contained in:
@@ -50,7 +50,10 @@ public class TeamPlayer {
|
||||
resetWorldBorder(player, worldBorderApi, gamePhase, worldBorderCenter));
|
||||
}
|
||||
|
||||
public void resetWorldBorder(Player player, WorldBorderApi worldBorderApi, GamePhase gamePhase, Location worldBorderCenter) {
|
||||
public void resetWorldBorder(@NotNull Player player, WorldBorderApi worldBorderApi, GamePhase gamePhase, Location worldBorderCenter) {
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
WorldBorderSettings worldBorderSettings = GameConfig.WORLD_BORDER.getGAME_PHASE_WORLD_BORDER().get(gamePhase);
|
||||
if (worldBorderSettings == null) {
|
||||
throw new IllegalStateException("All phases need to have world border settings");
|
||||
|
||||
Reference in New Issue
Block a user