mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 20:46:41 +00:00
Tab completion
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user