use of org.spongepowered.api.data.manipulator.mutable.PotionEffectData in project Skree by Skelril.
the class Fangz method setupFangz.
private void setupFangz() {
Sponge.getEventManager().registerListeners(SkreePlugin.inst(), new BossListener<>(bossManager, Spider.class));
List<Instruction<BindCondition, Boss<Spider, WildernessBossDetail>>> bindProcessor = bossManager.getBindProcessor();
bindProcessor.add((condition, boss) -> {
Optional<Spider> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Spider bossEnt = optBossEnt.get();
bossEnt.offer(Keys.DISPLAY_NAME, Text.of("Fangz"));
double bossHealth = 20 * 50 * boss.getDetail().getLevel();
setMaxHealth(bossEnt, bossHealth, true);
}
return Optional.empty();
});
List<Instruction<UnbindCondition, Boss<Spider, WildernessBossDetail>>> unbindProcessor = bossManager.getUnbindProcessor();
unbindProcessor.add((condition, boss) -> {
Optional<Spider> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Spider bossEnt = optBossEnt.get();
CuboidContainmentPredicate predicate = new CuboidContainmentPredicate(bossEnt.getLocation().getPosition(), 3, 2, 3);
for (Entity aEntity : bossEnt.getNearbyEntities((entity) -> predicate.test(entity.getLocation().getPosition()))) {
Optional<PotionEffectData> optPotionEffects = aEntity.getOrCreate(PotionEffectData.class);
if (!optPotionEffects.isPresent()) {
continue;
}
PotionEffectData potionEffects = optPotionEffects.get();
potionEffects.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, 20 * 30));
potionEffects.addElement(PotionEffect.of(PotionEffectTypes.POISON, 2, 20 * 30));
aEntity.offer(potionEffects);
}
}
return Optional.empty();
});
List<Instruction<DamageCondition, Boss<Spider, WildernessBossDetail>>> damageProcessor = bossManager.getDamageProcessor();
damageProcessor.add((condition, boss) -> {
Optional<Spider> optBossEnt = boss.getTargetEntity();
if (optBossEnt.isPresent()) {
Spider bossEnt = optBossEnt.get();
Entity eToHit = condition.getAttacked();
if (!(eToHit instanceof Living))
return Optional.empty();
Living toHit = (Living) eToHit;
DamageEntityEvent event = condition.getEvent();
event.setBaseDamage(event.getBaseDamage() * 2);
EntityHealthUtil.heal(bossEnt, event.getBaseDamage());
Optional<PotionEffectData> optPotionEffects = toHit.getOrCreate(PotionEffectData.class);
if (!optPotionEffects.isPresent()) {
return Optional.empty();
}
PotionEffectData potionEffects = optPotionEffects.get();
potionEffects.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 1, 20 * 15));
potionEffects.addElement(PotionEffect.of(PotionEffectTypes.POISON, 1, 20 * 15));
toHit.offer(potionEffects);
}
return Optional.empty();
});
}
use of org.spongepowered.api.data.manipulator.mutable.PotionEffectData in project Skree by Skelril.
the class Agility method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 18);
Optional<PotionEffectData> optOwnerPotionEffectData = owner.getOrCreate(PotionEffectData.class);
if (optOwnerPotionEffectData.isPresent()) {
PotionEffectData ownerPotionEffectData = optOwnerPotionEffectData.get();
ownerPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SPEED, 2, duration));
owner.offer(ownerPotionEffectData);
}
Optional<PotionEffectData> optTargetPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (optTargetPotionEffectData.isPresent()) {
PotionEffectData targetPotionEffectData = optTargetPotionEffectData.get();
targetPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.SLOWNESS, 2, duration));
target.offer(targetPotionEffectData);
}
if (optOwnerPotionEffectData.isPresent() || optTargetPotionEffectData.isPresent()) {
notify(owner, Text.of(TextColors.YELLOW, "You gain a agile advantage over your opponent."));
}
}
use of org.spongepowered.api.data.manipulator.mutable.PotionEffectData in project Skree by Skelril.
the class Regen method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = owner.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) (EntityHealthUtil.getHealth(target) * 10);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.REGENERATION, 2, duration));
owner.offer(potionEffectData);
notify(owner, Text.of(TextColors.YELLOW, "You gain a healing aura."));
}
use of org.spongepowered.api.data.manipulator.mutable.PotionEffectData in project Skree by Skelril.
the class Weaken method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
int duration = (int) Math.min(20 * 60 * 5, EntityHealthUtil.getHealth(owner) * 18);
Optional<PotionEffectData> optOwnerPotionEffectData = owner.getOrCreate(PotionEffectData.class);
if (optOwnerPotionEffectData.isPresent()) {
PotionEffectData ownerPotionEffectData = optOwnerPotionEffectData.get();
ownerPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.STRENGTH, 1, duration));
owner.offer(ownerPotionEffectData);
}
Optional<PotionEffectData> optTargetPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (optTargetPotionEffectData.isPresent()) {
PotionEffectData targetPotionEffectData = optTargetPotionEffectData.get();
targetPotionEffectData.addElement(PotionEffect.of(PotionEffectTypes.WEAKNESS, 1, duration));
target.offer(targetPotionEffectData);
}
if (optOwnerPotionEffectData.isPresent() || optTargetPotionEffectData.isPresent()) {
notify(owner, Text.of(TextColors.YELLOW, "Your sword leaches strength from its victim."));
}
}
use of org.spongepowered.api.data.manipulator.mutable.PotionEffectData in project Skree by Skelril.
the class Confuse method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
Optional<PotionEffectData> optPotionEffectData = target.getOrCreate(PotionEffectData.class);
if (!optPotionEffectData.isPresent()) {
return;
}
PotionEffectData potionEffectData = optPotionEffectData.get();
int duration = (int) Math.min(1200, EntityHealthUtil.getHealth(owner) * 18);
potionEffectData.addElement(PotionEffect.of(PotionEffectTypes.NAUSEA, 1, duration));
target.offer(potionEffectData);
notify(owner, Text.of(TextColors.YELLOW, "Your sword confuses its victim."));
}
Aggregations