diff --git a/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java b/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java index b6a0773..4363f6c 100644 --- a/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java +++ b/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java @@ -13,12 +13,13 @@ public class DefaultServerList { public final Gson gson = new Gson(); public ServerListModel loadModel(final File file) { - try (JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8))) { - return this.gson.fromJson(reader, ServerListModel.class); - } catch (final Exception e) { - Log.log.warn("Could not load "+file.getName(), e); - return null; - } + if (file.exists()) + try (JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8))) { + return this.gson.fromJson(reader, ServerListModel.class); + } catch (final Exception e) { + Log.log.warn("Could not load "+file.getName(), e); + } + return null; } public static class ServerListModel { diff --git a/src/main/java/net/teamfruit/serverobserver/GuiHandler.java b/src/main/java/net/teamfruit/serverobserver/GuiHandler.java index 1e070a7..64148e1 100644 --- a/src/main/java/net/teamfruit/serverobserver/GuiHandler.java +++ b/src/main/java/net/teamfruit/serverobserver/GuiHandler.java @@ -204,6 +204,8 @@ public void action(final ActionPerformedEvent.Post e) { public class TargetServer { private ServerData target; + private GuiMultiplayer mpgui_cache; + private String targetIP_cache; public void set(final ServerData serverData) { if (serverData==null) { @@ -219,8 +221,11 @@ public void set(final ServerData serverData) { final String targetServerIP = getServerIP(); if (targetServerIP==null) return null; - if (this.target==null||!StringUtils.equals(this.target.serverIP, targetServerIP)) + if (mpgui!=this.mpgui_cache||!StringUtils.equals(this.targetIP_cache, targetServerIP)) { this.target = getServerData(mpgui, getServerName(), targetServerIP, true); + this.targetIP_cache = targetServerIP; + this.mpgui_cache = mpgui; + } return this.target; }