Solved error on startup - NPE

Discussion in 'Plugin Development' started by glasseater, Sep 12, 2015.

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

    glasseater

    Hey guys,

    I am making a plugin and it is almost done except for one bug. I get this weird error on startup and I am not too sure what's causing it or how to fix it.

    This is the error

    Code:
    [12:32:27 ERROR]: Error occurred while enabling McMyths-Core v1.0 (Is it up to date?)
    java.lang.NullPointerException
        at me.glasseater.myths.utils.ClassConstructor.<init>(ClassConstructor.java:36) ~[?:?]
        at me.glasseater.myths.utils.Econ.<init>(Econ.java:33) ~[?:?]
        at me.glasseater.myths.Core.initializePlugin(Core.java:49) ~[?:?]
        at me.glasseater.myths.Core.onEnable(Core.java:62) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:356) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:316) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:418) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:382) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:337) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:256) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:528) [craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51]

    Here is the core ClassConstructor Class:


    Code:
    public Core instance;
        public ClassConstructor(Core plugin) {
            instance = plugin;
        }
    
        public ClassConstructor() {
    
        }
    
        public FileConfiguration config = instance.getConfig();
    
        public HashMap<String, Boolean> usedKit = instance.usedKit;
    
        public String getString(String s){
            return instance.getConfig().getString(s);
        }
        public int getInt(String s){
            return instance.getConfig().getInt(s);
        }
        public int getLong(String s){
            return instance.getConfig().getInt(s);
        }
        public int getBoolean(String s){
            return instance.getConfig().getInt(s);
        } //Can you go in the server folder?
    
        //Alright now when you go into Villager all you have to do is use the eclipse completer
        public String color(String msg) {
            return ChatColor.translateAlternateColorCodes('&', msg);
    
        }
        int task;
    
        @SuppressWarnings("deprecation")
        public void startCooldown(final Player player, final HashMap<String, Integer> hashmap
        ) {
             task = instance.getServer().getScheduler().scheduleSyncRepeatingTask(instance , new BukkitRunnable() {
    
                public void run() {
                    int time = hashmap.get(player.getName());
                    hashmap.put(player.getName(), time - 1);
    
                    if(time == 0){
                        Bukkit.getServer().getScheduler().cancelTask(task);
                    }
    
                }
            }, 0L, 20L); //Which class? Ummm I guess Wolf2? kk
    
        }
    
    
        public void setOwner(Player p) {
        }
    
        public void setTamed(boolean b) {
        }
    
    
        public void setPassenger(Player p) {
        }
    
        public HorseInventory getInvetory() {
            return null;
        }
    
        public void loadKit(Player p, String kit) {
            PlayerInventory inv = p.getInventory();
            if(config.getConfigurationSection("kits.").get(kit) != null) {
                inv.clear();
                for (String armor : config.getConfigurationSection("kits." + kit + ".armor").getKeys(false)){
                    String secPath = "kits." + kit + ".armor." + armor + ".";
                    ItemStack item = new ItemStack(Material.getMaterial(config.getString(secPath + "type")));
                    for (String en : config.getConfigurationSection(secPath + "enchantments").getKeys(false)) {
                        Enchantment e = Enchantment.getByName(en.toUpperCase());
                        int l = config.getInt(secPath + "enchantments." + en);
                        item.addUnsafeEnchantment(e, l);
                    }
                    if(item.getType().name().contains("HELMET")) {
                        inv.setHelmet(item);
                    }
                    if(item.getType().name().contains("CHESTPLATE")) {
                        inv.setChestplate(item);
                    }
                    if(item.getType().name().contains("LEGGINGS")) {
                        inv.setLeggings(item);
                    }
                    if(item.getType().name().contains("BOOTS")) {
                        inv.setBoots(item);
                    }
                }
                for (String slot : config.getConfigurationSection("kits." + kit + ".items").getKeys(false)) {
                    {
                        String secPath = "kits." + kit + ".items." + slot + ".";
                        int id = config.getInt(secPath + "material-id");
                        ItemStack stack = new ItemStack(Material.getMaterial(config.getString(secPath + "material")), config.getInt(secPath + "amount"), (short) id);
                        for (String en : config.getConfigurationSection(secPath + "enchantments").getKeys(false)) {
                            Enchantment e = Enchantment.getByName(en.toUpperCase());
                            int l = config.getInt(secPath + "enchantments." + en);
                            stack.addUnsafeEnchantment(e, l);
                        }
                        List<String> lore = config.getStringList(secPath + "lore");
                        String name = config.getString(secPath + "name");
    
                        ItemMeta im = stack.getItemMeta();
                        if (name != null) {
                            im.setDisplayName(color(name));
                        }
                        if ((lore != null) &&
                                (lore.size() > 0)) {
                            ArrayList<String> loreFinal = new ArrayList<>();
                            for (String str : lore) {
                                loreFinal.add(color(str));
                            }
                            im.setLore(loreFinal);
                        }
    
                        stack.setItemMeta(im);
                        inv.setItem(getInt(secPath + "slot"), stack);
                    }
                }
            }
            usedKit.put(p.getName(), true);
        }
    }
    Here is the Core class:


    Code:
    public final class Core extends JavaPlugin implements Listener {
    
    
        public List<String> kits = new ArrayList<>();
        public HashMap<String, Boolean> usedKit = new HashMap<>(); //Like htis
        public static Plugin plugin;
        public static Plugin run;
        public ArrayList<Pair> itemPair = new ArrayList<>();
        public ArrayList<Pair> categoryPair = new ArrayList<>();
    
    
        public Config kitsConfig = new Config(this, "kits.yml");
        public Config shopConfig = new Config(this, "shop.yml");
        public Config reportsConfig = new Config(this, "reports.yml");
        private Permission permission = null;
        public ArrayList<Pair> kitsPair = new ArrayList<>();
    
    
        public void initializePlugin() {
            shopConfig.saveDefaultConfig();
            kitsConfig.saveDefaultConfig();
            reportsConfig.saveDefaultConfig();
            new Econ(this);
            new CommandManager(this);
            new EventManager(this);
            getServer().getPluginManager().registerEvents(new JoinItems(this), this);
            getServer().getPluginManager().registerEvents(new LaunchPads(this), this);
            new KitsManager(this);
    
    
        }
    
        @Override
        public void onEnable() {
    
            initializePlugin();
    
    
        }
    
        public Permission getPermission() {
            return this.permission;
        } //Try this?
    
        public FileConfiguration getKitsConfig() {
            return kitsConfig.getConfig();
        }
    
        public FileConfiguration getShopConfig() {
            return shopConfig.getConfig();
    
        }
    
        public FileConfiguration getReports() {
            return reportsConfig.getConfig();
        }
    
        public Economy econ;
        public static EconomyResponse r;
    
    
        public static Core core;
    
        public Core() {
            core = this;
        }
    }
    And here is the Econ Class

    Code:
     public Econ(Core plugin) {
            super(plugin);
            setupEconomy();
    
        }
    
        public Core plugin;
        public ArrayList<Pair> itemPair = instance.itemPair;
        public FileConfiguration shop = instance.shopConfig.getConfig();
        public Permission permission = instance.getPermission();
    
    
        public static Economy econ;
        //Not sure if that will work but try it out
        public static EconomyResponse r;
    
    
        public boolean setupEconomy() {
            if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }
    
    
        @SuppressWarnings("deprecation")
        @EventHandler
        public void onEntityDeath(EntityDeathEvent e) {
            Player p = e.getEntity().getKiller();
            if (e.getEntity().getKiller() instanceof Player) {
                r = econ.depositPlayer(p.getName(), 5.00);
                if (r.transactionSuccess()) {
                    p.sendMessage("§a§oCongrats! You have earned §6§o5 Drachmas§a§o!");
                    return;
                } else {
                    p.sendMessage(ChatColor.RED + "An error occured when paying out your money. Please contact a server admin.");
                    return;
    
                }
            }
        }
    
        @EventHandler
        public void onPlayerInteract(PlayerInteractEvent evt) {
            if (evt.getAction().equals(Action.RIGHT_CLICK_AIR) || evt.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                Player p = evt.getPlayer();
                ItemStack i = p.getItemInHand();
                if (i != null) {
                    if (i.getType() == Material.CHEST) {
                        if (i.hasItemMeta()) {
                            if (i.getItemMeta().getDisplayName().equals(color("&e&lDrachma Shop &7(&8Right-Click&7)"))) {
                            Bukkit.dispatchCommand(p, "shop");
                            }
                        }
                    }
                }
            }
        }
    
        @SuppressWarnings("deprecation")
        @EventHandler //Delete the old kits config, reload and do /debugkit brb
        public void onInventoryInteract(InventoryClickEvent evt) {
            Inventory inv = evt.getInventory();
            Player p = (Player) evt.getWhoClicked();
            String invName = color((shop.getString("Inventory.name")));
            if (evt.getInventory() == null) {
                return;
            }
            if (evt.getCurrentItem() == null) {
                return;
            }
            if (evt.getCurrentItem().getType() == null) {
                return;
            }
            if (evt.getClickedInventory() != null) {
                if (!evt.getCurrentItem().getType().equals(Material.AIR)) {
                    if (inv.getTitle() != null) {
                        if (inv.getTitle().equals(invName)) { //try
                            String path = (String) itemPair.get(evt.getSlot()).getValue();
                            evt.setCancelled(true);
                            if (!p.hasPermission("shop.use." + path.toLowerCase())) {
                                p.sendMessage(String.valueOf(shop.getInt("Shop." + path + ".price")));
                                r = econ.withdrawPlayer(p.getName(), (double) shop.getInt("Shop." + path + ".price"));
                                if (r.transactionSuccess()) {
                                    p.sendMessage("You have successfully bought " + path + ".");
                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + p.getName() + " add shop.use." + path.toLowerCase());
                                } else {
                                    p.sendMessage("You do not have " + String.valueOf(shop.getInt("Shop." + path + ".price")) + "$");
                                }
                            }
                            if (p.hasPermission("shop.use." + path.toLowerCase())) {
                                List<String> list = shop.getStringList("Shop." + path + ".commands");
                                for (String command : list) {
                                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("{player}", p.getName()));
                                }
                                p.sendMessage(color(shop.getString("Shop." + path + ".message")));
                            }
                            p.closeInventory();
    
                        }
                    }
                }
            }
        }
    
    }
    Does anyone notice what's wrong?

    Any help will be greatly appreciated!
     
  2. Offline

    SuperSniper

    @glasseater
    Code:
        at me.glasseater.myths.utils.ClassConstructor.<init>(ClassConstructor.java:36) ~[?:?]
        at me.glasseater.myths.utils.Econ.<init>(Econ.java:33) ~[?:?]
        at me.glasseater.myths.Core.initializePlugin(Core.java:49) ~[?:?]
        at me.glasseater.myths.Core.onEnable(Core.java:62) ~[?:?]
    Show us those lines of code please.

    ClassConstructor line 36.
    Econ like 33
    Core like 49
    Core like 62
     
  3. Offline

    Gamesareme

    @glasseater What is the 36 line the the ClassConstructer script?
     
  4. Offline

    glasseater

    @Gamesareme @SuperSniper
    Same error just different lines
    ClassConstructor Line 36
    Code:
    public FileConfiguration config = instance.getConfig();
    Econ Line 33
    Code:
    super(plugin);
    Core Line 49
    Code:
    new Econ(this);
    Core Line 62
    Code:
     initializePlugin();
     
  5. Offline

    Ruptur

    @glasseater
    In the ClassContructor class you tried to use core instance before assigning it.
    Code:
    public FileConfiguration config = instance.getConfig();
    public HashMap<String, Boolean> usedKit = instance.usedKit;
    This is static code run as soon as a new instance of the class of called. Notice you only set what 'instance' is in the contructor so before that 'instance' would be null, which is why you are getting an npe

    To avoid this move the assignment of 'usedKit' and 'config' instance the contructor after you define what 'instance' is
     
  6. Offline

    glasseater

    @Ruptur
    How could I define instance? I thought I did that in the core class?
     
  7. Offline

    Ruptur

    @glasseater
    Seems like you did but there is code that is running before you define it.

    A basic order of the initialise sequence
    new Class instance > Static code > Contructor

    You have these statement happening before the contructor is executed, therefore there is no way instance is not null
    Code:
    public FileConfiguration config = instance.getConfig();
    public HashMap<String, Boolean> usedKit;
    Which is causing a null pointer.
    All you need to do is to move it into the construtor after you define what instance is.
    Code:
    instance = plugin;
    usedKit = instance.usedKit;
    config = instance.getConfig();
     
  8. Offline

    glasseater

    @Ruptur
    Like this?
    Code:
    public class ClassConstructor {
    
        public Core instance;
        public ClassConstructor(Core plugin) {
            instance = plugin;
            usedKit = instance.usedKit;
            config = instance.getConfig();
    
        }
    
        public ClassConstructor() {
    
        }
    
    
    
    
        public FileConfiguration config = instance.getConfig();
    
    
    
        public HashMap<String, Boolean> usedKit = instance.usedKit;
    
        public String getString(String s){
            return instance.getConfig().getString(s);
        }
        public int getInt(String s){
            return instance.getConfig().getInt(s);
        }
        public int getLong(String s){
            return instance.getConfig().getInt(s);
        }
        public int getBoolean(String s){
            return instance.getConfig().getInt(s);
        } //Can you go in the server folder?
    
        //Alright now when you go into Villager all you have to do is use the eclipse completer
        public String color(String msg) {
            return ChatColor.translateAlternateColorCodes('&', msg);
    
        }
        int task;
    
        @SuppressWarnings("deprecation")
        public void startCooldown(final Player player, final HashMap<String, Integer> hashmap
        ) {
             task = instance.getServer().getScheduler().scheduleSyncRepeatingTask(instance , new BukkitRunnable() {
    
                public void run() {
                    int time = hashmap.get(player.getName());
                    hashmap.put(player.getName(), time - 1);
    
                    if(time == 0){
                        Bukkit.getServer().getScheduler().cancelTask(task);
                    }
    
                }
            }, 0L, 20L); //Which class? Ummm I guess Wolf2? kk
    
        }
    
    
        public void setOwner(Player p) {
        }
    
        public void setTamed(boolean b) {
        }
    
    
        public void setPassenger(Player p) {
        }
    
        public HorseInventory getInvetory() {
            return null;
        }
    
        public void loadKit(Player p, String kit) {
            PlayerInventory inv = p.getInventory();
            if(config.getConfigurationSection("kits.").get(kit) != null) {
                inv.clear();
                for (String armor : config.getConfigurationSection("kits." + kit + ".armor").getKeys(false)){
                    String secPath = "kits." + kit + ".armor." + armor + ".";
                    ItemStack item = new ItemStack(Material.getMaterial(config.getString(secPath + "type")));
                    for (String en : config.getConfigurationSection(secPath + "enchantments").getKeys(false)) {
                        Enchantment e = Enchantment.getByName(en.toUpperCase());
                        int l = config.getInt(secPath + "enchantments." + en);
                        item.addUnsafeEnchantment(e, l);
                    }
                    if(item.getType().name().contains("HELMET")) {
                        inv.setHelmet(item);
                    }
                    if(item.getType().name().contains("CHESTPLATE")) {
                        inv.setChestplate(item);
                    }
                    if(item.getType().name().contains("LEGGINGS")) {
                        inv.setLeggings(item);
                    }
                    if(item.getType().name().contains("BOOTS")) {
                        inv.setBoots(item);
                    }
                }
                for (String slot : config.getConfigurationSection("kits." + kit + ".items").getKeys(false)) {
                    {
                        String secPath = "kits." + kit + ".items." + slot + ".";
                        int id = config.getInt(secPath + "material-id");
                        ItemStack stack = new ItemStack(Material.getMaterial(config.getString(secPath + "material")), config.getInt(secPath + "amount"), (short) id);
                        for (String en : config.getConfigurationSection(secPath + "enchantments").getKeys(false)) {
                            Enchantment e = Enchantment.getByName(en.toUpperCase());
                            int l = config.getInt(secPath + "enchantments." + en);
                            stack.addUnsafeEnchantment(e, l);
                        }
                        List<String> lore = config.getStringList(secPath + "lore");
                        String name = config.getString(secPath + "name");
    
                        ItemMeta im = stack.getItemMeta();
                        if (name != null) {
                            im.setDisplayName(color(name));
                        }
                        if ((lore != null) &&
                                (lore.size() > 0)) {
                            ArrayList<String> loreFinal = new ArrayList<>();
                            for (String str : lore) {
                                loreFinal.add(color(str));
                            }
                            im.setLore(loreFinal);
                        }
    
                        stack.setItemMeta(im);
                        inv.setItem(getInt(secPath + "slot"), stack);
                    }
                }
            }
            usedKit.put(p.getName(), true);
        }
    }
    
    EDIT: Nvm that didnt work. Does it go in the Core class? Im pretty confused sorry :/
     
  9. Offline

    mythbusterma

    @Ruptur

    You forgot a few stages in there.

    Class Load > Static Initialization > (instantiation) > Class Initialization > Constructor
     
  10. Offline

    boomboompower

  11. Offline

    Ruptur

    @mythbusterma
    @glasseater
    You are still getting from instance when its null
    Code:
    public FileConfiguration config = instance.getConfig();
    public HashMap<String, Boolean> usedKit = instance.usedKit;
    You had moved the assignments to the constructor but forgot to remove it from here
     
  12. Offline

    glasseater

    @Ruptur @mythbusterma Ok I fixed that error but now I get this error
    Code:
    Caused by: java.lang.NullPointerException
        at me.glasseater.myths.utils.ClassConstructor.loadKit(ClassConstructor.java:96) ~[?:?]
        at me.glasseater.myths.listeners.KitsListener.onInventoryInteract(KitsListener.java:75) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[craftbukkit.jar:git-Spigot-6d0ae89-a03743b]
        ... 15 more
    I see its null but I don't see where...

    This is line 96 in the loadKit method in the ClassConstructor Class

    Code:
      if (config.getConfigurationSection("kits").get(kit) != null) {
    And here is line 75 in KitsListener

    Code:
    kitCommand.loadKit(p, path);
    Full KitsListener Class

    Code:
        public KitCommand kitCommand;
    
        //to fix this, we just call super(Core.core)
        public KitsListener(KitCommand kitCommand) {
            super(Core.core);
    
            this.kitCommand = kitCommand;
        }
    
        public HashMap<String, Boolean> usedKit = instance.usedKit;
        public ArrayList<Pair> kitsPair = instance.kitsPair;
        public FileConfiguration kits = instance.getKitsConfig();
    
        @EventHandler
        public void onInventoryInteract(InventoryClickEvent evt) {
            Inventory inv = evt.getInventory();
            Player p = (Player) evt.getWhoClicked();
            String invName = color(kits.getString("inventory.name")); //try
            if (evt.getInventory() == null) {
                return;
            }
            if (evt.getCurrentItem() == null) {
                return;
            }
            if (evt.getCurrentItem().getType() == null) {
                return;
            }
            if (evt.getClickedInventory() != null) {
                System.out.print("1st");
                p.sendMessage("1");
                if (!evt.getCurrentItem().getType().equals(Material.AIR)) {
                    System.out.print("2nd");
                    p.sendMessage("2");
                    if (inv.getTitle() != null) {
                        System.out.print("3rd");
                        p.sendMessage("3");
                        if (inv.getTitle().equals(invName)) { //try
                            System.out.print("4th");
                            p.sendMessage("4");
                            String path = (String) kitsPair.get(evt.getSlot()).getValue();
                            evt.setCancelled(true);
                            if (p.hasPermission("kits.use." + path.toLowerCase())) {
                                System.out.print("5th");
                                p.sendMessage("5");
                                p.sendMessage(String.valueOf(kits.getInt("kits." + path + ".price")));
                                p.sendMessage(color("&aYou have successfully loaded " + path + "."));
                                System.out.print("6th");
                                p.sendMessage("6");
                                kitCommand.loadKit(p, path); //this is where we have had the issue for the past few weeks :/
                            }
                            p.closeInventory();
    
                        }
                    }
                }
            }
        }
    
        @EventHandler
        public void onDeath(PlayerDeathEvent evt) {
            evt.setDroppedExp(0);
            evt.getDrops();
            Player p = evt.getEntity();
            if (usedKit.containsKey(p.getName())) {
                if (usedKit.get(p.getName()).equals(true)) {
                    usedKit.remove(p.getName(), true);
                    usedKit.put(p.getName(), false);
                }
                if (usedKit.get(p.getName()).equals(false)) {
                    System.out.print("Player " + p.getName() + " out of loop, contact developer.");
                    usedKit.remove(p.getName(), false);
                    usedKit.put(p.getName(), false);
                }
            }
            if (!usedKit.containsKey(p.getName())) {
                usedKit.put(p.getName(), false);
                System.out.print("Player " + p.getName() + " out of loop, contact developer.");
            }
        }
    
        @EventHandler
        public void onRespawn(PlayerRespawnEvent evt) {
            Player p = evt.getPlayer();
            Inventory inv = p.getInventory();
            ItemStack drac = new ItemStack(Material.CHEST, 1);
            ItemStack ns = new ItemStack(Material.NETHER_STAR, 1);
    
            ItemMeta dracM = drac.getItemMeta();
            ItemMeta nsM = ns.getItemMeta();
    
            dracM.setDisplayName(color("&e&lDrachma Shop &7(&8Right-Click&7)"));
            nsM.setDisplayName(color("&6&lArmory &7(&8Right-Click&7)"));
    
            ns.setItemMeta(nsM);
            drac.setItemMeta(dracM);
    
            if (!inv.contains(ns)) {
                inv.setItem(8, ns); //try
            }//try
            if (!inv.contains(drac)) {
                inv.setItem(0, drac);
            }
    
        }
    
        @EventHandler
        public void onRightClick(PlayerInteractEvent evt) {
            if (evt.getAction() == Action.RIGHT_CLICK_BLOCK || evt.getAction() == Action.RIGHT_CLICK_AIR) {
                Player p = evt.getPlayer();
                ItemStack hand = p.getItemInHand();
                if (hand.hasItemMeta()) {
                    if(hand.getItemMeta().getDisplayName().equals(color("&6&lArmory &7(&8Right-Click&7)"))){
                    p.chat("/debugkit");
                    }
                }
            }
        }
    }
    @boomboompower
    I read that... But I don't see what is null I initialized everything :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  13. Offline

    mythbusterma

    Well, in that case, you're completely wrong.

    (instantiation) > Class Init > Constructor

    No static initializers are run in this case.


    @glasseater

    Start using encapsulation properly. Then learn what accessor methods are. Then use them properly.

    That will magically solve all your issues.
     
  14. Offline

    glasseater

    @mythbusterma Thank you for the help... Found out that wasn't the issue... It was a silly mistake on my part.. I was doing .getConfig instead of .getKitsConfig...
    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page