commands, camera, messages, overlay, ..
This commit is contained in:
parent
75f91dbf4c
commit
d45cd7ec2c
126 changed files with 854 additions and 628 deletions
42
java/src/game/command/PlayerEntityListParser.java
Normal file
42
java/src/game/command/PlayerEntityListParser.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue