JackOUT

Untitled

Mar 14th, 2022 (edited)
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. @Override
  2.     protected void onDamage(final int level, final LivingEntity damager, final EntityDamageByEntityEvent event) {
  3.         if (!(damager instanceof Player))
  4.             return;
  5.  
  6.         final Entity victim = event.getEntity();
  7.  
  8.         new BukkitRunnable() {
  9.  
  10.             private int remainingSeconds = 25;
  11.             private final Map<Location, Material> oldBlocks = new HashMap<>();
  12.  
  13.             @Override
  14.             public void run() {
  15.                 remainingSeconds--;
  16.  
  17.                 for (final Block block : getBlocksInRadius(victim.getLocation(), 4)) {
  18.                     if (block.getType() != Material.ICE) {
  19.                         oldBlocks.put(block.getLocation(), block.getType());
  20.                         block.setType(Material.ICE);
  21.                     }
  22.                 }
  23.  
  24.                 if (remainingSeconds == 0) {
  25.                     this.cancel();
  26.  
  27.                     for (final Map.Entry<Location, Material> entry : oldBlocks.entrySet()) {
  28.                         entry.getKey().getBlock().setType(entry.getValue());
  29.                     }
  30.                 }
  31.             }
  32.         }.runTaskTimer(SimplePlugin.getInstance(), 0, 6);
  33.     }
Add Comment
Please, Sign In to add comment