[SOLVED] Vault integration help!

Discussion in 'Plugin Development' started by TheHudek, Aug 3, 2012.

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

    TheHudek

    Hi!

    Here is a piece of my code:
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
            Player player = (Player) sender;
            double price = Config.getDouble("price");
            EconomyResponse r = econ.withdrawPlayer(player.getName(), price);
            if(commandLabel.equalsIgnoreCase("buyheal") || commandLabel.equalsIgnoreCase("bh")){
                if(player.hasPermission("buyheal.heal")){
                    econ.withdrawPlayer(player.getName(), price);
                if(args.length == 0 && r.transactionSuccess()){
                    player.setHealth(20);
                    player.sendMessage(ChatColor.GOLD + "You healed yourself for " + r.amount + " " + econ.currencyNamePlural());
                }else{
                    player.sendMessage(ChatColor.DARK_BLUE + "You" + ChatColor.RED + " don't " + ChatColor.DARK_BLUE + "have enough money");
                }
                }
            }else{
                player.sendMessage(ChatColor.RED + "You can't do that, bro!");
            }
            return false;
        }
    It doesn't have an error message but, when i run command /buyheal it says a long error message on the console:
    Code:
    19:09:32 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'buyh
    eal' in plugin BuyHeal v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:42)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:16
    8)
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:4
    90)
            at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.
    java:862)
            at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:822)
     
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:804)
            at net.minecraft.server.Packet3Chat.handle(Packet3Chat.java:44)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:281)
            at net.minecraft.server.NetServerHandler.d(NetServerHandler.java:105)
            at net.minecraft.server.ServerConnection.b(SourceFile:35)
            at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
            at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:557)
            at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:212)
            at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:472)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:404)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.NullPointerException
            at net.thehudek.BuyHeal.BuyHeal.onCommand(BuyHeal.java:77)
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:40)
            ... 15 more
    P.S.:It's still working if i change to econ.withdrawPlayer(player.getName(), 20); and if i delete double price = Config.getDouble("price"); but i want to pay the price which is configured by the user.

    Solved, sorry for that.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  2. Offline

    Diegokoen

    what did you do?!
     
Thread Status:
Not open for further replies.

Share This Page