NullPointerException help

Discussion in 'Plugin Development' started by KiF, Jun 18, 2014.

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

    KiF

    I tried running my plugin on my server, but then the console said I got a NullPointerException. When I checked why, it said I had errors on lines 44 and 152 in my main class.
    Line 44:
    Code:
    @Override
        public void onEnable(){
            String enability = "enabled";
            ScoreboardManager sbManager = Bukkit.getScoreboardManager();
            Scoreboard sBoard = sbManager.getNewScoreboard();
            Inventory wrGadget2Inv = Bukkit.createInventory(null, 9, ChatColor.GREEN + "Choose a gadget!");
            Inventory wrGadget1Inv = Bukkit.createInventory(null, 9, ChatColor.GREEN + "Choose a gadget!");
            Inventory wrPrimaryInv = Bukkit.createInventory(null, 9, ChatColor.GREEN + "Choose a primary weapon!");
            Inventory wrCustomInv = Bukkit.createInventory(null, 9, ChatColor.GREEN + "Choose an item to customize!");
            Inventory customizeInv = Bukkit.createInventory(null, 9, ChatColor.GREEN + "Choose a class to customize!");
            Inventory AGclassInv = Bukkit.createInventory(null, 9, ChatColor.GREEN + "Choose a Class!");
            Team team1 = sBoard.registerNewTeam("Red Team");
            Team team2 = sBoard.registerNewTeam("Yellow Team");
            (LINE 44)onInventoryClick(null, team1, team2, "enabled", wrGadget2Inv, wrGadget1Inv, wrPrimaryInv, wrCustomInv, customizeInv, AGclassInv);
            onCommand(null, null, null, "enabled", null);
            onPlayerQuit(null, team1, team2);
            int playerCount;
            playerCount = Bukkit.getOnlinePlayers().length;
            if(enability == "enabled"){
                if(playerCount == 6){
                thing1.arenaStart(null, team1, team2);
                }else if(playerCount <= 5){
                thing1.arenaWait(team1, team2);
                }
            }
        }
    Line 152:
    Code:
    @EventHandler
        public void onInventoryClick(InventoryClickEvent event,
                                    Team team1,
                                    Team team2,
                                    String enability,
                                    Inventory wrGadget2Inv,
                                    Inventory wrGadget1Inv,
                                    Inventory wrPrimaryInv,
                                    Inventory wrCustomInv,
                                    Inventory customizeInv,
                                    Inventory AGclassInv){
            if(enability == "enabled"){
        (LINE 152)Player player = (Player) event.getWhoClicked();
        ItemStack clicked = event.getCurrentItem();
        Inventory inventory = event.getInventory();
    I'm pretty sure the exception happens on line 44 where I put "null," because that's where the method looks for the InventoryClickEvent. So, what do I put as a placeholder for the event since "null" doesn't work? Also, what is wrong with line 152?

    Thanks in advance :D
     
  2. Offline

    es359


    Please post your Stacktrace.
     
  3. Offline

    Rocoty

    You're passing null to a method that doesn't check for null before using the parameter. In fact, why you do explicitly call an EventHandler method anyway?
     
    es359 likes this.
  4. Offline

    JD_Warriors

  5. Offline

    KiF

    es359 Stacktrace (bottom to top):
    Rocoty I'm calling the eventhandler method because I'm initializing some objects (like teams and inventories) in my onEnable method. After initializing them there, I have to input the to the methods that require them.
     
  6. Offline

    Rocoty

    I dont think you know what a method really is. You should read up on the topic.
     
    AoH_Ruthless likes this.
  7. Offline

    KiF

    While I am new to developing Bukkit plugins, I can assure you that I do know what a method is. I'm not looking for offensive comments, but I am looking for suggestions to help solve my problem.
     
Thread Status:
Not open for further replies.

Share This Page