use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.
the class PatientXInstance method throwSlashPotion.
private void throwSlashPotion(Location<World> location) {
PotionEffectType[] thrownTypes = new PotionEffectType[] { PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS };
Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
entity.setVelocity(new Vector3d(random.nextDouble() * .5 - .25, random.nextDouble() * .4 + .1, random.nextDouble() * .5 - .25));
PotionEffectType type = Probability.pickOneOf(thrownTypes);
PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));
getRegion().getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.
the class CursedMineInstance method poison.
public void poison(Player player, int duration) {
if (Probability.getChance(player.getLocation().getBlockY() / 2)) {
PotionEffect posionEffect = PotionEffect.of(PotionEffectTypes.POISON, 2, 20 * duration);
List<PotionEffect> potionEffects = player.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(posionEffect);
player.offer(Keys.POTION_EFFECTS, potionEffects);
player.sendMessage(Text.of(TextColors.RED, "The ore releases a toxic gas poisoning you!"));
}
}
use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.
the class DeadlyPotionCurse method throwSlashPotion.
private void throwSlashPotion(Location<World> location) {
PotionEffectType[] thrownTypes = new PotionEffectType[] { PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.INSTANT_DAMAGE, PotionEffectTypes.POISON, PotionEffectTypes.WEAKNESS };
Entity entity = location.getExtent().createEntity(EntityTypes.SPLASH_POTION, location.getPosition());
entity.setVelocity(new Vector3d(random.nextDouble() * .5 - .25, random.nextDouble() * .4 + .1, random.nextDouble() * .5 - .25));
PotionEffectType type = Probability.pickOneOf(thrownTypes);
PotionEffect effect = PotionEffect.of(type, 2, type.isInstant() ? 1 : 15 * 20);
entity.offer(Keys.POTION_EFFECTS, Lists.newArrayList(effect));
location.getExtent().spawnEntity(entity, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
}
use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.
the class MainWorldWrapper method run.
@Override
public void run() {
PotionEffect speedEffect = PotionEffect.builder().duration(3 * 20).amplifier(5).particles(false).potionType(PotionEffectTypes.SPEED).build();
for (World world : getWorlds()) {
for (Entity entity : world.getEntities(p -> p.getType().equals(EntityTypes.PLAYER))) {
if (entity.get(Keys.GAME_MODE).orElse(GameModes.CREATIVE) != GameModes.SURVIVAL) {
continue;
}
List<PotionEffect> potionEffects = entity.getOrElse(Keys.POTION_EFFECTS, new ArrayList<>(1));
potionEffects.add(speedEffect);
entity.offer(Keys.POTION_EFFECTS, potionEffects);
}
}
}
use of org.spongepowered.api.effect.potion.PotionEffect in project Skree by Skelril.
the class FreakyFourInstance method runFrimus.
private void runFrimus() {
createWall(getRegion(FreakyFourBoss.FRIMUS), type -> type == BlockTypes.AIR, type -> type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA, BlockTypes.AIR, BlockTypes.LAVA, config.frimusWallDensity, -1);
for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
List<PotionEffect> oldPotions = player.get(Keys.POTION_EFFECTS).orElse(new ArrayList<>());
List<PotionEffect> newPotions = oldPotions.stream().filter(effect -> effect.getType() != PotionEffectTypes.FIRE_RESISTANCE).collect(Collectors.toList());
if (oldPotions.size() != newPotions.size()) {
player.offer(Keys.POTION_EFFECTS, newPotions);
}
}
}
Aggregations