Null Value

Discussion in 'Plugin Development' started by killerzz1, May 9, 2015.

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

    killerzz1

    Hello, I am making a plugin that has stats involved in it and when i join the server it gives you your stats but if the player has not done one of the stats E.G. Get a kill it will say "kills: null" how do i change it from a null value to 0?

    If you need to see the code just ask thanks :D
     
  2. Offline

    Skionz

    @killerzz1 An 'int' is 0 by default and primitives cannot be null. Are you using a wrapper class?
     
  3. Offline

    killerzz1

    I don't know if I am or not
    Code:
    public class deaths {
        public static void setTimesdied(Player p){
       
           
            int deaths = Main.getInstance().settingsp.getplayer().getInt(p.getName()+".deaths");
            deaths =  deaths+1;
            Main.getInstance().settingsp.getplayer().set(p.getName()+".deaths", deaths);
            Main.getInstance().settingsp.saveplayer();   
           
        }
    
    }
    Here is my method for adding the deaths to a config.yml
     
  4. Offline

    teej107

    @killerzz1 Show the code where you send the player the "kills: #" info.
     
  5. Offline

    caderape

    @killerzz1 When a player join for the first time, save in the config his kill as 0,
    or just check in your method if the player has killed or no.
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page