Solved Adding a custom integer

Discussion in 'Plugin Development' started by Condolent, Dec 28, 2015.

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

    Condolent

    So I want a currency system where I as a admin can add credits to a user. The command is /currency add <player> <amount> but I've set it up wrong, so bukkit thinks the amount is a string. How do I make it an integer?
    My line of code for the command:
    Code:
    getPlayerLog().set(targetUUID, getPlayerLog().getInt(targetUUID) + args[2]);
    plugin.savePlayerLog();
    Is there a easy way to fix this? I'm guessing I need to make a private integer and set that integer to the argument or something, but that seems like kind of a hassle, I feel like there's a easier way, but I can't figure it out.

    FYI: the getPlayerLog is a custom .yml file, basically like a config
     
  2. Offline

    Xerox262

    Integer.parseInt(String);
    That's pretty basic Java, make sure you handle NFE
     
  3. Offline

    Condolent

    @Xerox262 thanks! Trying to come back to Java after a year of inactivity, forgot a bunch of very basic stuff hehe
     
    Zombie_Striker likes this.
  4. Offline

    Zombie_Striker

    @Condolent
    It's always takes time coming back to something after a long period of time. Mark thread as solved, if your problem has been solved.
     
Thread Status:
Not open for further replies.

Share This Page