43 lines
1.2 KiB
Java
43 lines
1.2 KiB
Java
![]() |
package game.command;
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
public String[] getCompletions(CommandEnvironment env) {
|
||
|
List<String> comp = Lists.newArrayList(env.getServer().getAllUsernames());
|
||
|
comp.add("*");
|
||
|
return comp.toArray(new String[comp.size()]);
|
||
|
}
|
||
|
|
||
|
public Class<?> getTypeClass() {
|
||
|
return List.class;
|
||
|
}
|
||
|
}
|