SHARE
TWEET

RemoveOldBlockTask

Ytnoos Mar 4th, 2019 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.bukkit.Location;
  2.  
  3. import java.util.Date;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6.  
  7. public class RemoveOldBlockTask implements Runnable {
  8.  
  9.     private final int secondsBeforeExpiration = CosmicBreaking.getInstance().getConfig().getInt("removeOldBlocks");;
  10.  
  11.     @Override
  12.     public void run() {
  13.         Map<Location, BrokenBlock> blocks = new HashMap<>(BrokenBlocksService.getBrokenBlocks());
  14.         Date currentDate = new Date();
  15.         blocks.values().forEach(damagedBlock -> {
  16.             if (damagedBlock.getLastDamage() == null) return;
  17.  
  18.             if ((currentDate.getTime() - damagedBlock.getLastDamage().getTime()) / 1000 > secondsBeforeExpiration)
  19.                 damagedBlock.destroyBlockObject();
  20.         });
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top