Solved Player Death/Health if(...) Statement

Discussion in 'Plugin Development' started by FabeGabeMC, Dec 8, 2013.

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

    FabeGabeMC

    Hey Bukkit Community,
    I have been having this problem with my Bukkit plugin.
    I wanted to have the plugin setup so whenever a player dies or types in chat /quit, his inventory gets cleared, an Enderman Teleport sounds, Invisibility potion effect, broadcasting the player has died or has typed /quit, setting the player fly, and setting the player to Adventure mode.
    Btw the plugin is a custom Survival Games plugin.

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    2. Player p = (Player) sender;
    3. if(cmd.getName().equalsIgnoreCase("quit")) {
    4. p.setGameMode(GameMode.ADVENTURE);
    5. p.setFlying(true);
    6. p.hasPotionEffect(PotionEffectType.INVISIBILITY);
    7. p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, (float)LIMIT, (float)LIMIT);
    8. Bukkit.broadcastMessage(ChatColor.GREEN + "[GeoSG] " + ChatColor.AQUA + "Tribute " + ChatColor.GOLD + p.getName() + ChatColor.AQUA + "has forfeited!");
    9. p.getInventory().clear();
    10. }
    11. if(p.isDead()){
    12. p.setGameMode(GameMode.ADVENTURE);
    13. p.setFlying(true);
    14. p.hasPotionEffect(PotionEffectType.INVISIBILITY);
    15. p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, (float)LIMIT, (float)LIMIT);
    16. Bukkit.broadcastMessage(ChatColor.GREEN + "[GeoSG] " + ChatColor.AQUA + "Tribute " + ChatColor.GOLD + p.getName() + ChatColor.AQUA + "has fallen.");
    17. p.getInventory().clear();
    18. }
    19. return false;


    That is what I have inserted.
    Is it supposed to be like that?
    When I tested out the plugin, nothing happened.

    P.S. The command does not work.
     
  2. Offline

    user_90854156

    Did you register the command in your plugin.yml/main class?
    And uh, what is the second part of your code doing?
     
  3. Offline

    Gater12

    FabeGabeMC Probably want to do
    Code:java
    1. p.setAllowFlight(true)

    before setting the player in fly mode else the console is going to complain the player doesn't have setAllowFlight(true);
     
  4. Offline

    FabeGabeMC

    MrTang Gater12
    In the second part is where someone dies. I have added the command in the plugin.yml but nothing happens.
    I'll try that.
     
  5. Offline

    Wolfey

    Code:java
    1.  
    2. p.hasPotionEffect(PotionEffectType.INVISIBILITY);
    3.  

    This is a boolean, not a void, use p.addPotionEffect(new PotionEffect(PotionEffectType type, int duration, int amplifier));
     
  6. Offline

    FabeGabeMC

    Wolfey
    I'll try that.

    The plugin doesn't seem to work anymore :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page