player.setInvincible(boolean)

A new update is now available, introducing seasons and more!
Latest hotfix: 0.8.0.1 (2024-12-20)
  • No need to say sorry Solveign :) It's for the first server screen - just don't want people tabbing to chrome (other browsers are available hehe) to read the rules only to return to find their character dead. I've implemented the no damage for now, but someone may find they need food and water rather desperately if they stay on that screen too long.

  • Actually it's intended that the hunger/thirst bar still go down when cancelling the PlayerDamage event, but the player doesn't take any damage ;)


    If you want to disable hunger/thirst, you have either have to disable it by setting the permission key (although this could be overridden if the player permission group gets changed in the meantime), or alternatively you have to create a timer and set the hunger/thirst back to 100 every minute or so, for example:


    Java
    @EventMethod
    public void onPlayerSpawnEvent(PlayerSpawnEvent evt){
    Timer timer = new Timer(60, 0, -1, () -> {
    evt.getPlayer().setHunger(100);
    evt.getPlayer().setThirst(100);
    });
    timer.start();
    }
  • If you work with that timer you will probably need to stop the timer when the player logs out, otherwise you would probably get a nullpointer exception the next time that timerevent is triggered...

    Good point! You won't get a nullpointer though, but it's still a bad thing if too many unnecessary timers are running in the background. Having a small check inside the timer if the player is still connected (and kill it if needed) would be indeed a better approach:


Participate now!

Don’t have an account yet? Create a new account now and be part of our community!