[SOLVED]Plugin load error

Discussion in 'Spigot Plugin Development' started by ChikenGamer, Jun 16, 2015.

  1. EDIT
    Error:
    Code (Text):

    [16:19:13 ERROR]: Error occurred while enabling AdvancedHubPlus v1.0.0 (Is it up
     to date?)
    java.lang.NullPointerException
            at com.jimdo.choscar.Principal.GADGETS.Hats.<init>(Hats.java:28) ~[?:?]
            at com.jimdo.choscar.Principal.AdvancedHubPlusMain.onEnable(AdvancedHubP
    lusMain.java:26) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[s
    pigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:340) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r.java:405) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.jav
    a:356) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.
    java:316) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:74
    2) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.Bukkit.reload(Bukkit.java:534) [spigot1_8.jar:git-Spigot-0
    44d928-e8c6403]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    25) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14
    1) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServe
    r.java:642) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(Craf
    tServer.java:628) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:
    404) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:3
    68) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:6
    57) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java
    :560) [spigot1_8.jar:git-Spigot-044d928-e8c6403]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_31]
     
    Line 26 of "hats"
    PHP:
    String id1 = HConfig.get().getString("Hat1.Hat");
    Class of "hats"
    PHP:
    public class Hats implements Listener{
     
        AdvancedHubPlusMain plugin;
        public Hats(AdvancedHubPlusMain plugin) {
            this.plugin = plugin;
        }

    private Inventory invH;
     
    ////////////////////Hat 1///////////////////////
    String id1 = HConfig.get().getString("Hat1.Hat");
    int ip1 = HConfig.get().getInt("Hat1.Short");
    int Hat1 = HConfig.get().getInt("Hat1.Slot");
    String Hat1Name = HConfig.get().getString("Hat1.Name").replaceAll("&", "§");
    String Hat1Lore = HConfig.get().getString("Hat1.Lore").replaceAll("&", "§");
       
     public  void Enable() { //to onEnable
                    invH = Bukkit.createInventory(null, 18, "Name");
    invH.setItem(Hat1, createItem(Material.valueOf(id1), 1, (short) ip1, Hat1Name, Hat1Lore));
     
    Main:
    PHP:

    private Hats hats;
       
        public void onEnable(){
            pm.registerEvents(this, this);
           
            pm.registerEvents(new Hats(this), this);
           
            l.log(Level.INFO, " > Status: Enabled");
            l.log(Level.INFO, " > Version: " + getDescription().getVersion());
            l.log(Level.INFO, " > Author: " + getDescription().getAuthors());
            l.log(Level.INFO, " > Name: " + getDescription().getName());
            l.log(Level.INFO, "=======================");
      /////////////////////////////////////////////////////////////////////////////      
            HConfig.setup();
            HConfig.get().options().copyDefaults();
            HConfig.save();
      /////////////////////////////////////////////////////////////////////////////
            hats = new Hats(this);
            hats.Enable();
           
    }
     
    Line 26 of the main class:
    Code (Text):
    pm.registerEvents(new Hats(this), this);
     
    #1 ChikenGamer, Jun 16, 2015
    Last edited: Jun 16, 2015
  2. Looks like your error is on line 22 of your main class. What line is that cause you only posted parts of your classes?
     
  3. Line 22: Hats Hats = new Hats(this);
     
  4. Uh, mind showing me where in the StackTrace you saw that? All I see is this..
    at com.jimdo.choscar.Principal.GADGETS.Hats.<init>(Hats.java:25

    EDIT: Nevermind, I'm in my phone, and the way it formatted I didn't see the line below, my bad.