Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.xdip.rp;
- import java.util.HashMap;
- import java.util.Map;
- import org.bukkit.Chunk;
- import org.bukkit.Effect;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.Server;
- import org.bukkit.Sound;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.EventPriority;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockPistonExtendEvent;
- import org.bukkit.event.block.BlockPistonRetractEvent;
- import org.bukkit.event.block.BlockRedstoneEvent;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitScheduler;
- public class Main extends JavaPlugin
- implements Listener
- {
- Map<Chunk, Integer> ratio = new HashMap();
- Map<Chunk, Integer> ticks = new HashMap();
- int[] ids = { 75, 76, 93, 94, 149 };
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- }
- @EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
- public void onBlockRedstoneChange(BlockRedstoneEvent event) {
- Block block = event.getBlock();
- Chunk chunk = block.getChunk();
- World world = block.getWorld();
- int worldTime = (int)world.getTime();
- if (!this.ticks.containsKey(chunk)) {
- redstonePut(chunk, 1, worldTime);
- } else {
- int r = ((Integer)this.ratio.get(chunk)).intValue();
- if ((((Integer)this.ticks.get(chunk)).intValue() < 12) && (((Integer)this.ticks.get(chunk)).intValue() - 10 > worldTime)) {
- redstoneRemove(chunk);
- } else if (((Integer)this.ticks.get(chunk)).intValue() + 5 > worldTime) {
- int bid = block.getTypeId();
- byte bdata = block.getData();
- if (bid == 55) {
- if (bdata <= 2)
- r++;
- }
- else for (int id : this.ids)
- if (bid == id)
- r++;
- Location loc = block.getLocation();
- if (r > 2000) {
- if (bid == 55) {
- block.setType(Material.FIRE);
- world.playEffect(loc, Effect.EXPLOSION_HUGE, 1);
- world.playSound(loc, Sound.EXPLODE, 1.0F, 1.0F);
- } else {
- for (int id : this.ids)
- if (bid == id) {
- getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(block, world, loc)
- {
- public void run() {
- this.val$block.setType(Material.FIRE);
- this.val$world.playEffect(this.val$loc, Effect.EXPLOSION_HUGE, 1);
- this.val$world.playSound(this.val$loc, Sound.EXPLODE, 1.0F, 1.0F);
- }
- });
- break;
- }
- }
- r -= 400;
- } else if (r > 1500) {
- worldTime += 10;
- if ((bid == 76) || (bid == 149))
- world.playSound(loc, Sound.LAVA, 1.0F, 2.0F);
- if ((bid == 93) || (bid == 76) || (bid == 149) || (
- (bid == 55) && (bdata == 1)))
- world.playEffect(loc, Effect.LAVA_POP, 1);
- } else if (r > 1000) {
- worldTime += 6;
- if ((bid == 76) || (bid == 149)) {
- world.playEffect(loc, Effect.LAVA_POP, 1);
- world.playSound(loc, Sound.LAVA, 1.0F, 1.0F);
- }
- } else if ((r > 500) && (r <= 1000)) {
- worldTime += 4;
- if ((bid == 76) || (bid == 149))
- world.playSound(loc, Sound.LAVA, 1.0F, 0.0F);
- } else if (this.ticks.size() > 200) {
- redstoneRemove(chunk);
- }redstonePut(chunk, r, worldTime);
- } else {
- redstoneRemove(chunk);
- }
- }
- }
- private void redstonePut(Chunk chunk, int r, int worldTime) {
- this.ratio.put(chunk, Integer.valueOf(r));
- this.ticks.put(chunk, Integer.valueOf(worldTime));
- }
- private void redstoneRemove(Chunk chunk) {
- this.ratio.remove(chunk);
- this.ticks.remove(chunk);
- }
- @EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
- public void onBlockPistonExtend(BlockPistonExtendEvent event) {
- Chunk chunk = event.getBlock().getChunk();
- if (this.ratio.containsKey(chunk)) {
- int r = ((Integer)this.ratio.get(chunk)).intValue();
- r += 50;
- this.ratio.put(chunk, Integer.valueOf(r));
- }
- }
- @EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
- public void onBlockPistonRetract(BlockPistonRetractEvent event)
- {
- Chunk chunk = event.getBlock().getChunk();
- if (this.ratio.containsKey(chunk)) {
- int r = ((Integer)this.ratio.get(chunk)).intValue();
- r += 50;
- this.ratio.put(chunk, Integer.valueOf(r));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement