ServerPlugin TabList

Dieses Thema im Forum "Programmierung" wurde erstellt von Lentry, 29. Mai 2016.

  1. Lentry
    Offline

    Lentry

    Registriert seit:
    15. Mai 2016
    Beiträge:
    39
    Hallo
    ich habe immer ein Fehler bei mir wann ich den Server starte

    Der Fehler
    Code (Text):
    1. [19:20:03 INFO]: [RangListener] Enabling RangListener v1.0
    2. [19:20:03 ERROR]: Error occurred while enabling RangListener v1.0 (Is it up to date?)
    3. java.lang.NullPointerException
    4.         at de.mtrx.RangListener.main.onEnable(main.java:23) ~[?:?]
    5.         at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    6.         at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    7.         at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    8.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    9.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    10.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    11.         at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    12.         at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    13.         at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    14.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    15.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    16.         at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    17.         at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    18.         at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    19.         at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-db6de12-18fbb24]
    20.         at java.lang.Thread.run(Unknown Source) [?:1.8.0_92]
    Die Main
    Code (Text):
    1. package de.mtrx.RangListener;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.player.PlayerJoinEvent;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8. import org.bukkit.scoreboard.Scoreboard;
    9.  
    10. import com.connorlinfoot.titleapi.TitleAPI;
    11.  
    12. public class main extends JavaPlugin implements Listener{
    13.  
    14.     public static String prefix  = "§7[§cCrynexcraft§7]§c";  
    15.    
    16.     public static Scoreboard sb;
    17.    
    18.     @Override
    19.     public void onEnable() {
    20.         Bukkit.getPluginManager().registerEvents(this, this);
    21.    
    22.    
    23.             sb.registerNewTeam("0000owner");
    24.             sb.registerNewTeam("0001admin");
    25.             sb.registerNewTeam("0002dev");
    26.             sb.registerNewTeam("0003builder");
    27.             sb.registerNewTeam("0004mod");
    28.             sb.registerNewTeam("0005supp");
    29.             sb.registerNewTeam("0006youtuber");
    30.             sb.registerNewTeam("0007vip");
    31.             sb.registerNewTeam("0008user");
    32.            
    33.             sb.getTeam("0000owner").setPrefix("§7[§4Owner§7]§4 ");
    34.             sb.getTeam("0001admin").setPrefix("§7[§cAdmin§7]§c ");
    35.             sb.getTeam("0002dev").setPrefix("§7[§bDev§7]§b ");
    36.             sb.getTeam("0003builder").setPrefix("§7[§eBuilder§7]§e ");
    37.             sb.getTeam("0004mod").setPrefix("§7[§3Mod§7]§3 ");
    38.             sb.getTeam("0005supp").setPrefix("§7[§2Supporter§7]§2 ");
    39.             sb.getTeam("0006youtuber").setPrefix("§7[§5YouTuber§7]§5 ");
    40.             sb.getTeam("0007vip").setPrefix("§7[§6VIP§7]§6 ");
    41.             sb.getTeam("0008user").setPrefix("§a");
    42.            
    43.          
    44.            
    45.             sb = Bukkit.getScoreboardManager().getNewScoreboard();
    46.  
    47.     }
    48.    
    49.  
    50.  
    51.        @SuppressWarnings("deprecation")
    52.     public void onjoin(PlayerJoinEvent e) {
    53.            setPrefix(e.getPlayer());
    54.          
    55.          
    56.          
    57.             e.setJoinMessage(prefix + "§a" + e.getPlayer().getName() + " §9Hat den Server Betreten");
    58.            
    59.        
    60.             Player p = e.getPlayer();
    61.  
    62.             TitleAPI.sendFullTitle(p, 25, 25, 25, "§aWillkommen auf", "§aCrynexcraft.de");  
    63.             TitleAPI.sendTabTitle(p, "§aCrynexcraft.de 1.8", "§cSkyPvP");
    64.            
    65.          
    66.        }
    67.  
    68.  
    69.  
    70.     private void setPrefix(Player p ) {
    71.              
    72.               String team = "";
    73.               if(p.hasPermission("nametag.owner")) {
    74.                   team = "0001admin";
    75.               } else if(p.hasPermission("nametag.admin")) {
    76.                   team = "0001admin";
    77.               } else if(p.hasPermission("nametag.dev")) {
    78.                   team = "0002dev";
    79.               } else if(p.hasPermission("nametag.builder")) {
    80.                   team = "0003builder";
    81.               } else if(p.hasPermission("nametag.mod")) {
    82.                   team = "0004mod";
    83.               } else if(p.hasPermission("nametag.supp")) {
    84.                   team = "0005supp";
    85.               } else if(p.hasPermission("nametag.youtuber")) {
    86.                   team = "0006youtuber";
    87.               } else if(p.hasPermission("nametag.vip")) {
    88.                   team = "0007vip";
    89.               } else {
    90.                   team = "0008user";
    91.               }
    92.              
    93.               sb.getTeam(team).addPlayer(p);
    94.  
    95.               p.setDisplayName(sb.getTeam(team).getPrefix() + p.getName());
    96.              
    97.               for(Player all : Bukkit.getOnlinePlayers()) {
    98.                   all.setScoreboard(sb);
    99.               }
    100.  
    101.  
    102.  
    103.  
    104.  
    105.        }
    106.  
    107.  
    108.  
    109. }
    110.  

    LG MTRX schon mal im vorraus danke
     
    #1
  2. jensIO
    Offline

    jensIO

    Registriert seit:
    28. Juli 2015
    Beiträge:
    602
    Ort:
    Internet, im Neuland
    Minecraft:
    jens1o
    sb definierst du zu spät. sb muss nach erstes. Vor sb.registerNewTeam("0000owner");)

    Außerdem muss das wie folgt lauten:
    Code (Text):
    1. public Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
     
    #2
  3. JTK222
    Offline

    JTK222

    Registriert seit:
    5. September 2013
    Beiträge:
    665
    Ort:
    Planet Erde
    Minecraft:
    JTK222
    Richtig ist es schon
    (weiter oben)
    Code (Text):
    1. public static Scoreboard sb;
    Jedoch musst du
    Code (Text):
    1. sb = Bukkit.getScoreboardManager().getNewScoreboard();
    ausführen bevor du zu dem Scoreboard sachen hinzufügst vorher existiert das Scoreboard nämlich gar nicht erst.
     
    #3
  4. Lentry
    Offline

    Lentry

    Registriert seit:
    15. Mai 2016
    Beiträge:
    39
    Vielen Dank
     
    #4