From 0b6b288c8d5580b71cf48376247e922d97923649 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Mon, 16 Feb 2015 21:48:02 -0500 Subject: [PATCH] Ajout de la commande /muco --- make_jar.jardesc | 2 +- resources/plugin.yml | 20 +- .../plugin/pandacraftutils/ConfigManager.java | 113 +++++++++++ .../pandacraftutils/commands/CommandMuco.java | 186 ++++++++++++++++++ .../PandacraftUtilsCommandsManager.java | 1 + 5 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java diff --git a/make_jar.jardesc b/make_jar.jardesc index 9707c6c..169440d 100644 --- a/make_jar.jardesc +++ b/make_jar.jardesc @@ -1,6 +1,6 @@ - + diff --git a/resources/plugin.yml b/resources/plugin.yml index cb09018..18dd80f 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.10 +version: 3.11 @@ -78,6 +78,10 @@ commands: usage: /coeur permission: pandacraft.coeur aliases: [heart, love] + muco: + description: Succession automatique de commandes + usage: /muco [paramètres ...] + permission: pandacraft.muco @@ -166,9 +170,21 @@ permissions: #### à ajouter pandacraft.coeur: - description: Utiliser la commande animal pour tout les animaux + description: Utiliser la commande coeur default: true +#### à ajouter + pandacraft.muco: + description: Utiliser la commande muco + default: op + +# pandacraft.muco.sitemembre donne accès à la liste de commande nommé "sitemembre" +#### à ajouter + pandacraft.muco.*: + description: Utiliser toutes les listes de commandes muco + default: op + + pandacraft.antispam.exempt: description: Ignoré par le système anti-spam diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java index 777f5ea..36faa65 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/ConfigManager.java @@ -130,6 +130,7 @@ public class ConfigManager { initCommandAlias(); initAutomessages(); initWorldBorder(); + initMultiCommand(); } @@ -446,6 +447,118 @@ public class ConfigManager { + /* + * Multicommand + */ + + public Map> MultiCommand_config; + + + private void initMultiCommand() { + /* + * Format d'un String dans l'ArrayList : + * T C A /CMD ... + * - T : temps en tick, depuis l'exécution de la commande /muco + * - C : "C" si doit être exécuté en tant que la console, autre chose sinon + * - A : "A" si la commande peut être exécuté en mode asynchrone, autre chose, sinon + * (T, C et A ne peuvent pas contenir d'espace) + * /CMD ... correspond à la commande, avec le / devant. Peut contenir $1, $2, ... comme des paramètres + */ + + MultiCommand_config = new HashMap>(); + + List list = new ArrayList(); + list.add("0 - - /pex user $1 remove $2"); + list.add("1 - - /pex user $1 add $3"); + list.add("1 - - /m $1 La mise à jour de votre grade est terminé :) !"); + MultiCommand_config.put("gradejoueur", list); + + list = new ArrayList(); + list.add("0 - - /region select arenespleef_niv1"); + list.add("1 - - //replace 0 87"); + list.add("2 - - /region select arenespleef_niv2"); + list.add("3 - - //replace 0 87"); + list.add("4 - - /region select arenespleef_niv3"); + list.add("5 - - //replace 0 87"); + list.add("6 - - /region select arenespleef_niv4"); + list.add("7 - - //replace 0 87"); + list.add("8 - - /region select arenespleef_niv5"); + list.add("9 - - //replace 0 87"); + list.add("10 - - /region select arenespleef_niv6"); + list.add("11 - - //replace 0 87"); + list.add("12 - - /region select arenespleef_niv7"); + list.add("13 - - //replace 0 87"); + list.add("14 - - /region select arenespleef_niv8"); + list.add("15 - - //replace 0 87"); + MultiCommand_config.put("arenespleef_reparer", list); + + list = new ArrayList(); + list.add("0 - - /pex user $1 group add premium"); + list.add("0 - - /m $1 Vous venez de passer Premium :)"); + MultiCommand_config.put("addpremium", list); + + list = new ArrayList(); + list.add("0 - - /pex user $1 group remove premium"); + MultiCommand_config.put("delpremium", list); + + list = new ArrayList(); + list.add("0 - - /pex user $1 group add ultimate"); + list.add("0 - - /m $1 Vous venez de recevoir le grade Ultimate, félicitation :)"); + MultiCommand_config.put("addultimate", list); + + list = new ArrayList(); + list.add("0 - - /pex user $1 group remove ultimate"); + list.add("0 - - /mail send $1 Vous venez de perdre votre grade Ultimate et tous ses avantages car la durée est écoulée."); + list.add("1 - - /mail send $1 Si vous voulez encore en profiter, rendez vous sur http://mc-pandacraft.net/?p=ultimate"); + MultiCommand_config.put("delultimate", list); + + list = new ArrayList(); + list.add("0 - - /region select arenepvp_solarene"); + list.add("1 - - //replace 11 20"); + MultiCommand_config.put("arenepvp_proteger_lave", list); + + list = new ArrayList(); + list.add("0 - - /region select arenepvp_solarene"); + list.add("1 - - //replace 20 11"); + MultiCommand_config.put("arenepvp_remettre_lave", list); + + list = new ArrayList(); + list.add("0 - - /region select arenepvp_toit"); + list.add("1 - - //replace 20 98"); + MultiCommand_config.put("arenepvp_fermer_fenetre", list); + + list = new ArrayList(); + list.add("0 - - /region select arenepvp_toit"); + list.add("1 - - //replace 98 20"); + MultiCommand_config.put("arenepvp_ouvrir_fenetre", list); + + list = new ArrayList(); + list.add("0 C - /broadcast &7Site Web :&a https://www.mc-pandacraft.net/"); + MultiCommand_config.put("site", list); + + list = new ArrayList(); + list.add("0 C - /broadcast &7Devenir &f[&bMembre&f]&7 :&a http://mc-pandacraft.net/?id=12"); + MultiCommand_config.put("sitemembre", list); + + list = new ArrayList(); + list.add("0 C - /broadcast Grade &f[&eUltimate&f]&7 :&a http://mc-pandacraft.net/?p=ultimate"); + MultiCommand_config.put("siteultimate", list); + + list = new ArrayList(); + list.add("0 - - /mv regen Survival_the_end"); + list.add("1 - - /mvconfirm"); + MultiCommand_config.put("new_ender", list); + + list = new ArrayList(); + list.add("0 - - /mv regen Survival_nether"); + list.add("1 - - /mvconfirm"); + list.add("600 - - /mv regen Faction_nether"); + list.add("601 - - /mvconfirm"); + MultiCommand_config.put("new_nether", list); + + } + + diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java new file mode 100644 index 0000000..a4de716 --- /dev/null +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandMuco.java @@ -0,0 +1,186 @@ +package net.mc_pandacraft.java.plugin.pandacraftutils.commands; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.mc_pandacraft.java.plugin.pandacraftutils.ConfigManager; +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.scheduler.BukkitScheduler; + +public class CommandMuco extends AbstractCommandExecutor { + + public CommandMuco() { + super("muco"); + } + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String label, + String[] args) { + + if (args.length == 0) { + sendMucoLists(sender); + return true; + } + + Map> lists = ConfigManager.getInstance().MultiCommand_config; + + + String list_name = args[0].toLowerCase(); + + if (!lists.containsKey(list_name)) { + sender.sendMessage(ChatColor.RED+"La sous commande '"+list_name+"' n'existe pas"); + return true; + } + + if ((sender instanceof Player) && !OnlinePlayerManager.get((Player)sender).hasPermission("pandacraft.muco."+list_name)) { + sender.sendMessage(ChatColor.RED+"Vous n'avez pas la permission pour la sous commande '"+list_name+"'"); + return true; + } + + + List params = new ArrayList(); + + + for (int i=1; i list = lists.get(list_name); + + for (String line : list) { + executeListedCommand(sender, line, params); + } + + + return true; + } + + + + + + + + + + + private void sendMucoLists(CommandSender sender) { + + List list_names = getMucoLists((sender instanceof Player)?OnlinePlayerManager.get((Player) sender):null); + + sender.sendMessage(ChatColor.GOLD+"----- Liste des commandes /muco -----"); + + for (String name : list_names) { + sender.sendMessage(" - "+ChatColor.GRAY+name); + } + + sender.sendMessage(ChatColor.GOLD+"-----------------------------------"); + } + + + private List getMucoLists(OnlinePlayer permittedPlayer) { + Set list_names = ConfigManager.getInstance().MultiCommand_config.keySet(); + + List retList = new ArrayList(); + + for (String name : list_names) { + if (permittedPlayer == null || permittedPlayer.hasPermission("pandacraft.muco."+name)) + retList.add(name); + } + + return retList; + } + + + + + + + + + + + + + + + + + + + + private void executeListedCommand(CommandSender sender, String line, List params) { + String[] args = line.split(" ", 4); + + if (args.length != 4) { + plugin.getLogger().warning("/muco : bad format for "+ChatColor.ITALIC+line); + return; + } + + long time; + + try { + time = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + plugin.getLogger().warning("/muco : bad format for "+ChatColor.ITALIC+line); + return; + } + + boolean console = args[1].equalsIgnoreCase("c"); + boolean async = args[2].equalsIgnoreCase("a"); + + if (!args[3].startsWith("/")) { + plugin.getLogger().warning("/muco : bad format for "+ChatColor.ITALIC+line); + return; + } + + String cmd = args[3].substring(1); + + for (int i=0; i