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.entity.Entity;
|
|
|
|
import game.entity.npc.EntityNPC;
|
|
|
|
import game.network.Player;
|
|
|
|
|
|
|
|
public class PlayerEntityListParser extends PlayerEntityParser {
|
|
|
|
public PlayerEntityListParser(String name, boolean useSender) {
|
|
|
|
super(name, useSender);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object parse(CommandEnvironment env, String input) {
|
|
|
|
if(input.equals("*")) {
|
|
|
|
List<Entity> list = Lists.newArrayList();
|
|
|
|
for(Player plr : env.getServer().getPlayers()) {
|
|
|
|
if(plr.getEntity() != null)
|
|
|
|
list.add(plr.getEntity());
|
|
|
|
}
|
|
|
|
if(list.isEmpty())
|
|
|
|
throw new RunException("Keine Spieler gefunden");
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
return Lists.newArrayList((EntityNPC)super.parse(env, input));
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object getDefault(CommandEnvironment env) {
|
|
|
|
EntityNPC entity = (EntityNPC)super.getDefault(env);
|
|
|
|
return entity == null ? null : Lists.newArrayList(entity);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|