From b5c1eb082363b36ed5c453f722d016573f2b063b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Mon, 10 Feb 2020 14:58:13 +0100 Subject: [PATCH] Fixing NPE on disconnect --- .../de/steamwar/scoreboard/SWScoreboard.java | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java b/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java index 9ccf6db..958b08d 100644 --- a/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java +++ b/SpigotCore_Main/src/de/steamwar/scoreboard/SWScoreboard.java @@ -45,25 +45,29 @@ public class SWScoreboard { if(!playerBoards.containsKey(player)) return; - switch (Core.getVersion()) { - case 8: - ((SWScoreboard_8) playerBoards.get(player)).deleteScoreboard(player); - break; - case 9: - ((SWScoreboard_9) playerBoards.get(player)).deleteScoreboard(player); - break; - case 10: - ((SWScoreboard_10) playerBoards.get(player)).deleteScoreboard(player); - break; - case 12: - ((SWScoreboard_12) playerBoards.get(player)).deleteScoreboard(player); - break; - case 14: - ((SWScoreboard_14) playerBoards.get(player)).deleteScoreboard(player); - break; - case 15: - ((SWScoreboard_15) playerBoards.get(player)).deleteScoreboard(player); - break; + try{ + switch (Core.getVersion()) { + case 8: + ((SWScoreboard_8) playerBoards.get(player)).deleteScoreboard(player); + break; + case 9: + ((SWScoreboard_9) playerBoards.get(player)).deleteScoreboard(player); + break; + case 10: + ((SWScoreboard_10) playerBoards.get(player)).deleteScoreboard(player); + break; + case 12: + ((SWScoreboard_12) playerBoards.get(player)).deleteScoreboard(player); + break; + case 14: + ((SWScoreboard_14) playerBoards.get(player)).deleteScoreboard(player); + break; + case 15: + ((SWScoreboard_15) playerBoards.get(player)).deleteScoreboard(player); + break; + } + }catch(NullPointerException e){ + //ignored } playerBoards.remove(player); }