46 lines
1.3 KiB
Java
46 lines
1.3 KiB
Java
![]() |
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;
|
||
|
}
|
||
|
}
|