Bug au chargement + ajout de /animal info
Le commandManager faisait planter le chargment du plugin car la commande /region de WorldGuard n'était pas encore chargé à ce moment La commande /animal info permet de donner des informations sur l'animal sélectionné (si l'utilisateur en a les droits)
This commit is contained in:
parent
3d6a970196
commit
b4f15816b4
@ -4,9 +4,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection.TamedEntityProtectManager;
|
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.OnlinePlayer;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
import net.mc_pandacraft.java.util.StringUtil;
|
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.EntityHorse;
|
||||||
import net.minecraft.server.v1_7_R1.GenericAttributes;
|
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.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftHorse;
|
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.Horse;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
@ -62,15 +67,16 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TamedEntityProtectManager tepm = plugin.tamedEntityProtectManager;
|
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 (!op.hasPermission("pandacraft.animal.admin")) {
|
||||||
if (animal.getOwner() == null) {
|
if (tameable.getOwner() == null) {
|
||||||
p.sendMessage(ChatColor.RED+animalName+ChatColor.RED+" n'appartient à personne");
|
p.sendMessage(ChatColor.RED+animalName+ChatColor.RED+" n'appartient à personne");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!animal.getOwner().equals(p)) {
|
if (!tameable.getOwner().equals(p)) {
|
||||||
p.sendMessage(ChatColor.RED+animalName+ChatColor.RED+" n'est pas à vous");
|
p.sendMessage(ChatColor.RED+animalName+ChatColor.RED+" n'est pas à vous");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -88,7 +94,7 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
animal.setOwner(newOwner);
|
tameable.setOwner(newOwner);
|
||||||
p.sendMessage(ChatColor.GREEN+"Vous venez de donner "+animalName+ChatColor.GREEN+" à "+newOwner.getDisplayName());
|
p.sendMessage(ChatColor.GREEN+"Vous venez de donner "+animalName+ChatColor.GREEN+" à "+newOwner.getDisplayName());
|
||||||
op.resetAnimalSelection();
|
op.resetAnimalSelection();
|
||||||
|
|
||||||
@ -104,11 +110,11 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
if (args.length >= 3 && args[1].equalsIgnoreCase("hauteur_saut")) {
|
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");
|
p.sendMessage(ChatColor.RED+"Vous ne pouvez pas modifier la hauteur de saut de cet animal");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Horse h = (Horse)animal;
|
Horse h = (Horse)tameable;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
double jump = Double.parseDouble(args[2]);
|
double jump = Double.parseDouble(args[2]);
|
||||||
@ -124,12 +130,12 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
|||||||
}
|
}
|
||||||
if (args.length >= 3 && args[0].equalsIgnoreCase("vitesse")) {
|
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");
|
p.sendMessage(ChatColor.RED+"Vous ne pouvez pas modifier la vitesse de cet animal");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Horse h = (Horse)animal;
|
Horse h = (Horse)tameable;
|
||||||
EntityHorse horse = ((CraftHorse)h).getHandle();
|
EntityHorse horse = ((CraftHorse)h).getHandle();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -146,6 +152,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) {
|
if (op.getSelectedAnimal() != null) {
|
||||||
proposal_first_arg.add("donner");
|
proposal_first_arg.add("donner");
|
||||||
proposal_first_arg.add("modifier");
|
proposal_first_arg.add("modifier");
|
||||||
|
proposal_first_arg.add("info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public class PandacraftUtilsCommandsManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +64,12 @@ public class PandacraftUtilsCommandsManager {
|
|||||||
add(new CommandReply());
|
add(new CommandReply());
|
||||||
|
|
||||||
// complétion des commandes des autres plugins
|
// 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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user