From 3d6a97019679c524f96a11d0d7e33fa875db9d1b Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 14 May 2015 02:14:32 +0200 Subject: [PATCH] TabCompleter pour la commande /region MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit le précédent commit du même nom ne contenait pas l'implémentation de la classe TabCompleterWorldGuardRegion --- .../TabCompleterWorldGuardRegion.java | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/TabCompleterWorldGuardRegion.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/TabCompleterWorldGuardRegion.java index 08a9e81..5f0bf80 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/TabCompleterWorldGuardRegion.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/TabCompleterWorldGuardRegion.java @@ -1,18 +1,49 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.commands; +import java.util.ArrayList; import java.util.List; +import java.util.Set; +import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; +import org.bukkit.entity.Player; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; + +/** + * Permet le l'autosuggestion des nom des cubos (qui sont compliqués et souvent long) + * @author Marc Baloup + * + */ public class TabCompleterWorldGuardRegion implements TabCompleter { @Override - public List onTabComplete(CommandSender paramCommandSender, - Command paramCommand, String paramString, - String[] paramArrayOfString) { - // TODO Auto-generated method stub + public List onTabComplete(CommandSender sender, + Command cmd, String alias, + String[] args) { + + World w = null; + + if (sender instanceof Player) + w = ((Player)sender).getWorld(); + else + return null; + + + + + + + if (args.length == 2) { + + Set regionList = WorldGuardPlugin.inst().getRegionManager(w).getRegions().keySet(); + + return AbstractCommandExecutor.getTabProposalFromToken(args[1], new ArrayList(regionList)); + + } + return null; }