effect command
This commit is contained in:
parent
6c0bd5481f
commit
66421e806e
16 changed files with 393 additions and 16 deletions
45
java/src/game/command/commands/CommandMilk.java
Normal file
45
java/src/game/command/commands/CommandMilk.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package game.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
import game.collect.Lists;
|
||||
import game.command.ScriptEnvironment;
|
||||
import game.command.ScriptExecutable;
|
||||
import game.command.ScriptExecutor;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.potion.Potion;
|
||||
|
||||
public class CommandMilk extends ScriptExecutable {
|
||||
public CommandMilk() {
|
||||
super("milk");
|
||||
|
||||
this.addLivingEntityList("entities", true);
|
||||
this.setParamsOptional();
|
||||
List<Potion> potions = Lists.newArrayList();
|
||||
for(Potion potion : Potion.POTION_TYPES) {
|
||||
if(potion != null)
|
||||
potions.add(potion);
|
||||
}
|
||||
this.addEnum("type", Potion.class, potions);
|
||||
|
||||
this.addFlag("negative", 'n');
|
||||
}
|
||||
|
||||
public Object exec(ScriptEnvironment env, ScriptExecutor exec, List<EntityLiving> entities, Potion type, boolean negative) {
|
||||
int done = 0;
|
||||
for(EntityLiving entity : entities) {
|
||||
if(type != null && entity.hasEffect(type)) {
|
||||
entity.removeEffect(type.id);
|
||||
exec.logConsole("%s von %s entfernt", type.getDisplay(), entity.getCommandName());
|
||||
done++;
|
||||
}
|
||||
else if(type == null && !entity.getEffects().isEmpty()) {
|
||||
entity.clearEffects(negative);
|
||||
exec.logConsole("Alle Effekte von %s entfernt", entity.getCommandName());
|
||||
done++;
|
||||
}
|
||||
}
|
||||
if(done > 1)
|
||||
exec.logConsole(type == null ? "Alle Effekte von %d Objekten entfernt" : "%d Effekte entfernt", entities.size());
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue