diff --git a/src/main/java/io/github/seriousguy888/cheezsurvtaggame/Game.java b/src/main/java/io/github/seriousguy888/cheezsurvtaggame/Game.java index 64ab165..b0b1403 100644 --- a/src/main/java/io/github/seriousguy888/cheezsurvtaggame/Game.java +++ b/src/main/java/io/github/seriousguy888/cheezsurvtaggame/Game.java @@ -70,7 +70,12 @@ private void loadState() { } public void saveState() { - gameDataStorage.set("it", getIt().getUniqueId().toString()); + OfflinePlayer it = getIt(); + if(it == null) { + Bukkit.getLogger().warning("Current It was not saved as no player is It."); + return; + } + gameDataStorage.set("it", it.getUniqueId().toString()); try { gameDataStorage.save(file); diff --git a/src/main/java/io/github/seriousguy888/cheezsurvtaggame/TagEvents.java b/src/main/java/io/github/seriousguy888/cheezsurvtaggame/TagEvents.java index 6b7b9b9..0bea8d0 100644 --- a/src/main/java/io/github/seriousguy888/cheezsurvtaggame/TagEvents.java +++ b/src/main/java/io/github/seriousguy888/cheezsurvtaggame/TagEvents.java @@ -65,7 +65,8 @@ public void onJoin(PlayerJoinEvent event) { plugin.game.loadTagStats(player); OfflinePlayer it = plugin.game.getIt(); - player.sendMessage(ChatColor.GRAY + it.getName() + " is currently It."); + if(it != null) + player.sendMessage(ChatColor.GRAY + it.getName() + " is currently It."); } @EventHandler diff --git a/src/main/java/io/github/seriousguy888/cheezsurvtaggame/runnables/ChooseRandomIt.java b/src/main/java/io/github/seriousguy888/cheezsurvtaggame/runnables/ChooseRandomIt.java index d561a32..86d848d 100644 --- a/src/main/java/io/github/seriousguy888/cheezsurvtaggame/runnables/ChooseRandomIt.java +++ b/src/main/java/io/github/seriousguy888/cheezsurvtaggame/runnables/ChooseRandomIt.java @@ -16,7 +16,7 @@ public ChooseRandomIt(CheezSurvTagGame plugin) { @Override public void run() { OfflinePlayer currentIt = plugin.game.getIt(); - if(currentIt.isOnline()) + if(currentIt != null && currentIt.isOnline()) return; Player newIt = plugin.game.pickRandomIt();