Vault withdrawing money from users account issue

Discussion in 'Plugin Development' started by mineforfun, Aug 28, 2013.

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

    mineforfun

    OK i just fixed a lot of bugs in my plugin and now i have added vault to make it better :D. but when i run the server i get an error saying therer is a issue with this line:

    Code:
    EconomyResponse r = econ.withdrawPlayer(player.getName(), plugin.getConfig().getInt("Word_Fuck_Cost"));
    I want the amount that a player is charged to come from the config.yml here is the segment from the config.yml i am calling on
    so is there another way i should be trying to withdraw the money ?
    -Thank you
     
  2. For all we know the error is caused by your server being out of bacon, post the error stacktrace perhaps??
     
    Eats_Rainbows likes this.
  3. Offline

    mineforfun

     
  4. Caused by: java.lang.NullPointerException
    at me.gerard2202.Firstplugin.Chat_listen.onPlayerChat(Chat_listen.java:49)

    so, one of the variables on that line has not been set to a value. Have a look and figure out which one hasn't been given a value.
     
  5. Offline

    mineforfun

    what i was saying is that line 49 is:
    Code:
    EconomyResponse r = econ.withdrawPlayer(player.getName(), plugin.getConfig().getInt("Word_Fuck_Cost"));
    and the config looks just like this :

    so i have given it a value :S
     
  6. econ, player and plugin are variables on that line.

    One of them, or possibly all, have not been given values according to that error message.

    Not the config.yml, the actual java variables.
     
  7. Offline

    mineforfun

    *Time to sound dumb* i do not get what you are talking about
     
  8. post the Chat_listen.java file and i'll point them out.
     
  9. Offline

    mineforfun

  10. Ok, assuming that you're actually passing your plugin class to the Chat_listen's constructor and you don't do anything funky like call the event somewhere else without a player, you haven't initialised the econ field.

    If you look at vault's dbo page http://dev.bukkit.org/bukkit-plugins/vault/ it tells you how to do this.
     
  11. Offline

    Diegokoen

    Hey i got the same problem but i didn't foud the awnser! I am making a command (/heal) but I want that player pay for that command. But how can i setup that in the config?
    //Code
    EconomyResponse r = econ.withdrawPlayer(p.getName(), getconfig().getInt("Heal"));
    if (r.transactionSuccess()){
    p.setHealt(20);
    } else {
    p.sendMessage("§cYou need more money " + p.getName() + "!");
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page