Error in console says "Error occurred while enabling plugin v1.0 (is it up to date?)"

Discussion in 'Plugin Development' started by tregt315, May 31, 2019.

  1. Offline

    tregt315

    Console error below

    [08:57:32 ERROR]: Error occurred while enabling Custom_Game_Crates v1.0 (Is it up to date?)
    java.lang.NullPointerException: null
    at me.Tregt315.GameCrates.commands.CustomLoot.<init>(CustomLoot.java:18) ~[?:?]
    at me.Tregt315.GameCrates.Main.onEnable(Main.java:16) ~[?:?]


    Code in main below

    1 package me.Tregt315.GameCrates;
    2
    3 import org.bukkit.plugin.java.JavaPlugin;
    4
    5 import me.Tregt315.GameCrates.commands.CustomLoot;
    6 import me.Tregt315.GameCrates.listeners.InventoryClickListener;
    7 import me.Tregt315.GameCrates.ui.Crate_UI;
    8
    9 public class Main extends JavaPlugin {
    10
    11
    12 @Override
    13 public void onEnable() {
    14 new CustomLoot(this);
    15 new InventoryClickListener(this);
    16 Crate_UI.initialize();
    17 }
    18
    19 }
     
  2. Offline

    timtower Ninja on the waves Moderator

    @tregt315 Post the customloot class please without the line numbers.
     
  3. Offline

    tregt315

    Code:
    package me.Tregt315.GameCrates.commands;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    import me.Tregt315.GameCrates.Main;
    import me.Tregt315.GameCrates.ui.Crate_UI;
    
    public class CustomLoot implements CommandExecutor{
    
        private Main plugin;
       
        public CustomLoot(Main plugin) {
            this.plugin = plugin;
           
            plugin.getCommand("test").setExecutor(this);
        }
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player))
            {
               
                return true;
           
        }
            Player p = (Player) sender;
           
            if(p.hasPermission("blah.blah")) {
                p.openInventory(Crate_UI.GUI(p));
               
            }
            return false;
        }
    }
     
    Last edited by a moderator: May 31, 2019
  4. Offline

    timtower Ninja on the waves Moderator

    @tregt315 Did you register the command in the plugin.yml?
    If not: please do so.
     
  5. Offline

    tregt315

    I did

    name: Custom_Game_Crates
    version: 1.0
    main: me.Tregt315.GameCrates.Main
     
  6. Offline

    timtower Ninja on the waves Moderator

    @tregt315 You didn't register the command there.
     
  7. Offline

    tregt315

    ok I will thanks

    name: Custom_Game_Crates
    version: 1.0
    main: me.Tregt315.GameCrates.Main
    commands:
    basic:
    description: Test Plugin
    usage: /<command>

    still putting out errors

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2019
  8. Offline

    timtower Ninja on the waves Moderator

    @tregt315 Because you have basic in your plugin.yml but test in your cide.
     
  9. Offline

    tregt315

    thanks it is working now
     

Share This Page