Solved Items

Discussion in 'Plugin Development' started by Coopah, Apr 21, 2014.

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

    Coopah

    I'm trying to make it so when your disguised and you log out it removes potion effects and items?
    How come this doesn't work?
    Code:
    Code:java
    1. @EventHandler
    2. public void onPlayerLogout(PlayerQuitEvent e) {
    3. if (DisguiseCraft.getAPI().isDisguised(e.getPlayer())) {
    4. Player p = e.getPlayer();
    5. p.getInventory().remove(Material.SPIDER_EYE);
    6. p.getInventory().remove(Material.FEATHER);
    7. p.getInventory().remove(Material.IRON_INGOT);
    8. p.removePotionEffect(PotionEffectType.REGENERATION);
    9. p.removePotionEffect(PotionEffectType.SLOW);
    10. p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
    11. p.removePotionEffect(PotionEffectType.ABSORPTION);
    12. p.removePotionEffect(PotionEffectType.SPEED);
    13. p.removePotionEffect(PotionEffectType.JUMP);
    14. p.setFoodLevel(20);
    15.  
    16. MorphsEnable.setMetadata(e.getPlayer(), "morphtype", "none", this.plugin);
    17. Morphs.unmorph(e.getPlayer());
    18.  
    19.  
    20. }
    21. }
     
  2. Offline

    beeselmane

    What if the player doesn't have those potion effects or items?
     
  3. Offline

    Dinosaurs

    I think this tries to remove the potion effects after the player logs out, not before.
     
  4. Do A PlayerJoinEvent instead
     
Thread Status:
Not open for further replies.

Share This Page