Development Assistance IllegalStateException ;-;

Discussion in 'Plugin Help/Development/Requests' started by dlange, May 19, 2015.

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

    dlange

    I get a IllegalStateException when i do this:
    Code:
        public static void boardAdd(final Player p) {
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
            final Objective objective = board.registerNewObjective("null", "dummy");
    
            Team defaultT = board.registerNewTeam("default");
            Team donorT = board.registerNewTeam("donor");
            Team modT = board.registerNewTeam("moderator");
            Team srModT = board.registerNewTeam("srmoderator");
            Team adminT = board.registerNewTeam("admin");
            Team ownerT = board.registerNewTeam("owner");
            Team devT = board.registerNewTeam("developer");
    
            FileConfiguration config = Core.getPlugin().getConfig();
            board.resetScores(p.getName());
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            objective.setDisplayName(ChatColor.DARK_RED + "  -- " + ChatColor.RED + "" + ChatColor.BOLD + "null" + ChatColor.DARK_RED + " --");
    
            Score score = objective.getScore(ChatColor.WHITE + "Coins: " + ChatColor.YELLOW + "" + config.getInt("Players." + p.getUniqueId() + ".Coins"));
            score.setScore(5);
    
            Score spacer = objective.getScore(ChatColor.RED + "   ");
            Score spacer5 = objective.getScore(ChatColor.RED + " ");
            Score spacer2 = objective.getScore(ChatColor.RED + "     ");
            Score spacer3 = objective.getScore(ChatColor.RED + "          ");
            Score spacer4 = objective.getScore(ChatColor.RED + "----------------------");
            spacer.setScore(8);
            spacer5.setScore(2);
            spacer4.setScore(0);
            spacer2.setScore(6);
            spacer3.setScore(10);
    
            Score score4 = objective.getScore(ChatColor.WHITE + "Kills: " + ChatColor.YELLOW + "" + Core.getPlugin().getConfig().getInt("Players." + p.getUniqueId() + ".Kills"));
            score4.setScore(5);
    
            Score score6 = objective.getScore(ChatColor.WHITE + "Deaths: " + ChatColor.YELLOW + "" + Core.getPlugin().getConfig().getInt("Players." + p.getUniqueId() + ".Deaths"));
            score6.setScore(4);
    
            Manager.onlinePlayers.clear();
    
            for (Player target : Core.getPlugin().getServer().getOnlinePlayers()) {
                if (p.canSee(target)) {
                    Manager.onlinePlayers.add(target.getName());
                }
            }
    
            Score players = objective.getScore(ChatColor.WHITE + "Online: " + ChatColor.YELLOW + "" + Manager.onlinePlayers.size());
            players.setScore(7);
    
            Score url = objective.getScore(ChatColor.WHITE + "www.null.com");
            url.setScore(1);
    
            if (Core.killstreak.containsKey(p.getName())) {
                Score score12 = objective.getScore(ChatColor.WHITE + "Killstreak: " + ChatColor.YELLOW + "" + Core.killstreak.get(p.getName()));
                score12.setScore(3);
            }
            if (!Core.killstreak.containsKey(p.getName())) {
                Score score12 = objective.getScore(ChatColor.WHITE + "Killstreak: " + ChatColor.YELLOW + "0");
                score12.setScore(3);
            }
    
            if (p.hasPermission("staff.owner")) {
                ownerT.addPlayer(p);
                Score score9 = objective.getScore(ChatColor.WHITE + "Rank: " + ChatColor.DARK_RED + "" + ChatColor.BOLD + "Owner");
                score9.setScore(9);
                p.setScoreboard(board);
            }
        }
     
    Last edited: May 19, 2015
  2. Offline

    dontjudgeme1243

    You may want to post your full code and the stack trace. This usually helps figure out where the problem is located.
     
  3. Offline

    dlange

    Stacktrace:
    Code:
    [20:08:25] [Server thread/WARN]: [OrchestraV2] Task #17 for Plugin v1.0 generated an exception
    java.lang.IllegalStateException: Cannot set scoreboard for invalid CraftPlayer
        at org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer.setScoreboard(CraftPlayer.java:1245) ~[custom.jar:git-Bukkit-33d5de3]
        at dev.dlange.plugin.managers.Manager.boardAdd(Manager.java:151) ~[?:?]
        at dev.dlange.plugin.Core$2.run(Core.java:153) ~[?:?]
        at org.bukkit.craftbukkit.v1_8_R1.scheduler.CraftTask.run(CraftTask.java:53) ~[custom.jar:git-Bukkit-33d5de3]
        at org.bukkit.craftbukkit.v1_8_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:349) [custom.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:668) [custom.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:284) [custom.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:609) [custom.jar:git-Bukkit-33d5de3]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:517) [custom.jar:git-Bukkit-33d5de3]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_75]
    Sorry it was an Illegal State Exception, not the other one xD
     
  4. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
Thread Status:
Not open for further replies.

Share This Page