When I join my max health is 40.0 but it shows 20.0 until it updates. HELP

Discussion in 'Spigot Plugin Development' started by parpar8090, Aug 14, 2019.

  1. So I made a feature in my plugin that will give you 40.0 HP instead of 20.0 as the default Minecraft, but then when I join the health shows 20.0 even if it's 40.0 is there any way to set it to 40.0? It's probably a visual glitch...
    Remember! I have no console errors.
    Code (Java):
    public void addHealth(Player p) {
            String pname = p.getUniqueId().toString();
            if(this.getCustomConfig().getBoolean("Players." + pname + ".HasMoreHealthPerk") == true){
            else if(this.getCustomConfig().getBoolean("Players." + pname + ".HasMoreHealthPerk") == false){
    trigger line:
    Code (Java):
    Also, if we speak about health, when I want to reset it to 20.0 it still wants to be at 40.0... Idk why.
  2. Where do you call that method?
    • Agree Agree x 1
  3. Here, it's when I am clicking in the inventory:
    Code (Java):
                else if(e.getRawSlot() == 13){
                    String pname = p.getUniqueId().toString();
                    int money = plugin.getCustomConfig().getInt("Players." + pname + ".Coins");
                    if(plugin.getCustomConfig().getInt("Player." + pname + ".Coins", money) > 15000) {
                        if(plugin.getCustomConfig().getBoolean("Players." + pname + ".HasMoreHealthPerk") == false) {
                            plugin.getCustomConfig().set("Players." + pname + ".HasMoreHealthPerk", true);
                            //p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 200, 5));
                            p.playSound(loc, Sound.ENTITY_PLAYER_LEVELUP, 100, 1.5F);
                            plugin.getCustomConfig().getInt("Player." + pname + ".Coins", money - 15000);
                            plugin.saveCustomConfig(); //Save config
                        else if(plugin.getCustomConfig().getBoolean("Players." + pname + ".HasMoreHealthPerk") == true){
                            p.playSound(loc, Sound.ENTITY_ENDERMAN_TELEPORT, 100, 0);
                            p.sendMessage("§cYou already have this perk!");
                    else if(plugin.getCustomConfig().getInt("Player." + pname + ".Coins", money) < 15000) {
                        p.sendMessage("§cNot enough money! Check your money value at §d/mymoney");
    Also when in the config I have:
    HasMoreHealthPerk: true
  4. Does this occur for any health amount you set?
  5. Wdym occur?
  6. TWW


    occur = happen
  7. Yes it happens when its 40.0 HP 60.0HP 55.0HP etc...
    Thank you so much!
  8. Just checking that you have remembered to remove your config entry for ("Players." + pname + ".HasMoreHealthPerk")
    During the event, you are checking it is false, the line after you set it to true and then it also has to be true when you call plugin#addHealth, which is fine by itself. I know it'd be something I'd forget to do