package game.command; import java.util.Collection; import java.util.List; import java.util.Set; import game.collect.Lists; import game.collect.Sets; 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()); } Set set = Sets.newHashSet(); for(String tok : input.split(",", -1)) { set.add((Player)super.parse(env, tok)); } if(set.isEmpty()) throw new RunException("Keine Spieler gefunden"); return Lists.newArrayList(set); } public Object getDefault(CommandEnvironment env) { Player net = (Player)super.getDefault(env); return net == null ? null : Lists.newArrayList(net); } public Collection getCompletions(CommandEnvironment env) { Collection comp = super.getCompletions(env); comp.add("*"); return comp; } public Class getTypeClass() { return List.class; } }