Solved Enum NullPointerExeption error

Discussion in 'Plugin Development' started by 4thegame3, Nov 5, 2015.

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

    4thegame3

    Hello, I'm getting this error and i really don't know why...
    Error (open)

    [13:16:08] [Server thread/INFO]: 4TheGame3 issued server command: /wand
    [13:16:08] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'wand' in plugin AmbitiousMagic v0.0.1
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_40]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_40]
    at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-550ebac-7019900]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_40]
    Caused by: java.lang.ExceptionInInitializerError
    at me.TheGame.AmbitiousMagic.AmbitiousMagicMAIN.onCommand(AmbitiousMagicMAIN.java:108) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.jar:git-Spigot-550ebac-7019900]
    ... 14 more
    Caused by: java.lang.NullPointerException



    The class enum:
    Code:
    public enum Wands {
        NOVICE_WAND(new NoviceWand()),
        APPRENTDIST_WAND(new ApprendistWand());
        public Wand wand;
        private Wands(Wand wand){
            this.wand = wand;
        }
        public static Wands fromString(String str){
            switch (str) {
            case "Novice":
                return NOVICE_WAND;
            case "Apprendist":
                return APPRENTDIST_WAND;
            default:
                return null;
            }
        }
    }
    The NoviceWand class:
    Code:
    
    public class NoviceWand extends Wand{
        public NoviceWand(){
            super();
            this.prefix = "ยง5";
            this.lore = new LinkedList<String>(Arrays.asList(ChatColor.RED+"Bacchetta base indispensabile per iniziare a praticare magia"));
            this.wand = new ItemStack(Material.STICK);
            this.cost = 500;
            this.advableSpells = Arrays.asList(Spells.FIREBALL_SPELL,Spells.VORTEX_SPELL);
            this.name = "Bacchetta per novellini";
        }
    }
    
    And the calling line:
    Code:
    Wand wand = Wands.NOVICE_WAND.wand;
     
    Last edited: Nov 5, 2015
  2. Offline

    Lordloss

    can we see the class where you got your onCommand method? AmbitiousMagicMAIN.java:108
     
  3. Offline

    4thegame3

    Solved by restarting the server. Then i got another error and i fixed it.
     
  4. Offline

    Scimiguy

    Please mark the thread as solved if you've resolved the issue then please

    =0 Ninja'd!
     
  5. Offline

    4thegame3

    Was going to do it later since i had to go.
     
Thread Status:
Not open for further replies.

Share This Page