diff options
author | bowser0000 <bowser0000@gmail.com> | 2020-08-02 19:19:11 -0400 |
---|---|---|
committer | bowser0000 <bowser0000@gmail.com> | 2020-08-02 19:19:11 -0400 |
commit | 0243a46401f7654be2b61457880681fb027271bf (patch) | |
tree | 317f7383f1ca5c787216ab8b6f59ed2cb20675d2 /me/Danker/commands | |
parent | 4655b12ae7cf1735bc951343fe2bc9679d7cb529 (diff) | |
download | SkyblockMod-0243a46401f7654be2b61457880681fb027271bf.tar.gz SkyblockMod-0243a46401f7654be2b61457880681fb027271bf.tar.bz2 SkyblockMod-0243a46401f7654be2b61457880681fb027271bf.zip |
Add tab complete to commands
Diffstat (limited to 'me/Danker/commands')
-rw-r--r-- | me/Danker/commands/ArmourCommand.java | 10 | ||||
-rw-r--r-- | me/Danker/commands/BankCommand.java | 10 | ||||
-rw-r--r-- | me/Danker/commands/DisplayCommand.java | 21 | ||||
-rw-r--r-- | me/Danker/commands/GuildOfCommand.java | 12 | ||||
-rw-r--r-- | me/Danker/commands/LootCommand.java | 12 | ||||
-rw-r--r-- | me/Danker/commands/MoveCommand.java | 11 | ||||
-rw-r--r-- | me/Danker/commands/PetsCommand.java | 10 | ||||
-rw-r--r-- | me/Danker/commands/SkillsCommand.java | 12 | ||||
-rw-r--r-- | me/Danker/commands/SlayerCommand.java | 13 | ||||
-rw-r--r-- | me/Danker/commands/ToggleCommand.java | 11 |
10 files changed, 116 insertions, 6 deletions
diff --git a/me/Danker/commands/ArmourCommand.java b/me/Danker/commands/ArmourCommand.java index 4d89bcd..fa2973d 100644 --- a/me/Danker/commands/ArmourCommand.java +++ b/me/Danker/commands/ArmourCommand.java @@ -11,6 +11,7 @@ import com.google.gson.JsonObject; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.CommandUtils; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; @@ -18,6 +19,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -43,6 +45,14 @@ public class ArmourCommand extends CommandBase { public int getRequiredPermissionLevel() { return 0; } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return CommandUtils.getMatchingPlayers(args[0]); + } + return null; + } @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { diff --git a/me/Danker/commands/BankCommand.java b/me/Danker/commands/BankCommand.java index f569e7f..0dd00e7 100644 --- a/me/Danker/commands/BankCommand.java +++ b/me/Danker/commands/BankCommand.java @@ -8,10 +8,12 @@ import com.google.gson.JsonObject; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.CommandUtils; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -39,6 +41,14 @@ public class BankCommand extends CommandBase { } @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return CommandUtils.getMatchingPlayers(args[0]); + } + return null; + } + + @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { // MULTI THREAD DRIFTING new Thread(() -> { diff --git a/me/Danker/commands/DisplayCommand.java b/me/Danker/commands/DisplayCommand.java index e32f9d2..761aa30 100644 --- a/me/Danker/commands/DisplayCommand.java +++ b/me/Danker/commands/DisplayCommand.java @@ -1,10 +1,13 @@ package me.Danker.commands; +import java.util.List; + import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -27,6 +30,16 @@ public class DisplayCommand extends CommandBase { } @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return getListOfStringsMatchingLastWord(args, "wolf", "spider", "zombie", "fishing", "off"); + } else if (args.length == 2 && args[0].equalsIgnoreCase("fishing")) { + return getListOfStringsMatchingLastWord(args, "winter"); + } + return null; + } + + @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { final EntityPlayer player = (EntityPlayer) arg0; @@ -43,14 +56,14 @@ public class DisplayCommand extends CommandBase { display = "spider"; } else if (arg1[0].equalsIgnoreCase("zombie")) { display = "zombie"; - } else if (arg1[0].equalsIgnoreCase("off")) { - display = "off"; - } else if (arg1[0].equalsIgnoreCase("fishing")) { + } else if (arg1[0].equalsIgnoreCase("fishing")) { if (arg1.length > 1 && arg1[1].equalsIgnoreCase("winter")) { display = "fishingwinter"; } else { display = "fishing"; - } + } + } else if (arg1[0].equalsIgnoreCase("off")) { + display = "off"; } else { player.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: /display <zombie/spider/wolf/fishing/off> [winter]")); return; diff --git a/me/Danker/commands/GuildOfCommand.java b/me/Danker/commands/GuildOfCommand.java index 568c710..74fb728 100644 --- a/me/Danker/commands/GuildOfCommand.java +++ b/me/Danker/commands/GuildOfCommand.java @@ -1,15 +1,19 @@ package me.Danker.commands; +import java.util.List; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.CommandUtils; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -31,6 +35,14 @@ public class GuildOfCommand extends CommandBase { } @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return CommandUtils.getMatchingPlayers(args[0]); + } + return null; + } + + @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { // MULTI THREAD DRIFTING new Thread(() -> { diff --git a/me/Danker/commands/LootCommand.java b/me/Danker/commands/LootCommand.java index 5853cee..f93eda9 100644 --- a/me/Danker/commands/LootCommand.java +++ b/me/Danker/commands/LootCommand.java @@ -1,12 +1,14 @@ package me.Danker.commands; import java.text.NumberFormat; +import java.util.List; import java.util.Locale; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -118,6 +120,16 @@ public class LootCommand extends CommandBase { public int getRequiredPermissionLevel() { return 0; } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return getListOfStringsMatchingLastWord(args, "wolf", "spider", "zombie", "fishing"); + } else if (args.length == 2 && args[0].equalsIgnoreCase("fishing")) { + return getListOfStringsMatchingLastWord(args, "winter"); + } + return null; + } @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { diff --git a/me/Danker/commands/MoveCommand.java b/me/Danker/commands/MoveCommand.java index 797cffa..1232e18 100644 --- a/me/Danker/commands/MoveCommand.java +++ b/me/Danker/commands/MoveCommand.java @@ -1,10 +1,13 @@ package me.Danker.commands; +import java.util.List; + import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -27,6 +30,14 @@ public class MoveCommand extends CommandBase { public int getRequiredPermissionLevel() { return 0; } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return getListOfStringsMatchingLastWord(args, "coords", "display"); + } + return null; + } @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { diff --git a/me/Danker/commands/PetsCommand.java b/me/Danker/commands/PetsCommand.java index 8c53732..6d7f241 100644 --- a/me/Danker/commands/PetsCommand.java +++ b/me/Danker/commands/PetsCommand.java @@ -10,10 +10,12 @@ import com.google.gson.JsonObject; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.CommandUtils; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -68,6 +70,14 @@ public class PetsCommand extends CommandBase { public int getRequiredPermissionLevel() { return 0; } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return CommandUtils.getMatchingPlayers(args[0]); + } + return null; + } @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { diff --git a/me/Danker/commands/SkillsCommand.java b/me/Danker/commands/SkillsCommand.java index dc70175..e248757 100644 --- a/me/Danker/commands/SkillsCommand.java +++ b/me/Danker/commands/SkillsCommand.java @@ -1,13 +1,17 @@ package me.Danker.commands; +import java.util.List; + import com.google.gson.JsonObject; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.CommandUtils; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -191,6 +195,14 @@ public class SkillsCommand extends CommandBase { } @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return CommandUtils.getMatchingPlayers(args[0]); + } + return null; + } + + @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { // MULTI THREAD DRIFTING new Thread(() -> { diff --git a/me/Danker/commands/SlayerCommand.java b/me/Danker/commands/SlayerCommand.java index 8f528e6..a6fe85e 100644 --- a/me/Danker/commands/SlayerCommand.java +++ b/me/Danker/commands/SlayerCommand.java @@ -1,17 +1,18 @@ package me.Danker.commands; import java.text.NumberFormat; +import java.util.List; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import me.Danker.handlers.APIHandler; import me.Danker.handlers.ConfigHandler; +import me.Danker.utils.CommandUtils; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -33,6 +34,14 @@ public class SlayerCommand extends CommandBase { } @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return CommandUtils.getMatchingPlayers(args[0]); + } + return null; + } + + @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { // MULTI THREAD DRIFTING new Thread(() -> { diff --git a/me/Danker/commands/ToggleCommand.java b/me/Danker/commands/ToggleCommand.java index 0e893c4..218378f 100644 --- a/me/Danker/commands/ToggleCommand.java +++ b/me/Danker/commands/ToggleCommand.java @@ -1,11 +1,14 @@ package me.Danker.commands; +import java.util.List; + import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -30,6 +33,14 @@ public class ToggleCommand extends CommandBase implements ICommand { } @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length == 1) { + return getListOfStringsMatchingLastWord(args, "gparty", "coords", "golden", "list"); + } + return null; + } + + @Override public void processCommand(ICommandSender arg0, String[] arg1) throws CommandException { final EntityPlayer player = (EntityPlayer)arg0; final ConfigHandler cf = new ConfigHandler(); |