Give potion effects to players who respawn

Discussion in 'Plugin Development' started by dylanhansch, Mar 21, 2014.

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

    dylanhansch

    Hello, I am trying to code a plugin that gives certain potion effects to players who re-spawn after they die. But all it does is sends the player to "getSpawn()". It doesn't give them the effects. Here is my code...

    Code:java
    1. @EventHandler
    2. public boolean onPlayerRespawn(PlayerRespawnEvent event){
    3. Player player = event.getPlayer();
    4.  
    5. event.setRespawnLocation(getSpawn());
    6.  
    7. if(this.getConfig().getBoolean("hub-features.speedboost") == true){
    8. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 10000000, 2));
    9. }else{
    10. return false;
    11. }
    12. if(this.getConfig().getBoolean("hub-features.jumpboost") == true){
    13. player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 10000000, 2));
    14. player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 10000000, 254));
    15.  
    16. }else{
    17. return false;
    18. }
    19. return false;
    20. }
     
  2. Offline

    willeb96

    I think you might have to schedule your potion effects to be applied one tick later.
     
  3. Offline

    dylanhansch

    Okay, how would I schedule that?
     
  4. Offline

    TnT

Thread Status:
Not open for further replies.

Share This Page