diff --git a/.classpath b/.classpath index 4d8e104..d1dc344 100644 --- a/.classpath +++ b/.classpath @@ -7,7 +7,7 @@ - + diff --git a/lib/craftbukkit-1.7.2-R0.3.src.zip b/lib/craftbukkit-1.7.2-R0.3.src.zip new file mode 100644 index 0000000..6261b9c Binary files /dev/null and b/lib/craftbukkit-1.7.2-R0.3.src.zip differ diff --git a/make_jar.jardesc b/make_jar.jardesc index d2486a2..80ab172 100644 --- a/make_jar.jardesc +++ b/make_jar.jardesc @@ -1,6 +1,6 @@ - + diff --git a/resources/plugin.yml b/resources/plugin.yml index 59f2734..1e38e0f 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils -version: 3.8 +version: 3.9 @@ -69,6 +69,10 @@ commands: description: Administration usage: /admin [reload [config|network]] permission: pandacraft.admin + animal: + description: Gestion des propriétaire des animaux apprivoisable + usage: /animal [donner ] + permission: pandacraft.animal @@ -145,6 +149,15 @@ permissions: pandacraft.admin: description: Utiliser la commande admin default: op + +#### à ajouter + pandacraft.animal: + description: Utiliser la commande animal + default: true +#### à ajouter + pandacraft.animal.admin: + description: Utiliser la commande animal pour tout les animaux + default: op pandacraft.antispam.exempt: diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java new file mode 100644 index 0000000..b669bb8 --- /dev/null +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandAnimal.java @@ -0,0 +1,76 @@ +package net.mc_pandacraft.java.plugin.pandacraftutils.commands; + +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; + +public class CommandAnimal extends AbstractCommandExecutor { + + public CommandAnimal() { + super("animal"); + } + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String label, + String[] args) { + + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED+"seul un joueur en ligne peut effectuer cette commande"); + return true; + } + + Player p = (Player) sender; + OnlinePlayer op = OnlinePlayerManager.get(p); + + if (!op.isAnimalSelectionEnabled()) { + op.enableAnimalSelection(); + p.sendMessage(ChatColor.GREEN+"Faites clic droite pour sélectionner un animal apprivoisé"); + return true; + } + // la sélection d'un animal est déjà activée + + // si je joueur n'a pas encore sélectionné d'animal + if (op.getSelectedAnimal() == null) { + p.sendMessage(ChatColor.RED+"Faites d'abord un clic droite sur un animal apprivoisé"); + return true; + } + + Tameable animal = op.getSelectedAnimal(); + + if ((animal.getOwner() == null || !animal.getOwner().equals(p)) && !op.hasPermission("pandacraft.animal.admin")) { + p.sendMessage(ChatColor.RED+"Vous n'avez pas le droit de modifier cet animal"); + return true; + } + + + + + if (args.length >= 2 && args[0].equalsIgnoreCase("donner")) { + + Player newOwner = plugin.getServer().getPlayer(args[1]); + + if (newOwner == null) { + p.sendMessage(ChatColor.RED+"Le joueur indiqué n'est pas en ligne"); + return true; + } + + + animal.setOwner(newOwner); + p.sendMessage(ChatColor.GREEN+"Vous venez de donner cet animal à "+newOwner.getDisplayName()); + + return true; + } + + + + + + return false; + } + +} diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandsManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandsManager.java index 2404864..76adab5 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandsManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandsManager.java @@ -52,6 +52,7 @@ public class CommandsManager { add(new CommandSetblock()); add(new CommandStaff()); add(new CommandSystem()); + add(new CommandAnimal()); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/cheat_protect/TamedEntityProtectManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/cheat_protect/TamedEntityProtectManager.java index 5a1c307..379a898 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/cheat_protect/TamedEntityProtectManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/cheat_protect/TamedEntityProtectManager.java @@ -1,6 +1,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules.cheat_protect; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; import org.bukkit.ChatColor; import org.bukkit.entity.AnimalTamer; @@ -54,7 +55,7 @@ public class TamedEntityProtectManager implements Listener { event.setCancelled(true); Player p = (Player) event.getEntered(); - p.sendMessage(ChatColor.RED+"Cet animal est à "+getOwnerDisplayName(tameableEntity)+", vous ne pouvez pas y toucher"); + p.sendMessage(ChatColor.RED+"Cet animal est à "+getOwnerDisplayName(tameableEntity)+ChatColor.RED+", vous ne pouvez pas y toucher"); } @@ -72,7 +73,7 @@ public class TamedEntityProtectManager implements Listener { if (animal.getOwner().equals(p)) return; event.setCancelled(true); - p.sendMessage(ChatColor.RED+"Cet animal est à "+getOwnerDisplayName(animal)+", vous ne pouvez pas y toucher"); + p.sendMessage(ChatColor.RED+"Cet animal est à "+getOwnerDisplayName(animal)+ChatColor.RED+", vous ne pouvez pas y toucher"); } @@ -86,10 +87,15 @@ public class TamedEntityProtectManager implements Listener { Tameable animal = (Tameable) event.getRightClicked(); + boolean selected = OnlinePlayerManager.get(event.getPlayer()).setSelectedAnimal(animal); + if (selected) { + event.getPlayer().sendMessage(ChatColor.GREEN+"Vous venez de sélectionner cet animal"); + } + if (animal.getOwner().equals(event.getPlayer())) return; event.setCancelled(true); - event.getPlayer().sendMessage(ChatColor.RED+"Cet animal est à "+getOwnerDisplayName(animal)+", vous ne pouvez pas y toucher"); + event.getPlayer().sendMessage(ChatColor.RED+"Cet animal est à "+getOwnerDisplayName(animal)+ChatColor.RED+", vous ne pouvez pas y toucher"); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java index 158baad..31641b5 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OnlinePlayer.java @@ -15,6 +15,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.Essentials import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; import ru.tehkode.permissions.bukkit.PermissionsEx; @@ -228,6 +229,43 @@ public class OnlinePlayer { + /* + * Sélection d'un animal aprivoisé + */ + + private Tameable selectedAnimal = null; + private boolean enableAnimalSelection = false; + + public void enableAnimalSelection() { enableAnimalSelection = true; } + + public boolean setSelectedAnimal(Tameable animal) { + if (!enableAnimalSelection || animal == null) return false; + selectedAnimal = animal; + return true; + } + + public Tameable getSelectedAnimal() { return selectedAnimal; } + public boolean isAnimalSelectionEnabled() { return enableAnimalSelection; } + + public void resetAnimalSelection() { + selectedAnimal = null; + enableAnimalSelection = false; + } + + + + + + + + + + + + + + +