Help with scoreboards disappearing

Discussion in 'Plugin Development' started by UNC00KED, Dec 20, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Having this problem with scoreboards in my plugin. I am making sort of a TNT Runner (called OreRunner) plugin except you also get points for ores you step on. I have hashmaps setup for scoreboards and objectives and they are initialized when the plugin is enabled.

    for (World world : Bukkit.getServer().getWorlds()) {
                Scoreboard sb = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
                Objective obj = sb.registerNewObjective(world.getName() + "-t", world.getName() + "-d");
                obj.setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "  Ore" + ChatColor.GRAY + "Runner");
                scoreboards.put(world.getName(), sb);
                objectives.put(world.getName(), obj);
    Whenever a player joins an "OreRunner" game world, a function is ran, scoreboardAdd:
    void scoreboardAdd(String world, Player player) {
            Scoreboard sb = scoreboards.get(world);
    And they are added to the scoreboard (display spot being the sidebar) with:
    int score = OreRunner.plugin.playerScore.get(player.getName());
    final Score objScore = OreRunner.plugin.objectives.get(toWorld).getScore(player.getName());
    The problem I am having is when the player leaves the "OreRunner" game world. When that happens, for whatever reason, even the player's scoreboard who is still in the "OreRunner" game world, disappears. It doesn't matter if I throw the following code in there:
    Scoreboard sb = OreRunner.plugin.scoreboards.get(fromWorld);
    OreRunner.plugin.scoreboards.put(fromWorld, sb);
    it doesn't change anything.

    By the way, I use the PlayerChangedWorldEvent, so:
    String fromWorld = event.getFrom().getName();
    String toWorld = player.getWorld().getName();

    It may be a lot to take in, but if you have any questions, don't hesitate to ask! I would appreciate any help at all, thanks!

    Any ideas? @teej107 @Xerox262 @megamichiel @Scimiguy @oceantheskatr @mythbusterma @Scorpionvssub @Binner_Done

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.

    This is what the scoreboard looks like (with one person in the "OreRunner" game world):
    Last edited: Dec 21, 2015
  2. Offline


    Hmm... I don't really know the proper way to do per-world scoreboards. Is anybody well versed in the scoreboard API that could help? @timtower @bwfcwalshy @mine-care
  3. Offline


    Looks like I've stumped you guys ;) Let me ask you this though. Do scoreboards, for some reason, automatically disappear (reset) when a player changes world, like on default? Is there any work-around to this possibly?
Thread Status:
Not open for further replies.

Share This Page