Solved Received string length longer than maximum allowed - Scoreboard Plugin

Discussion in 'Plugin Development' started by MrConHD, Oct 10, 2014.

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

    MrConHD

    So I am creating a scoreboard that contains a small amount of info about the server and player. Yesterday, the scoreboard was working fine then came on today and received this error: "The received string length is longer than maximum allowed (19>16)

    I researched the problem and found out it has to do with Tab lists and scoreboards and the lengths of characters. After looking into it, I am still unable to resolve the issue. Here is the code:

    Code:
    package me.MrConHD.Scoreboard;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Server;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    import org.bukkit.ChatColor;
     
     
     
    public class Core extends JavaPlugin implements Listener {
     
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
            getLogger().info(ChatColor.GREEN + "FactionScoreboard V2 Enabled!");
        }
     
        public void onDisable() {
            getLogger().info(ChatColor.RED + "FactionScoreboard V1 Disabled.");
        }
     
        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
     
            Player player = event.getPlayer();
            Server server = player.getServer();
     
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard facBoard = manager.getNewScoreboard();
            Objective fBoard = facBoard.registerNewObjective("FacInfo", "dummy");
            fBoard.setDisplayName(ChatColor.GRAY + "- " + ChatColor.RED + "Faction Info" + ChatColor.GRAY + " -");
            fBoard.setDisplaySlot(DisplaySlot.SIDEBAR);
     
            Score faction;
            Score facServer;
            Score balance;
            Score power;
            Score space1;
            Score space2;
            Score space3;
            Score space4;
            Score space5;
     
            space1 = fBoard.getScore(ChatColor.AQUA + "");
            space1.setScore(1);
     
            space2 = fBoard.getScore(ChatColor.LIGHT_PURPLE + "");
            space2.setScore(3);
     
            space3 = fBoard.getScore(ChatColor.BLACK + "");
            space3.setScore(5);
     
            space4 = fBoard.getScore(ChatColor.DARK_PURPLE + "");
            space4.setScore(7);
     
            space5 = fBoard.getScore(ChatColor.GREEN + "");
            space5.setScore(9);
     
            faction = fBoard.getScore(ChatColor.GRAY + "Faction: " + ChatColor.AQUA + "Test");
            faction.setScore(2);
     
            facServer = fBoard.getScore(ChatColor.GRAY + "Server: ");
            facServer.setScore(8);
     
            balance = fBoard.getScore(ChatColor.GRAY + "Balance: ");
            balance.setScore(4);
     
            power = fBoard.getScore(ChatColor.GRAY + "Power: ");
            power.setScore(6);
     
            player.setScoreboard(facBoard);
        }
     
        @EventHandler public void onPlayerQuit(PlayerQuitEvent e) {
            ScoreboardManager manager2 = Bukkit.getScoreboardManager();
            Player player = e.getPlayer();
            player.setScoreboard(manager2.getNewScoreboard());
        }
    }
     
     
    
     
  2. Offline

    SmooshCakez

    MrConHD The maximum allowed is 16 because that's the max amount of characters allowed in a username, and scoreboards were meant to have usernames on them for scores. Pretty sure the only way to bypass that is packets.
     
  3. Offline

    MrConHD

    What needs changed then? Not too experienced so not sure what I would have to do. I don't recall changing anything at all, I just came on this morning and went to test it on the actual Factions Server and it gives me that error on join.
     
  4. Offline

    SmooshCakez

    Where you set
    Code:java
    1. faction = fBoard.getScore(ChatColor.GRAY + "Faction: " + ChatColor.AQUA + "Test");

    are you using the actual faction name on that server? If so, the faction name and the colors/prefix combined probably exceed the 16 character limit.
     
  5. Offline

    MrConHD

    Yea, I was using the faction name that was used in /f create and /f show. Thank you!

    Someone set to solved?
     
  6. Offline

    fireblast709

    MrConHD you should be able to set it solved yourself
     
Thread Status:
Not open for further replies.

Share This Page