Help! NullPointerException on my Plugin!

Discussion in 'Server & Community Management' started by ryguybuddy, Feb 10, 2015.

  1. I have continually encountered this error in my plugin, please help.
    Code (Text):
       package com.outlook.rcottone;


    import java.util.logging.Logger;

    import net.milkbowl.vault.chat.Chat;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.permissions.Permission;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Plugin extends JavaPlugin {

        final Logger log = Logger.getLogger("Minecraft");
         Economy econ = null;
         Permission perms = null;

        @Override
        public void onDisable() {
            log.info(String.format("[%s] Disabled Version %s", getDescription().getName(), getDescription().getVersion()));
        }

        @Override
        public void onEnable() {
            if (!setupEconomy() ) {
                log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
            setupPermissions();
            setupChat();
        }

        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }

        private boolean setupChat() {
            RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
            chat = rsp.getProvider();
            return chat != null;
        }

        private boolean setupPermissions() {
            RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
            perms = rsp.getProvider();
            return perms != null;
        }

        @SuppressWarnings("deprecation")
        public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
            if(!(sender instanceof Player)) {
                log.info("Only players are supported for this Example Plugin, but you should not do this!!!");
                return true;
            }

            Player player = (Player) sender;

            if(command.getLabel().equals("test-economy")) {
                // Lets give the player 1.05 currency (note that SOME economic plugins require rounding!)
                sender.sendMessage(String.format("You have %s", econ.format(econ.getBalance(player.getName()))));
                EconomyResponse r = econ.depositPlayer(player, 1.05);
                if(r.transactionSuccess()) {
                    sender.sendMessage(String.format("You were given %s and now have %s", econ.format(r.amount), econ.format(r.balance)));
                } else {
                    sender.sendMessage(String.format("An error occured: %s", r.errorMessage));
                }
                return true;
            } else if(command.getLabel().equals("test-permission")) {
                // Lets test if user has the node "example.plugin.awesome" to determine if they are awesome or just suck
                if(((Economy) perms).has(player, "example.plugin.awesome", 0)) {
                    sender.sendMessage("You are awesome!");
                } else {
                    sender.sendMessage("You suck!");
                }
                return true;
            } else {
                return false;
            }
        }
    }
    That is my plugin code and this is my server log:
    Code (Text):
    09.02 23:28:15 [Server] INFO World saved.
    09.02 23:28:15 [Server] INFO CONSOLE: Forcing save..
    09.02 23:28:15 [Server] INFO CONSOLE: Enabled level saving..
    09.02 23:28:15 [Multicraft] Auto-saving world...
    09.02 23:18:09 [Server] INFO World saved.
    09.02 23:18:09 [Server] INFO CONSOLE: Forcing save..
    09.02 23:18:09 [Server] INFO CONSOLE: Enabled level saving..
    09.02 23:18:09 [Multicraft] Auto-saving world...
    09.02 23:17:11 [Server] INFO No new version available
    09.02 23:17:11 [Server] INFO Checking for Updates ...
    09.02 23:17:11 [Server] INFO CONSOLE: Reload complete.
    09.02 23:17:11 [Server] INFO Server permissions file permissions.yml is empty, ignoring it
    09.02 23:17:11 [Server] INFO Enabling EssentialsSpawn v2.13.1
    09.02 23:17:11 [Server] INFO Enabling EssentialsChat v2.13.1
    09.02 23:17:11 [Server] INFO Permissions listed in as player-commands will be given to all users.
    09.02 23:17:11 [Server] INFO Essentials: Using config file enhanced permissions.
    09.02 23:17:11 [Server] INFO [Vault][Economy] Essentials Economy hooked.
    09.02 23:17:11 [Server] INFO 1.7.10-R0.1-SNAPSHOT
    09.02 23:17:11 [Server] INFO git-Spigot-1649 (MC: 1.7.10)
    09.02 23:17:11 [Server] INFO Bukkit version format changed. Version not checked.
    09.02 23:17:11 [Server] INFO Enabling Essentials v2.13.1
    09.02 23:17:11 [Server] INFO Registered Sniper Listener.
    09.02 23:17:11 [Server] INFO Registered 75 Sniper Brushes with 149 handles.
    09.02 23:17:11 [Server] INFO Enabling VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    09.02 23:17:11 [Server] INFO Brewery enabled!
    09.02 23:17:10 [Server] INFO Enabling Brewery v1.3.1
    09.02 23:17:10 [Server] INFO at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:290) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at net.minecraft.server.v1_7_R4.DedicatedServer.aB(DedicatedServer.java:326) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchServerCommand(CraftServer.java:753) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.Bukkit.reload(Bukkit.java:301) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.craftbukkit.v1_7_R4.CraftServer.reload(CraftServer.java:866) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[spigot-1649.jar:git-Spigot-1649]
    09.02 23:17:10 [Server] INFO at com.outlook.rcottone.Plugin.onEnable(Plugin.java:36) ~[?:?]
    09.02 23:17:10 [Server] INFO at com.outlook.rcottone.Plugin.setupChat(Plugin.java:53) ~[?:?]
    09.02 23:17:10 [Server] INFO java.lang.NullPointerException
    09.02 23:17:10 [Server] ERROR Error occurred while enabling PurchasePermission v1.0 (Is it up to date?)
    09.02 23:17:10 [Server] INFO Enabling PurchasePermission v1.0
    09.02 23:17:10 [Server] INFO Enabled Version 1.5.2-b33
    09.02 23:17:10 [Server] INFO [Permission] SuperPermissions loaded as backup permission system.
    09.02 23:17:10 [Server] INFO [Economy] Essentials Economy found: Waiting
    09.02 23:17:10 [Server] INFO Enabling Vault v1.5.2-b33
    09.02 23:17:10 [Server] INFO Loading EssentialsSpawn v2.13.1
    09.02 23:17:10 [Server] INFO Loading EssentialsChat v2.13.1
    09.02 23:17:10 [Server] INFO Loading Essentials v2.13.1
    09.02 23:17:10 [Server] INFO Loading VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    09.02 23:17:10 [Server] INFO Loading Brewery v1.3.1
    09.02 23:17:10 [Server] INFO Loading PurchasePermission v1.0
    09.02 23:17:10 [Server] INFO Loading Vault v1.5.2-b33
    09.02 23:17:10 [Server] INFO Disabling Vault v1.5.2-b33
    09.02 23:17:10 [Server] INFO Disabled Version 1.0
    09.02 23:17:10 [Server] INFO Disabling PurchasePermission v1.0
    09.02 23:17:10 [Server] INFO Brewery disabled!
    09.02 23:17:10 [Server] INFO Disabling Brewery v1.3.1
    09.02 23:17:10 [Server] INFO Disabling VoxelSniper v5.170.0-SNAPSHOT-jnks317-gitfcb8fe1
    09.02 23:17:10 [Server] INFO [Vault][Economy] Essentials Economy unhooked.
    09.02 23:17:10 [Server] INFO Disabling Essentials v2.13.1
    09.02 23:17:10 [Server] INFO Disabling EssentialsChat v2.13.1
    09.02 23:17:10 [Server] INFO Disabling EssentialsSpawn v2.13.1
    and my console log.
     
  2.  
  3. post lines 23,36 and 53
     
  4. @iXColtXi what is the problem? Is it with the code or spigot version? I think it may be because my plugin is geared for full 1.8 spigot and I have the 1.7.10-1.8 support version. I will test when I get home
     
  5. That doesn't work, I really need help ASAP!