potion cleanup
This commit is contained in:
parent
460a58e062
commit
e108650cd4
30 changed files with 644 additions and 968 deletions
|
@ -15,8 +15,8 @@ public class CommandMilk extends Command {
|
|||
this.addLivingEntityList("entities", true);
|
||||
this.setParamsOptional();
|
||||
List<Potion> potions = Lists.newArrayList();
|
||||
for(Potion potion : Potion.POTION_TYPES) {
|
||||
if(potion != null)
|
||||
for(Potion potion : Potion.values()) {
|
||||
if(!potion.isInstant())
|
||||
potions.add(potion);
|
||||
}
|
||||
this.addEnum("type", Potion.class, potions);
|
||||
|
@ -28,7 +28,7 @@ public class CommandMilk extends Command {
|
|||
int done = 0;
|
||||
for(EntityLiving entity : entities) {
|
||||
if(type != null && entity.hasEffect(type)) {
|
||||
entity.removeEffect(type.id);
|
||||
entity.removeEffect(type);
|
||||
exec.logConsole("%s von %s entfernt", type.getDisplay(), entity.getCommandName());
|
||||
done++;
|
||||
}
|
||||
|
|
|
@ -14,14 +14,13 @@ public class CommandPotion extends Command {
|
|||
super("potion");
|
||||
|
||||
List<Potion> potions = Lists.newArrayList();
|
||||
for(Potion potion : Potion.POTION_TYPES) {
|
||||
if(potion != null)
|
||||
potions.add(potion);
|
||||
for(Potion potion : Potion.values()) {
|
||||
potions.add(potion);
|
||||
}
|
||||
this.addLivingEntityList("entities", true);
|
||||
this.addEnum("type", Potion.class, potions);
|
||||
this.setParamsOptional();
|
||||
this.addInt("duration", 1, 1000000, 1000000);
|
||||
this.addInt("duration", 0, 1000000, 1000000);
|
||||
this.addInt("strength", 1, 256, 1);
|
||||
|
||||
this.addFlag("particles", 'p');
|
||||
|
@ -32,12 +31,20 @@ public class CommandPotion extends Command {
|
|||
public Object exec(CommandEnvironment env, Executor exec, List<EntityLiving> entities, Potion type, int duration, int strength, boolean particles, boolean ambient, boolean keep) {
|
||||
int done = 0;
|
||||
for(EntityLiving entity : entities) {
|
||||
PotionEffect effect = new PotionEffect(type.id, duration * 20, strength - 1, ambient, particles);
|
||||
if(entity.isPotionApplicable(effect)) {
|
||||
if(!keep && entity.hasEffect(type))
|
||||
entity.removeEffect(type.id);
|
||||
entity.addEffect(effect);
|
||||
exec.logConsole("%d * %s für %d Sekunden an %s gegeben", strength, type.getDisplay(), duration, entity.getCommandName());
|
||||
if(entity.isPotionApplicable(type)) {
|
||||
if(type.isInstant()) {
|
||||
type.onImpact(null, null, entity, strength - 1, 1.0);
|
||||
}
|
||||
else {
|
||||
PotionEffect effect = new PotionEffect(type, duration == 0 ? Integer.MAX_VALUE : (duration * 20), strength - 1, ambient, particles);
|
||||
if(!keep && entity.hasEffect(type))
|
||||
entity.removeEffect(type);
|
||||
entity.addEffect(effect);
|
||||
}
|
||||
if(type.isInstant() || duration == 0)
|
||||
exec.logConsole("%d * %s an %s gegeben", strength, type.getDisplay(), entity.getCommandName());
|
||||
else
|
||||
exec.logConsole("%d * %s für %d Sekunden an %s gegeben", strength, type.getDisplay(), duration, entity.getCommandName());
|
||||
done++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue