use of com.skelril.nitro.time.IntegratedRunnable in project Skree by Skelril.
the class ItemVortex method run.
@Override
public void run(Living owner, Location<World> target) {
IntegratedRunnable vortex = new IntegratedRunnable() {
@Override
public boolean run(int times) {
ParticleGenerator.enderTeleport(target, 1);
getTargetEntities(target).stream().filter(e -> e instanceof Item).forEach(e -> {
e.setLocation(owner.getLocation());
});
return true;
}
@Override
public void end() {
}
};
TimedRunnable<IntegratedRunnable> runnable = new TimedRunnable<>(vortex, 3);
Task task = Task.builder().execute(runnable).interval(500, TimeUnit.MILLISECONDS).submit(SkreePlugin.inst());
runnable.setTask(task);
}
use of com.skelril.nitro.time.IntegratedRunnable in project Skree by Skelril.
the class FearBomb method run.
@Override
public void run(Living owner, Living target, DamageEntityEvent event) {
final List<Location<World>> blocks = new ArrayList<>();
Location<World> originalLocation = target.getLocation();
Vector3d max = originalLocation.getPosition().add(1, 0, 1);
Vector3d min = originalLocation.getPosition().sub(1, 0, 1);
for (int x = min.getFloorX(); x <= max.getFloorX(); ++x) {
for (int z = min.getFloorZ(); z <= max.getFloorZ(); ++z) {
Location<World> loc = target.getLocation().setBlockPosition(new Vector3i(x, target.getLocation().getBlockY(), z));
while (loc.getY() > 0 && isPassable(loc.getBlockType())) {
loc = loc.add(0, -1, 0);
}
blocks.add(loc);
}
}
IntegratedRunnable bomb = new IntegratedRunnable() {
@Override
public boolean run(int times) {
Collection<Player> players = blocks.get(0).getExtent().getPlayers();
for (Location<World> loc : blocks) {
if (isPassable(loc.getBlockType())) {
continue;
}
for (Player player : players) {
player.sendBlockChange(loc.getBlockPosition(), times % 2 == 0 ? WHITE_WOOL_STATE : RED_WOOL_STATE);
}
}
return true;
}
@Override
public void end() {
Collection<Player> players = blocks.get(0).getExtent().getPlayers();
for (Location<World> loc : blocks) {
loc.getExtent().triggerExplosion(Explosion.builder().radius(3).location(loc).shouldBreakBlocks(false).shouldDamageEntities(false).canCauseFire(false).build(), Cause.source(SkreePlugin.container()).build());
for (Player player : players) {
player.resetBlockChange(loc.getBlockPosition());
}
}
getTargetEntities(originalLocation).stream().filter((e) -> e instanceof Monster || e instanceof Player).forEach((entity) -> {
entity.damage(10000, damageSource(owner));
});
}
};
TimedRunnable<IntegratedRunnable> timedRunnable = new TimedRunnable<>(bomb, 6);
Task task = Task.builder().execute(timedRunnable).interval(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
timedRunnable.setTask(task);
notify(owner, Text.of(TextColors.YELLOW, "Your bow creates a powerful bomb."));
}
Aggregations