Advertisement
Lilret123

LavaListener

Feb 26th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. package platinum.server.team.Listener;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Material;
  5. import org.bukkit.block.Block;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.block.BlockFromToEvent;
  9. import platinum.server.team.Config.Config;
  10. import platinum.server.team.Main;
  11.  
  12. /**
  13.  * Created by Lilret123 on 2/25/2015.
  14.  */
  15. public class LavaListener implements Listener {
  16.  
  17.     Main plugin;
  18.     public LavaListener(Main instance) {
  19.         plugin = instance;
  20.     }
  21.     public void registerEvents() {
  22.         this.plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
  23.     }
  24.     int check;
  25.     Config config = Main.config;
  26.  
  27.     @EventHandler
  28.     public  void onFlow(BlockFromToEvent e){
  29.         if(!config.getBoolean("LavaFix.Configuration.LavaSlow.Enabled")){
  30.             return;
  31.         }
  32.         else{
  33.             int factor = config.getInt("LavaFix.Configuration.LavaSlow.Factor");
  34.             Block b = e.getBlock();
  35.             Material m = b.getType();
  36.             if(m == Material.LAVA || m == Material.STATIONARY_LAVA) {
  37.                 Material lava = Material.LAVA;
  38.                 byte data = b.getData();
  39.                 if (check < factor) {
  40.                         e.setCancelled(true);
  41.                         check++;
  42.                         b.setType(lava);
  43.                         b.setData(data);
  44.                         Bukkit.getServer().broadcastMessage("Type is: " + lava + data);
  45.                 }
  46.                 else{
  47.                     check = 0;
  48.                 }
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement