浏览代码

Set player scoreboards to main server scoreboard upon entering a blacklisted world

nossr50 5 年之前
父节点
当前提交
bba35f8a4e
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 6 0
      Changelog.txt
  2. 7 1
      src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java

+ 6 - 0
Changelog.txt

@@ -1,3 +1,9 @@
+Version 2.1.105
+    mcMMO will reset players scoreboard to the main scoreboard if they move into a blacklisted world
+
+    NOTES:
+    The scoreboard change should result in mcMMO removing scoreboards from players properly when they enter a black listed world. This is a hacky band aid fix as our scoreboard code is archaic and needs to be rewritten in 2.2 and not 2.1. Expect a scoreboard overhaul sometime in the future.
+
 Version 2.1.104
     Fixed a bug resulting in many errors when using Rupture
     Large update to the Japanese locale (thanks ethernetcat)

+ 7 - 1
src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java

@@ -13,6 +13,7 @@ import com.gmail.nossr50.util.player.UserManager;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
+import org.bukkit.Bukkit;
 import org.bukkit.ChatColor;
 import org.bukkit.entity.Player;
 import org.bukkit.scoreboard.DisplaySlot;
@@ -173,8 +174,13 @@ public class ScoreboardManager {
         dirtyPowerLevels.add(player.getName());
     }
 
-    // Called by PlayerQuitEvent listener
+    // Called by PlayerQuitEvent listener and OnPlayerTeleport under certain circumstances
     public static void teardownPlayer(Player player) {
+        //Hacky world blacklist fix
+        if(player.isOnline() && player.isValid())
+            if(Bukkit.getServer().getScoreboardManager() != null)
+                player.setScoreboard(Bukkit.getServer().getScoreboardManager().getMainScoreboard());
+
         ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(player.getName());
 
         if (wrapper != null && wrapper.revertTask != null) {