Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. public Location[] circleFrom(Location l){
  2.     List<Location> returnList = new ArrayList<Location>();
  3.     for(int x = 2; x>=-2; x--){
  4.         for(int z = 2; z>=-2; z--){
  5.             for(int y = 0; y>=1; y++){
  6.                 if(!(Math.abs(z)==1&&x==0)||!(Math.abs(x)==1&&z==0)||x!=z){
  7.                     returnList.add(new Location(l.getWorld(), l.getX()-x, l.getY()+y, l.getZ()-z));
  8.                 }
  9.             }
  10.         }
  11.      }
  12.      return returnList.toArray(new Location[returnList.size()]);
  13. }
  14.  
  15. @EventHandler
  16. public void gandalf(PlayerInteractEvent e) {
  17. if(e.getAction()!=Action.RIGHT_CLICK_AIR||e.getAction()!=Action.RIGHT_CLICK_BLOCK)return;
  18. Player p = e.getPlayer();
  19. Action a = e.getAction();
  20. if (p.getItemInHand().getType() == Material.STICK) {
  21.         Location location=p.getLocation();
  22.         for(int i = 0; i<circleFrom(location).length; i++){
  23.             Location l = circleFrom(location)[i];
  24.             Material changeTo = Material.SPONGE;
  25.             new BukkitRunnable(){
  26.                 public void run(){
  27.                     l.getBlock().setType(changeTo);
  28.                 }
  29.             }.runTaskLater(this, i*2);//i*20 = (i) seconds
  30.         }
  31.         new BukkitRunnable(){
  32.             public void run(){
  33.                 for(Location l : circleFrom(location)){
  34.                     l.getBlock().setType(Material.AIR);
  35.                 }
  36.              }.runTaskLater(this, 3.8);//2 seconds + 18 blocks that each takes 0.1
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement