diff options
Diffstat (limited to 'me/Danker/utils')
-rw-r--r-- | me/Danker/utils/CommandUtils.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/me/Danker/utils/CommandUtils.java b/me/Danker/utils/CommandUtils.java new file mode 100644 index 0000000..7b10ad5 --- /dev/null +++ b/me/Danker/utils/CommandUtils.java @@ -0,0 +1,23 @@ +package me.Danker.utils; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; + +public class CommandUtils { + public static List<String> getMatchingPlayers(String arg) { + List<String> matchingPlayers = new ArrayList<>(); + List<EntityPlayer> players = Minecraft.getMinecraft().theWorld.playerEntities; + + for (EntityPlayer player : players) { + String playerName = player.getName(); + if (playerName.toLowerCase().startsWith(arg.toLowerCase())) { + matchingPlayers.add(playerName); + } + } + + return matchingPlayers; + } +} |