Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onProjectileHit(ProjectileHitEvent e) {
- Projectile p = e.getEntity();
- ProjectileSource ps = p.getShooter();
- if (p instanceof Snowball && ps instanceof Player) {
- final Player player = (Player) ps;
- if (player.getItemInHand().equals(Items.getGravity())) {
- final Location loc = p.getLocation();
- loc.setY(loc.getY() - 1);
- if (Main.getInstance().getWorldGuard() != null) {
- if (!Main.getInstance().getWorldGuard()
- .canBuild(player, loc.getBlock())) {
- return;
- }
- }
- int radius = 10;
- final ArrayList<Block> blocks = getBlocksAroundPoint(loc,
- radius);
- final ArrayList<Entity> entities = new ArrayList<Entity>();
- for (Entity ee : loc.getWorld().getEntities()) {
- if (ee.getLocation().distance(loc) <= radius) {
- entities.add(ee);
- }
- }
- int c = 0;
- for (Block b : blocks) {
- fly.add(b.getState());
- }
- for (final Block b : blocks) {
- c++;
- new BukkitRunnable() {
- @Override
- public void run() {
- final FallingBlock fb = b.getWorld()
- .spawnFallingBlock(b.getLocation(),
- b.getType(), b.getData());
- fb.setMetadata("Restore", new FixedMetadataValue(
- Main.getInstance(), b.getState()));
- b.setType(Material.AIR);
- fb.setDropItem(false);
- double y = 3;
- fb.setVelocity(new Vector(0, y, 0));
- falling.add(fb);
- for (Entity ee : entities) {
- if (ee.getLocation().distance(b.getLocation()) <= 3
- && ee instanceof LivingEntity) {
- LivingEntity le = (LivingEntity) ee;
- le.setVelocity(new Vector(0, y, 0));
- le.addPotionEffect(new PotionEffect(
- PotionEffectType.DAMAGE_RESISTANCE,
- 110, 30));
- }
- }
- }
- }.runTaskLater(Main.getInstance(), c / 100);
- }
- new BukkitRunnable() {
- @Override
- public void run() {
- for (Entity ee : entities) {
- if (ee.getLocation().distance(loc) <= 3
- && ee instanceof LivingEntity) {
- LivingEntity le = (LivingEntity) ee;
- Material m = le.getLocation().getBlock()
- .getType();
- if (m == Material.AIR || m == Material.WATER) {
- } else {
- le.teleport(le
- .getWorld()
- .getHighestBlockAt(le.getLocation())
- .getLocation());
- }
- }
- }
- }
- }.runTaskLater(Main.getInstance(), c);
- }
- }
- }
- @EventHandler
- public void onEntityChangeBlock(EntityChangeBlockEvent e) {
- if (!e.getEntity().hasMetadata("Restore")) {
- return;
- }
- BlockState b = (BlockState) e.getEntity().getMetadata("Restore").get(0)
- .value();
- e.setCancelled(true);
- b.update(true, false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement