Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package co.uk.tekkitservers.walkonwater;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerMoveEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitScheduler;
- import org.bukkit.scheduler.BukkitTask;
- public final class main extends JavaPlugin implements Listener {
- private static final double timeoutSecs = 1.5;
- @Override
- public void onEnable() {
- Bukkit.getPluginManager().registerEvents(this, this);
- }
- @EventHandler
- public void onWater(PlayerMoveEvent e) {
- Player p = e.getPlayer();
- if (p == null) {
- return;
- }
- Location loc = p.getLocation();
- World world = loc.getWorld();
- int x = loc.getBlockX();
- int y = loc.getBlockY();
- int z = loc.getBlockZ();
- Location b1 = new Location(world, x + 1, y, z);
- Location b2 = new Location(world, x - 1, y, z);
- Location b3 = new Location(world, x + 1, y, z + 1);
- Location b4 = new Location(world, x + 1, y, z - 1);
- Location b5 = new Location(world, x - 1, y, z + 1);
- Location b6 = new Location(world, x - 1, y, z - 1);
- Location b7 = new Location(world, x, y, z + 1);
- Location b8 = new Location(world, x, y, z - 1);
- Material b = loc.getBlock().getType();
- if (b != Material.WATER) {
- return;
- }
- if (p.hasPermission("tekkitservers.walkonwater") && ((b == Material.WATER) || (b == Material.STATIONARY_WATER))) {
- loc.getBlock().setType(Material.ICE);
- b1.getBlock().setType(Material.ICE);
- b2.getBlock().setType(Material.ICE);
- b3.getBlock().setType(Material.ICE);
- b4.getBlock().setType(Material.ICE);
- b5.getBlock().setType(Material.ICE);
- b6.getBlock().setType(Material.ICE);
- b7.getBlock().setType(Material.ICE);
- b8.getBlock().setType(Material.ICE);
- BukkitScheduler scheduler = Bukkit.getScheduler();
- scheduler.scheduleAsyncDelayedTask(this, new Runnable(){
- @Override
- public void run() {
- if ((loc.getX() == x + 3) || (loc.getY() == y + 3) || (loc.getZ() == z + 3)) {
- loc.getBlock().setType(Material.STATIONARY_WATER);
- b1.getBlock().setType(Material.STATIONARY_WATER);
- b2.getBlock().setType(Material.STATIONARY_WATER);
- b3.getBlock().setType(Material.STATIONARY_WATER);
- b4.getBlock().setType(Material.STATIONARY_WATER);
- b5.getBlock().setType(Material.STATIONARY_WATER);
- b6.getBlock().setType(Material.STATIONARY_WATER);
- b7.getBlock().setType(Material.STATIONARY_WATER);
- b8.getBlock().setType(Material.STATIONARY_WATER);
- }
- }
- }, (long) (20 * timeoutSecs));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement