diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java index 881b084..345960e 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java @@ -4,9 +4,11 @@ import java.util.ArrayList; import java.util.List; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection.TamedEntityProtectManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import net.mc_pandacraft.java.util.StringUtil; +import net.mc_pandacraft.java.util.TimeUtil; import net.minecraft.server.v1_7_R1.EntityHorse; import net.minecraft.server.v1_7_R1.GenericAttributes; @@ -14,6 +16,9 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.craftbukkit.v1_7_R1.entity.CraftHorse; +import org.bukkit.entity.Animals; +import org.bukkit.entity.Damageable; +import org.bukkit.entity.Entity; import org.bukkit.entity.Horse; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; @@ -62,15 +67,16 @@ public class CommandAnimal extends AbstractCommandExecutor { } TamedEntityProtectManager tepm = plugin.tamedEntityProtectManager; - Tameable animal = op.getSelectedAnimal(); - String animalName = tepm.get_thisAnimal_Name(animal); + + Tameable tameable = op.getSelectedAnimal(); + String animalName = tepm.get_thisAnimal_Name(tameable); if (!op.hasPermission("pandacraft.animal.admin")) { - if (animal.getOwner() == null) { + if (tameable.getOwner() == null) { p.sendMessage(ChatColor.RED+animalName+ChatColor.RED+" n'appartient à personne"); return true; } - if (!animal.getOwner().equals(p)) { + if (!tameable.getOwner().equals(p)) { p.sendMessage(ChatColor.RED+animalName+ChatColor.RED+" n'est pas à vous"); return true; } @@ -88,7 +94,7 @@ public class CommandAnimal extends AbstractCommandExecutor { return true; } - animal.setOwner(newOwner); + tameable.setOwner(newOwner); p.sendMessage(ChatColor.GREEN+"Vous venez de donner "+animalName+ChatColor.GREEN+" à "+newOwner.getDisplayName()); op.resetAnimalSelection(); @@ -104,11 +110,11 @@ public class CommandAnimal extends AbstractCommandExecutor { if (args.length >= 3 && args[1].equalsIgnoreCase("hauteur_saut")) { - if (!(animal instanceof Horse)) { + if (!(tameable instanceof Horse)) { p.sendMessage(ChatColor.RED+"Vous ne pouvez pas modifier la hauteur de saut de cet animal"); return true; } - Horse h = (Horse)animal; + Horse h = (Horse)tameable; try { double jump = Double.parseDouble(args[2]); @@ -124,12 +130,12 @@ public class CommandAnimal extends AbstractCommandExecutor { } if (args.length >= 3 && args[0].equalsIgnoreCase("vitesse")) { - if (!(animal instanceof Horse)) { + if (!(tameable instanceof Horse)) { p.sendMessage(ChatColor.RED+"Vous ne pouvez pas modifier la vitesse de cet animal"); return true; } - Horse h = (Horse)animal; + Horse h = (Horse)tameable; EntityHorse horse = ((CraftHorse)h).getHandle(); try { @@ -145,6 +151,35 @@ public class CommandAnimal extends AbstractCommandExecutor { } } + + if (args.length >= 2 && args[0].equalsIgnoreCase("info")) { + if (!(tameable instanceof Animals)) { + p.sendMessage(ChatColor.RED+"L'entité sélectionné n'est pas un animal (erreur innatendu)"); + return true; + } + Animals animal = (Animals) tameable; + p.sendMessage(ChatColor.GOLD+"----- Information sur l'animal sélectionné -----"); + + if (tameable.getOwner() != null) + p.sendMessage(ChatColor.GOLD+"Propriétaire : "+ChatColor.RESET+(new OffPlayer(tameable.getOwner().getName()).getDisplayName())); + else + p.sendMessage(ChatColor.GOLD+"Propriétaire : "+ChatColor.GRAY+"Non apprivoisé"); + p.sendMessage(ChatColor.GOLD+"Durée de vie : "+ChatColor.GRAY+TimeUtil.durationToString(animal.getTicksLived()*50L)); + p.sendMessage(ChatColor.GOLD+"Nom personnalisé : "+ChatColor.RESET+((animal.getCustomName() != null) ? animal.getCustomName() : ChatColor.GRAY+"Aucun")); + double health = ((Damageable)animal).getHealth(); + p.sendMessage(ChatColor.GOLD+"Point de vie : "+ChatColor.GRAY+((int)((Damageable)animal).getHealth())+"/"+((int)((Damageable)animal).getMaxHealth())+ChatColor.GOLD+" (2 points = 1 "+ChatColor.RED+"♥"+ChatColor.GOLD+")"); + p.sendMessage(ChatColor.GOLD+"Respiration sous l'eau : "+ChatColor.GRAY+animal.getRemainingAir()+"/"+animal.getMaximumAir()); + + if (animal instanceof Horse) { + Horse cheval = (Horse) animal; + + p.sendMessage(ChatColor.GOLD+"Niveau de domestication : "+ChatColor.GRAY+cheval.getDomestication()+"/"+cheval.getMaxDomestication()); + p.sendMessage(ChatColor.GOLD+"Puissance de saut : "+ChatColor.GRAY+(cheval.getJumpStrength()/0.2D)); + + double speed = ((CraftHorse)cheval).getHandle().getAttributeInstance(GenericAttributes.d).getValue(); + p.sendMessage(ChatColor.GOLD+"Vitesse de course : "+ChatColor.GRAY+(speed/0.1D)); + } + } @@ -181,6 +216,7 @@ public class CommandAnimal extends AbstractCommandExecutor { if (op.getSelectedAnimal() != null) { proposal_first_arg.add("donner"); proposal_first_arg.add("modifier"); + proposal_first_arg.add("info"); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/PandacraftUtilsCommandsManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/PandacraftUtilsCommandsManager.java index ea82180..5c0659e 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/PandacraftUtilsCommandsManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/PandacraftUtilsCommandsManager.java @@ -29,7 +29,7 @@ public class PandacraftUtilsCommandsManager { - + private PandacraftUtils plugin = PandacraftUtils.getInstance(); @@ -64,7 +64,12 @@ public class PandacraftUtilsCommandsManager { add(new CommandReply()); // complétion des commandes des autres plugins - PandacraftUtils.getInstance().getServer().getPluginCommand("region").setTabCompleter(new TabCompleterWorldGuardRegion()); + plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { + @Override public void run() { + plugin.getServer().getPluginCommand("region").setTabCompleter(new TabCompleterWorldGuardRegion()); + } + }, 1L); + }