Advertisement
Guest User

SomeListener

a guest
Jan 12th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. package com.bergerkiller.bukkit.fountains;
  2.  
  3. import org.bukkit.event.EventHandler;
  4. import org.bukkit.event.EventPriority;
  5. import org.bukkit.event.Listener;
  6. import org.bukkit.event.block.BlockFromToEvent;
  7. import org.bukkit.event.block.BlockPhysicsEvent;
  8.  
  9. import com.bergerkiller.bukkit.common.collections.BlockMap;
  10. import com.bergerkiller.bukkit.fountains.FountainController.FountainOptions;
  11.  
  12. public class SomeListener implements Listener {
  13.     private BlockMap<Boolean> fountainActiveMap = new BlockMap<Boolean>();
  14.  
  15.     @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  16.     public void onBlockFromTo(BlockFromToEvent event) {
  17.         event.setCancelled(FountainController.isNonSpreadingFountain(event.getBlock())
  18.                 || FountainController.isNonSpreadingFountain(event.getToBlock()));
  19.     }
  20.  
  21.     @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  22.     public void onSignBlockPhysics(BlockPhysicsEvent event) {
  23.         FountainOptions opts = FountainOptions.fromSignBlock(event.getBlock());
  24.         if (opts != null) {
  25.             Boolean activeUpState = fountainActiveMap.get(event.getBlock());
  26.             if (activeUpState == null || activeUpState.booleanValue() != opts.up) {
  27.                 fountainActiveMap.put(event.getBlock(), opts.up);
  28.                 FountainController.animate(FountainMain.plugin, event.getBlock().getRelative(0, 2, 0), opts);
  29.             }
  30.         } else if (FountainController.isNonSpreadingFountain(event.getBlock())) {
  31.             event.setCancelled(true);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement