소스 검색

Fix NPE with Scoreboards when updating

nossr50 4 년 전
부모
커밋
fc3e580550
2개의 변경된 파일9개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 0
      Changelog.txt
  2. 8 6
      src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java

+ 1 - 0
Changelog.txt

@@ -1,4 +1,5 @@
 Version 2.1.182
+    Fixed a NPE with Scoreboards enabled when trying to update scoreboards
     Players now receive XP from harvesting Sweet Berry bushes (double XP for harvesting fully grown berries)
     Sweet Berry Bush will no longer ready tools for Super Abilities
     You can now use '.all' (for example: mcmmo.perks.xp.customboost.all) to give an XP perk to all skills

+ 8 - 6
src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java

@@ -428,14 +428,16 @@ public class ScoreboardWrapper {
      * Load new values into the sidebar.
      */
     private void updateSidebar() {
-        try {
-            updateTask.cancel();
-        }
-        catch (Exception e) {
-            e.printStackTrace();
+        if(updateTask != null) {
+            try {
+                updateTask.cancel();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            updateTask = null;
         }
 
-        updateTask = null;
 
         if (sidebarType == SidebarType.NONE) {
             return;