Performances des chevaux modifiables
la commande /animal permet de modifier les performances des chevaux
This commit is contained in:
parent
6e7594ed87
commit
72370b6a38
@ -191,6 +191,10 @@ permissions:
|
||||
pandacraft.animal.admin:
|
||||
description: Utiliser la commande animal pour tout les animaux
|
||||
default: op
|
||||
#### à ajouter
|
||||
pandacraft.animal.modify:
|
||||
description: Utiliser la commande animal pour modifier les attributs des animaux
|
||||
default: op
|
||||
|
||||
#### à ajouter
|
||||
pandacraft.coeur:
|
||||
|
@ -6,13 +6,20 @@ import java.util.List;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection.TamedEntityProtectManager;
|
||||
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.minecraft.server.v1_7_R1.EntityHorse;
|
||||
import net.minecraft.server.v1_7_R1.GenericAttributes;
|
||||
|
||||
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.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class CommandAnimal extends AbstractCommandExecutor {
|
||||
|
||||
public CommandAnimal() {
|
||||
@ -50,7 +57,7 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
||||
// si je joueur n'a pas encore sélectionné d'animal
|
||||
if (op.getSelectedAnimal() == null) {
|
||||
p.sendMessage(ChatColor.RED+"Faites d'abord un clic droit sur un animal apprivoisé (cheval, loup ou chat)");
|
||||
p.sendMessage(ChatColor.RED+"Pour désactiver la sélection, faites "+ChatColor.GRAY+"/cubo annuler");
|
||||
p.sendMessage(ChatColor.RED+"Pour désactiver la sélection, faites "+ChatColor.GRAY+"/animal annuler");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -88,6 +95,56 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 2 && args[0].equalsIgnoreCase("modifier")) {
|
||||
|
||||
if (!op.hasPermission("pandacraft.animal.modify")) {
|
||||
p.sendMessage(ChatColor.RED+"Vous n'avez pas la permission de modifier les attributs de l'animal");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 3 && args[1].equalsIgnoreCase("hauteur_saut")) {
|
||||
|
||||
if (!(animal instanceof Horse)) {
|
||||
p.sendMessage(ChatColor.RED+"Vous ne pouvez pas modifier la hauteur de saut de cet animal");
|
||||
return true;
|
||||
}
|
||||
Horse h = (Horse)animal;
|
||||
|
||||
try {
|
||||
double jump = Double.parseDouble(args[2]);
|
||||
p.sendMessage(ChatColor.RED+"Puissance de saut du cheval défini à "+StringUtil.formatDouble(jump));
|
||||
jump *= 0.2D;
|
||||
h.setJumpStrength(jump);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage(ChatColor.RED+"La valeur indiquée est invalide");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if (args.length >= 3 && args[0].equalsIgnoreCase("vitesse")) {
|
||||
|
||||
if (!(animal instanceof Horse)) {
|
||||
p.sendMessage(ChatColor.RED+"Vous ne pouvez pas modifier la vitesse de cet animal");
|
||||
return true;
|
||||
}
|
||||
|
||||
Horse h = (Horse)animal;
|
||||
EntityHorse horse = ((CraftHorse)h).getHandle();
|
||||
|
||||
try {
|
||||
double speed = Double.valueOf(args[1]).doubleValue();
|
||||
p.sendMessage(ChatColor.RED+"Vitesse du cheval défini à "+StringUtil.formatDouble(speed));
|
||||
speed *= 0.1D;
|
||||
horse.getAttributeInstance(GenericAttributes.d).setValue(speed);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage(ChatColor.RED+"La valeur indiquée est invalide");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -97,10 +154,14 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
||||
|
||||
|
||||
|
||||
|
||||
public static final List<String> SECOND_ARG_MODIFIER = ImmutableList.of("hauteur_saut", "vitesse");
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return NO_PROPOSAL;
|
||||
}
|
||||
@ -117,8 +178,10 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
||||
proposal_first_arg.add("annuler");
|
||||
|
||||
|
||||
if (op.getSelectedAnimal() != null)
|
||||
if (op.getSelectedAnimal() != null) {
|
||||
proposal_first_arg.add("donner");
|
||||
proposal_first_arg.add("modifier");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -126,11 +189,14 @@ public class CommandAnimal extends AbstractCommandExecutor {
|
||||
if (args.length == 1) {
|
||||
return getTabProposalFromToken(args[0], proposal_first_arg);
|
||||
}
|
||||
else if (args.length > 1) {
|
||||
if (args.length == 2) {
|
||||
else if (args.length > 1 && op.getSelectedAnimal() != null) {
|
||||
if (args[0].equalsIgnoreCase("donner"))
|
||||
return getTabProposalFromToken(args[1], OnlinePlayerManager.getNamesOnlyVisible(p));
|
||||
}
|
||||
if (args.length == 2)
|
||||
return null;
|
||||
if (args[0].equalsIgnoreCase("modifier")) {
|
||||
if (args.length == 2)
|
||||
return getTabProposalFromToken(args[1], SECOND_ARG_MODIFIER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user