Tablist Prefix Plugin

Discussion in 'Programming' started by Prixix, Apr 30, 2017.

  1. Hello, ive coded a Tablist Prefix Plugin and if I join this error comes. upload_2017-4-30_17-0-28.png

    My code:

    package de.prixix.main;

    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.Scoreboard;

    import de.prixix.prefix.prefix;
    import ru.tehkode.permissions.bukkit.PermissionsEx;

    public class Main extends JavaPlugin
    implements Listener
    {
    Scoreboard sb;

    public void onEnable(){
    Bukkit.getConsoleSender().sendMessage("§6§lSkyPrefix §8┃ §7Das Plugin wurde geladen!");


    Bukkit.getPluginManager().registerEvents(new prefix(), this);

    this.sb = Bukkit.getScoreboardManager().getNewScoreboard();

    this.sb.registerNewTeam("00000inhaber");
    this.sb.registerNewTeam("00001leitung");
    this.sb.registerNewTeam("00002admin");
    this.sb.registerNewTeam("00003dev");
    this.sb.registerNewTeam("00004t-dev");
    this.sb.registerNewTeam("00005mod");
    this.sb.registerNewTeam("00006sup");
    this.sb.registerNewTeam("00007t-sup");
    this.sb.registerNewTeam("00008builder");
    this.sb.registerNewTeam("00009t-builder");
    this.sb.registerNewTeam("00010yt");
    this.sb.registerNewTeam("00011king");
    this.sb.registerNewTeam("00012master");
    this.sb.registerNewTeam("00013ultra");
    this.sb.registerNewTeam("00014gold");
    this.sb.registerNewTeam("00015Spieler");

    this.sb.getTeam("00000inhaber").setPrefix("§4§lInhaber §7§l| §4§l");
    this.sb.getTeam("00001leitung").setPrefix("§c§lLeitung §7§l| §c§l");
    this.sb.getTeam("00002admin").setPrefix("§c§lAdmin §7§l| §c§l");
    this.sb.getTeam("00003dev").setPrefix("§bDev §7┃ §b");
    this.sb.getTeam("00004t-dev").setPrefix("§dTest-Dev §7| §d");
    this.sb.getTeam("00005mod").setPrefix("§6Mod §7| §6");
    this.sb.getTeam("00006sup").setPrefix("§2Supp §7| §2");
    this.sb.getTeam("00007t-sup").setPrefix("§2Test-Supp §7| §2");
    this.sb.getTeam("00008builder").setPrefix("§aBuilder §7| §a");
    this.sb.getTeam("00009t-builder").setPrefix("§aTest-Builder §7| §a");
    this.sb.getTeam("00010yt").setPrefix("§bYTber §7| §b");
    this.sb.getTeam("00011king").setPrefix("§dKing §7| §d");
    this.sb.getTeam("00012master").setPrefix("§dMaster §7| §d");
    this.sb.getTeam("00013ultra").setPrefix("§dUltra §7| §d");
    this.sb.getTeam("00014gold").setPrefix("§dGold §7| §d");
    this.sb.getTeam("00015Spieler").setPrefix("§7Spieler |");

    Bukkit.getPluginManager().registerEvents(this, this);
    }

    public void onDisable()
    {
    Bukkit.getConsoleSender().sendMessage("§6§lTABLIST §8┃ §7Das Plugin wurde Deaktiviert!");
    }

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
    setPrefix(e.getPlayer());


    }

    @SuppressWarnings("deprecation")
    public void setPrefix(Player p)
    {

    String team = "";

    if(PermissionsEx.getUser(p).inGroup("Serverinhaber"))
    team = "00000inhaber";
    else if(PermissionsEx.getUser(p).inGroup("Serverleitung"))
    team = "00001leitung";
    else if(PermissionsEx.getUser(p).inGroup("Administrator"))
    team = "00002admin";
    else if(PermissionsEx.getUser(p).inGroup("Developer"))
    team = "00003dev";
    else if(PermissionsEx.getUser(p).inGroup("Test-Developer"))
    team = "00004t-dev";
    else if(PermissionsEx.getUser(p).inGroup("Moderator"))
    team = "00005mod";
    else if(PermissionsEx.getUser(p).inGroup("Supporter"))
    team = "00006sup";
    else if(PermissionsEx.getUser(p).inGroup("Test-Supporter"))
    team = "00007t-sup";
    else if(PermissionsEx.getUser(p).inGroup("Builder"))
    team = "00008builder";
    else if(PermissionsEx.getUser(p).inGroup("Test-Builder"))
    team = "00009t-builder";
    else if(PermissionsEx.getUser(p).inGroup("YouTuber"))
    team = "00010yt";
    else if(PermissionsEx.getUser(p).inGroup("King"))
    team = "00011king";
    else if(PermissionsEx.getUser(p).inGroup("Master"))
    team = "00012master";
    else if(PermissionsEx.getUser(p).inGroup("Ultra"))
    team = "00013ultra";
    else if(PermissionsEx.getUser(p).inGroup("VIP"))
    team = "00014gold";
    else {
    team = "00015Spieler";
    }

    this.sb.getTeam(team).addPlayer(p);
    p.setDisplayName(this.sb.getTeam(team).getPrefix() + p.getName());

    for (Player all : Bukkit.getOnlinePlayers())
    all.setScoreboard(this.sb);
    }
    }
     
  2. Why don't you read the JavaDoc?
    org.bukkit.scoreboard.Team#setPrefix:
    You can only use 16 characters as prefix. Color codes included! E.g. §4§lBla = 7 Characters.
     
  3. this.sb.registerNewTeam("00000inhaber"); ist zu lang | mach this.sb.registerNewTeam("00inhaber");