TabCompleter pour la commande /region

le précédent commit du même nom ne contenait pas l'implémentation de la
classe TabCompleterWorldGuardRegion
This commit is contained in:
Marc Baloup 2015-05-14 02:14:32 +02:00
parent 72370b6a38
commit 3d6a970196

View File

@ -1,18 +1,49 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.commands; package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set;
import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; 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 { public class TabCompleterWorldGuardRegion implements TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender paramCommandSender, public List<String> onTabComplete(CommandSender sender,
Command paramCommand, String paramString, Command cmd, String alias,
String[] paramArrayOfString) { String[] args) {
// TODO Auto-generated method stub
World w = null;
if (sender instanceof Player)
w = ((Player)sender).getWorld();
else
return null;
if (args.length == 2) {
Set<String> regionList = WorldGuardPlugin.inst().getRegionManager(w).getRegions().keySet();
return AbstractCommandExecutor.getTabProposalFromToken(args[1], new ArrayList<String>(regionList));
}
return null; return null;
} }