Auto complete for commands.

This commit is contained in:
Brianna 2019-10-04 11:19:41 -04:00
parent 34fe405312
commit 272a77a205
2 changed files with 25 additions and 5 deletions

View File

@ -8,9 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.*;
public class CommandBoost extends AbstractCommand {
@ -57,7 +55,18 @@ public class CommandBoost extends AbstractCommand {
}
@Override
protected List<String> onTab(CommandSender commandSender, String... strings) {
protected List<String> onTab(CommandSender sender, String... args) {
if (args.length == 1) {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
return players;
} else if (args.length == 2) {
return Arrays.asList("1", "2", "3", "4", "5");
} else if (args.length == 3) {
return Arrays.asList("1m", "1h", "1d");
}
return null;
}

View File

@ -7,6 +7,8 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommandGiveFarmItem extends AbstractCommand {
@ -55,7 +57,16 @@ public class CommandGiveFarmItem extends AbstractCommand {
}
@Override
protected List<String> onTab(CommandSender commandSender, String... strings) {
protected List<String> onTab(CommandSender sender, String... args) {
if (args.length == 1) {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
return players;
} else if (args.length == 2) {
return Arrays.asList("1", "2", "3", "4", "5");
}
return null;
}