Setting Max Health not working?

Discussion in 'Plugin Development' started by Acer_Mortem, May 17, 2014.

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

    Acer_Mortem

    On the player join event, I set the Max Health to 40 (20 hearts), yet, whenever I log in, only 10 hearts are shown filled, and the other 10 hearts can't be regenerated.

    Code:
        @EventHandler
        public void playerSetHealth(final PlayerJoinEvent e){
                    e.getPlayer().setMaxHealth(40D);
                    e.getPlayer().setHealthScaled(false);
                    e.getPlayer().setHealth(e.getPlayer().getMaxHealth());
     
        }
     
  2. Offline

    TGRHavoc

    Acer_Mortem
    Try taking the line e.getPlayer().setHealthScaled(false ); out... I've successfully set the players' health many time without that line...
     
  3. Offline

    rsod

    Are you registering your event correctly?
     
    dentych likes this.
  4. Offline

    CodePlaysMC

    rsod is correct.
    If you aren't registering your events correctly, or at all, then the event won't happen.
    To register your event, you need to put this under you onEnable void.

    Code:
    getServer().getPluginManager().registerEvents(this, this);
     
Thread Status:
Not open for further replies.

Share This Page