Tab completion

This commit is contained in:
ZeroEpoch1969 2019-01-28 21:57:41 -07:00
parent d7931793f1
commit 5b2334c60f
No known key found for this signature in database
GPG Key ID: A7BAB4E14F089CF3
25 changed files with 632 additions and 22 deletions

View File

@ -3,7 +3,9 @@ package me.totalfreedom.totalfreedommod.admin;
import com.google.common.base.Function;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@ -129,6 +131,16 @@ public class AdminList extends FreedomService
return isAdmin(sender);
}
public List<String> getActiveAdminNames()
{
List<String> names = new ArrayList();
for (Admin admin : activeAdmins)
{
names.add(admin.getName());
}
return names;
}
public boolean isAdmin(CommandSender sender)
{
if (!(sender instanceof Player))

View File

@ -1,5 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -42,4 +45,15 @@ public class Command_adminmode extends FreedomCommand
return false;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
{
return Arrays.asList("on", "off");
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime;
@ -11,7 +15,7 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Go to the AdminWorld.",
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]",
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "aw")
public class Command_adminworld extends FreedomCommand
{
@ -245,4 +249,47 @@ public class Command_adminworld extends FreedomCommand
}
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return Collections.emptyList();
}
if (args.length == 1)
{
return Arrays.asList("guest", "time", "weather");
}
else if (args.length == 2)
{
if (args[0].equals("guest"))
{
return Arrays.asList("add", "remove", "list", "purge");
}
else if (args[0].equals("time"))
{
return Arrays.asList("morning", "noon", "evening", "night");
}
else if (args[0].equals("weather"))
{
return Arrays.asList("off", "rain", "storm");
}
}
else if (args.length == 3)
{
if (args[0].equals("guest"))
{
if (args[1].equals("add"))
{
return FUtil.getPlayerList();
}
else if (args[1].equals("remove"))
{
return plugin.wm.adminworld.getGuestList();
}
}
}
return Collections.emptyList();
}
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Lists all possible enchantments.", usage = "/<command>")
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
public class Command_attributelist extends FreedomCommand
{

View File

@ -1,5 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -12,7 +16,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [skull | block] [blockname | playername]")
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [skull | block] [playername | blockname]")
public class Command_cage extends FreedomCommand
{
@ -106,4 +110,41 @@ public class Command_cage extends FreedomCommand
}
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return null;
}
if (args.length == 1)
{
List<String> arguments = new ArrayList<>();
arguments.add("purge");
arguments.addAll(FUtil.getPlayerList());
return arguments;
}
else if (args.length == 2)
{
if (!args[0].equals("purge"))
{
return Arrays.asList("off", "skull", "block");
}
}
else if (args.length == 3)
{
if (args[1].equals("block"))
{
return FUtil.getAllMaterialNames();
}
else if (args[1].equals("skull"))
{
return FUtil.getPlayerList();
}
}
return Collections.emptyList();
}
}

View File

@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> <carts>", aliases = "ew,rd")
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command>", aliases = "ew,rd")
public class Command_entitywipe extends FreedomCommand
{

View File

@ -1,6 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.player.PlayerData;
@ -157,4 +159,19 @@ public class Command_gtfo extends FreedomCommand
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return null;
}
if (args.length == 1)
{
return FUtil.getPlayerList();
}
return Collections.emptyList();
}
}

View File

@ -1,6 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -63,4 +65,15 @@ public class Command_invis extends FreedomCommand
}
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender))
{
return Arrays.asList("clear");
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,13 @@
package me.totalfreedom.totalfreedommod.command;
import com.google.common.collect.ContiguousSet;
import com.google.common.collect.DiscreteDomain;
import com.google.common.collect.Range;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.DoubleStream;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -93,4 +101,30 @@ public class Command_jumppads extends FreedomCommand
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return Collections.emptyList();
}
if (args.length == 1)
{
return Arrays.asList("on", "off", "info", "sideways", "strength");
}
else if (args.length == 2)
{
if (args[0].equals("sideways"))
{
return Arrays.asList("on", "off");
}
else if (args[0].equals("strength"))
{
return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
}
}
return Collections.emptyList();
}
}

View File

@ -1,6 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.world.WorldTime;
import me.totalfreedom.totalfreedommod.world.WorldWeather;
import org.bukkit.World;
@ -10,7 +14,7 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Go to the MasterBuilderWorld.",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | on | storm>]",
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
aliases = "mbw,mbworld")
public class Command_masterbuilderworld extends FreedomCommand
{
@ -146,6 +150,31 @@ public class Command_masterbuilderworld extends FreedomCommand
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return Collections.emptyList();
}
if (args.length == 1)
{
return Arrays.asList("time", "weather");
}
else if (args.length == 2)
{
if (args[0].equals("time"))
{
return Arrays.asList("morning", "noon", "evening", "night");
}
else if (args[0].equals("weather"))
{
return Arrays.asList("off", "rain", "storm");
}
}
return Collections.emptyList();
}
// TODO: Redo this properly
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
{

View File

@ -1,6 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
@ -204,5 +208,44 @@ public class Command_mbconfig extends FreedomCommand
}
}
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (sender instanceof Player)
{
if (args.length == 1)
{
List<String> arguments = new ArrayList<>();
arguments.add("list");
if (plugin.al.isAdmin(sender))
{
arguments.add("info");
}
return arguments;
}
else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
{
return plugin.al.getActiveAdminNames();
}
return Collections.emptyList();
}
else
{
if (args.length == 1)
{
return Arrays.asList("add", "remove", "reload", "list", "info");
}
else if (args.length == 2)
{
if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
{
return FUtil.getPlayerList();
}
}
}
return Collections.emptyList();
}
}

View File

@ -1,6 +1,10 @@
package me.totalfreedom.totalfreedommod.command;
import com.sk89q.worldedit.blocks.metadata.MobType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.util.Groups;
@ -80,4 +84,25 @@ public class Command_mobpurge extends FreedomCommand
return removed;
}
public static List<String> getAllMobNames()
{
List<String> names = new ArrayList<>();
for (EntityType entityType : Groups.MOB_TYPES)
{
names.add(entityType.name());
}
return names;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
return getAllMobNames();
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -67,4 +70,15 @@ public class Command_onlinemode extends FreedomCommand
}
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
{
return Arrays.asList("on", "off");
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
import net.pravian.aero.util.Ips;
@ -97,4 +100,14 @@ public class Command_playerverify extends FreedomCommand
return false;
}
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
return Arrays.asList("enable", "disable", "status", "clearips");
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@ -126,6 +130,39 @@ public class Command_plugincontrol extends FreedomCommand
return false;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return Collections.emptyList();
}
if (args.length == 1)
{
return Arrays.asList("enable", "disable", "reload", "list");
}
else if (args.length == 2)
{
if (!args[0].equals("list"))
{
return getAllPluginNames();
}
}
return Collections.emptyList();
}
public List<String> getAllPluginNames()
{
List<String> names = new ArrayList<>();
for (Plugin plugin : server.getPluginManager().getPlugins())
{
names.add(plugin.getName());
}
names.remove(plugin.getName());
return names;
}
public Plugin getPlugin(String name)
{
for (Plugin serverPlugin : server.getPluginManager().getPlugins())

View File

@ -1,6 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -71,7 +73,7 @@ public class Command_potion extends FreedomCommand
{
if (!plugin.al.isAdmin(sender))
{
msg("Only superadmins can clear potion effects from other players.");
msg(ChatColor.RED + "Only admins can clear potion effects from other players.");
return true;
}
}
@ -115,7 +117,7 @@ public class Command_potion extends FreedomCommand
{
if (!plugin.al.isAdmin(sender))
{
sender.sendMessage("Only superadmins can apply potion effects to other players.");
sender.sendMessage(ChatColor.RED + "Only admins can apply potion effects to other players.");
return true;
}
}
@ -177,4 +179,72 @@ public class Command_potion extends FreedomCommand
}
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
List<String> arguments = new ArrayList<>();
arguments.addAll(Arrays.asList("list", "clear", "add"));
if (plugin.al.isAdmin(sender))
{
arguments.add("clearall");
}
return arguments;
}
else if (args.length == 2)
{
if (args[0].equals("clear"))
{
if (plugin.al.isAdmin(sender))
{
return FUtil.getPlayerList();
}
}
else if (args[0].equals("add"))
{
return getAllPotionTypes();
}
}
else if (args.length == 3)
{
if (args[0].equals("add"))
{
return Arrays.asList("<duration>");
}
}
else if (args.length == 4)
{
if (args[0].equals("add"))
{
return Arrays.asList("<amplifier>");
}
}
else if (args.length == 5 && plugin.al.isAdmin(sender))
{
if (args[0].equals("add"))
{
return FUtil.getPlayerList();
}
}
return Collections.emptyList();
}
public List<String> getAllPotionTypes()
{
List<String> types = new ArrayList<>();
for (PotionEffectType potionEffectType : PotionEffectType.values())
{
if (potionEffectType != null)
{
types.add(potionEffectType.getName());
}
}
return types;
}
}

View File

@ -1,6 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import me.totalfreedom.totalfreedommod.admin.Admin;
@ -84,7 +86,7 @@ public class Command_saconfig extends FreedomCommand
if (!rank.isAtLeast(Rank.SUPER_ADMIN))
{
msg("Rank must be superadmin or higher.", ChatColor.RED);
msg("Rank must be Super Admin or higher.", ChatColor.RED);
return true;
}
@ -304,9 +306,46 @@ public class Command_saconfig extends FreedomCommand
}
}
/*@Override
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
return Arrays.asList("list", "clean", "reload", "setrank", "add", "remove", "info");
}*/
if (sender instanceof Player)
{
if (args.length == 1)
{
List<String> arguments = new ArrayList<>();
arguments.add("list");
if (plugin.al.isAdmin(sender))
{
arguments.add("info");
}
return arguments;
}
else if (args.length == 2 && args[0].equals("info") && plugin.al.isAdmin(sender))
{
return plugin.al.getActiveAdminNames();
}
return Collections.emptyList();
}
else
{
if (args.length == 1)
{
return Arrays.asList("add", "remove", "clean", "reload", "setrank", "info", "list");
}
else if (args.length == 2)
{
if (args[0].equals("add") || args[0].equals("remove") || args[0].equals("setrank") || args[0].equals("info"))
{
return FUtil.getPlayerList();
}
}
else if (args.length == 3 && args[0].equals("setrank"))
{
return Arrays.asList("super_admin", "telnet_admin", "senior_admin");
}
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.punishments.Punishment;
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
@ -150,4 +154,23 @@ public class Command_stfu extends FreedomCommand
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (!plugin.al.isAdmin(sender))
{
return null;
}
if (args.length == 1)
{
List<String> arguments = new ArrayList<>();
arguments.addAll(FUtil.getPlayerList());
arguments.addAll(Arrays.asList("list", "purge", "all"));
return arguments;
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.GameRuleHandler;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.rank.Rank;
@ -160,5 +163,18 @@ public class Command_toggle extends FreedomCommand
{
msg(name + " now " + (entry.setBoolean(!entry.getBoolean()) ? "enabled." : "disabled."));
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
return Arrays.asList(
"waterplace", "fireplace", "lavaplace", "fluidspread", "lavadmg", "firespread", "frostwalk",
"firework", "prelog", "lockdown", "petprotect", "entitywipe", "nonuke", "explosives");
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -27,4 +30,15 @@ public class Command_trail extends FreedomCommand
return true;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1 && plugin.al.isAdmin(sender))
{
return Arrays.asList("off");
}
return Collections.emptyList();
}
}

View File

@ -1,5 +1,9 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
import me.totalfreedom.totalfreedommod.util.FUtil;
@ -160,4 +164,46 @@ public class Command_whitelist extends FreedomCommand
}
return false;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
List<String> arguments = new ArrayList<>();
arguments.addAll(Arrays.asList("list", "count"));
if (plugin.al.isAdmin(sender))
{
arguments.addAll(Arrays.asList("on", "off", "add", "remove", "addall"));
if (!(sender instanceof Player))
{
arguments.add("purge");
}
}
return arguments;
}
else if (args.length == 2 && plugin.al.isAdmin(sender))
{
if (args[0].equals("add"))
{
return FUtil.getPlayerList();
}
else if (args[0].equals("remove"))
{
return getWhitelistedNames();
}
}
return Collections.emptyList();
}
public List<String> getWhitelistedNames()
{
List<String> names = new ArrayList<>();
for (Object name : plugin.si.getWhitelisted())
{
names.add(String.valueOf(name));
}
return names;
}
}

View File

@ -1,5 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
@ -32,10 +35,6 @@ public class Command_wiperegions extends FreedomCommand
msg("There is no world named \"" + args[0] + "\"", ChatColor.RED);
return true;
}
if (world.equals(plugin.wm.adminworld.getWorld()))
{
checkRank(Rank.SENIOR_ADMIN);
}
int regionsWiped = plugin.wgb.wipeRegions(world);
@ -51,4 +50,25 @@ public class Command_wiperegions extends FreedomCommand
return true;
}
}
public List<String> getAllWorldNames()
{
List<String> names = new ArrayList<>();
for (World world : server.getWorlds())
{
names.add(world.getName());
}
return names;
}
@Override
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
{
if (args.length == 1)
{
return getAllWorldNames();
}
return Collections.emptyList();
}
}

View File

@ -1,9 +1,8 @@
package me.totalfreedom.totalfreedommod.command;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.User;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
@ -28,7 +27,6 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static final String PLAYER_NOT_FOUND = ChatColor.GRAY + "Player not found!";
//
@Getter
@ -74,13 +72,27 @@ public abstract class FreedomCommand extends AbstractCommandBase<TotalFreedomMod
}
}
protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
/*@Override
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
{
return Arrays.asList("x", "d");
return null;
}*/
// Doesn't need to do any starts-with checks
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args) {
return null;
}
@Override
public List<String> tabComplete(CommandSender sender, Command command, String alias, String[] args)
{
List<String> options = getTabCompleteOptions(sender, command, alias, args);
if (options == null) {
return null;
}
return StringUtil.copyPartialMatches(args[args.length - 1], options, Lists.<String>newArrayList());
}
protected abstract boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole);
protected void checkConsole()
{

View File

@ -29,6 +29,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.Material;
public class FUtil
{
@ -84,6 +85,26 @@ public class FUtil
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name);
}
public static List<String> getPlayerList()
{
List<String> names = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers())
{
names.add(player.getName());
}
return names;
}
public static List<String> getAllMaterialNames()
{
List<String> names = new ArrayList<>();
for (Material material : Material.values())
{
names.add(material.name());
}
return names;
}
public static void bcastMsg(String message, ChatColor color)
{
FLog.info(message, true);

View File

@ -107,6 +107,16 @@ public final class AdminWorld extends CustomWorld
return player;
}
public List<String> getGuestList()
{
List<String> guests = new ArrayList<>();
for (Player guest : guestList.keySet())
{
guests.add(guest.getName());
}
return guests;
}
public Player removeGuest(String partialName)
{
partialName = partialName.toLowerCase();