mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-12-27 19:37:42 +01:00
Fix possible NPE and the forge-server instance never being initialized
This commit is contained in:
parent
0559df9730
commit
cd24f57031
@ -100,6 +100,7 @@ public HttpResponse handlePlayersRequest(HttpRequest request) {
|
||||
json.beginObject();
|
||||
json.name("players").beginArray();
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (!player.isOnline()) continue;
|
||||
|
||||
if (config.isHideInvisible() && player.isInvisible()) continue;
|
||||
if (config.isHideSneaking() && player.isSneaking()) continue;
|
||||
@ -116,6 +117,7 @@ public HttpResponse handlePlayersRequest(HttpRequest request) {
|
||||
json.endObject();
|
||||
json.endObject();
|
||||
}
|
||||
|
||||
json.endArray();
|
||||
json.endObject();
|
||||
|
||||
|
@ -129,6 +129,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameMode());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
StatusEffectInstance invis = player.getStatusEffect(StatusEffects.INVISIBILITY);
|
||||
this.invisible = invis != null && invis.getDuration() > 0;
|
||||
|
@ -129,6 +129,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameMode());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
StatusEffectInstance invis = player.getStatusEffect(StatusEffects.INVISIBILITY);
|
||||
this.invisible = invis != null && invis.getDuration() > 0;
|
||||
|
@ -129,6 +129,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameMode());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
StatusEffectInstance invis = player.getStatusEffect(StatusEffects.INVISIBILITY);
|
||||
this.invisible = invis != null && invis.getDuration() > 0;
|
||||
|
@ -129,6 +129,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameType());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
EffectInstance invis = player.getActivePotionEffect(Effects.INVISIBILITY);
|
||||
this.invisible = invis != null && invis.getDuration() > 0;
|
||||
|
@ -129,6 +129,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameType());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
EffectInstance invis = player.getActivePotionEffect(Effects.INVISIBILITY);
|
||||
this.invisible = invis != null && invis.getDuration() > 0;
|
||||
|
@ -98,12 +98,13 @@ public ForgeMod() {
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(FMLServerStartingEvent event) {
|
||||
this.worldUUIDs.clear();
|
||||
this.serverInstance = event.getServer();
|
||||
|
||||
//register commands
|
||||
new Commands<>(pluginInstance, event.getServer().getCommandManager().getDispatcher(), forgeSource -> new ForgeCommandSource(this, pluginInstance, forgeSource));
|
||||
|
||||
//save worlds to generate level.dat files
|
||||
event.getServer().save(false, true, true);
|
||||
serverInstance.save(false, true, true);
|
||||
|
||||
new Thread(() -> {
|
||||
Logger.global.logInfo("Loading...");
|
||||
|
@ -128,6 +128,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameType());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
EffectInstance invis = player.getActivePotionEffect(Effects.INVISIBILITY);
|
||||
this.invisible = invis != null && invis.getDuration() > 0;
|
||||
|
@ -114,6 +114,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.getGameMode());
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
this.invisible = player.hasPotionEffect(PotionEffectType.INVISIBILITY);
|
||||
|
||||
|
@ -119,6 +119,7 @@ public void update() {
|
||||
}
|
||||
|
||||
this.gamemode = GAMEMODE_MAP.get(player.get(Keys.GAME_MODE).orElse(GameModes.NOT_SET));
|
||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
||||
|
||||
boolean invis = player.get(Keys.VANISH).orElse(false);
|
||||
if (!invis && player.get(Keys.INVISIBLE).orElse(false)) invis = true;
|
||||
|
Loading…
Reference in New Issue
Block a user