2025-03-26 12:22:32 +01:00
|
|
|
package game.command;
|
|
|
|
|
2025-03-26 13:27:17 +01:00
|
|
|
import java.util.Collection;
|
2025-03-26 12:22:32 +01:00
|
|
|
import java.util.List;
|
|
|
|
import game.collect.Lists;
|
|
|
|
import game.network.Player;
|
|
|
|
|
|
|
|
public class PlayerListParser extends PlayerParser {
|
|
|
|
public PlayerListParser(String name, boolean useSender) {
|
|
|
|
super(name, useSender);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object parse(CommandEnvironment env, String input) {
|
|
|
|
if(input.equals("*")) {
|
|
|
|
if(env.getServer().getPlayers().isEmpty())
|
|
|
|
throw new RunException("Keine Spieler gefunden");
|
|
|
|
return Lists.newArrayList(env.getServer().getPlayers());
|
|
|
|
}
|
|
|
|
return Lists.newArrayList((Player)super.parse(env, input));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object getDefault(CommandEnvironment env) {
|
|
|
|
Player net = (Player)super.getDefault(env);
|
|
|
|
return net == null ? null : Lists.newArrayList(net);
|
|
|
|
}
|
|
|
|
|
2025-03-26 13:27:17 +01:00
|
|
|
public Collection<String> getCompletions(CommandEnvironment env) {
|
|
|
|
Collection<String> comp = super.getCompletions(env);
|
2025-03-26 12:22:32 +01:00
|
|
|
comp.add("*");
|
2025-03-26 13:27:17 +01:00
|
|
|
return comp;
|
2025-03-26 12:22:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public Class<?> getTypeClass() {
|
|
|
|
return List.class;
|
|
|
|
}
|
|
|
|
}
|