Solved Can't find where this nullpointerexception comes from.

Discussion in 'Plugin Help/Development/Requests' started by Dsi_Mario, Dec 30, 2014.

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

    Dsi_Mario

    This is an ongoing problem for me, I just can't find where the nullpointer comes from. I assume it is coming from my main class. Yes, I know it is bad to store player objects. Please don't rant about that. I know.
    The error:
    Code:
    [10:49:18] [Server thread/WARN]: [LolSwag] Task #2 for LolSwag v128 generated an exception
    java.lang.NullPointerException
        at me.knightuniverse.clubminecraft.Main$1.run(Main.java:29) ~[?:?]
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot.jar:git-Spigot-1649]
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:641) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1649]
    My main class file:
    Code:
    package me.knightuniverse.clubminecraft;
    
    
    import java.util.ArrayList;
    import java.util.List;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.Team;
    
    public class Main extends JavaPlugin implements Listener{
        public static List<Player> onlinePlayers = new ArrayList<Player>();
        public static Team blue;
        public static Team red;
        public static Team spec;
    
    public void onEnable(){
        spec = Bukkit.getScoreboardManager().getMainScoreboard().getTeam("Spectator");
        blue = Bukkit.getScoreboardManager().getMainScoreboard().getTeam("Blue");
        red = Bukkit.getScoreboardManager().getMainScoreboard().getTeam("Red");
            Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    for(Player p : onlinePlayers){
                        p.getInventory().getItemInHand().setDurability((short) 0);
                        p.getInventory().getHelmet().setDurability((short) 0);
                        p.getInventory().getChestplate().setDurability((short) 0);
                        p.getInventory().getLeggings().setDurability((short) 0);
                        p.getInventory().getBoots().setDurability((short) 0);
                    }
                    for(Player p : onlinePlayers){
                        p.setFoodLevel(20);
                        p.setSaturation(20);
                        if(!IsSpec.isSpectating(p)){
                        if(p.getLocation().getBlock().getType().equals(Material.WATER) || p.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER)){
                            p.damage(Math.random()*2.0+2.0);
                        }
                    }
                       
                        GameOver.TestIfOver();
                        AutomateServer.StartAutomating();
                        FireballHandler.HandleFireBall();
                        DoubleJumpHandler.HandleDoubleJump();
                        GoldPressurePlateHandler.HandleGoldPresssurePlate();
                    }
                }
        }, 20, 0);
        PluginManager pm = getServer().getPluginManager();
        pm.registerEvents(this, this);
        pm.registerEvents(new CharlesJonesAkaDamageHandler(), this);
        pm.registerEvents(new FireballHandler(), this);
        pm.registerEvents(new PlayerHashmapReset(), this);
        pm.registerEvents(new MiscListeners(), this);
        }
    
    }
     
  2. Offline

    Assist

    @Dsi_Mario
    Code:
    at me.knightuniverse.clubminecraft.Main$1.run(Main.java:29) ~[?:?]
    Line 29. They are not holding anything in their hands and you are trying to set the item durability.
     
  3. Offline

    Dsi_Mario

    Thank you! I probably should have found that error earlier when I added it and it immediately started throwing a NullPointerException.
     
Thread Status:
Not open for further replies.

Share This Page