Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. package co.uk.tekkitservers.walkonwater;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Location;
  5. import org.bukkit.Material;
  6. import org.bukkit.World;
  7. import org.bukkit.block.Block;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.block.Action;
  12. import org.bukkit.event.player.PlayerInteractEvent;
  13. import org.bukkit.event.player.PlayerMoveEvent;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.plugin.java.JavaPlugin;
  16. import org.bukkit.scheduler.BukkitScheduler;
  17. import org.bukkit.scheduler.BukkitTask;
  18.  
  19. public final class main extends JavaPlugin implements Listener {
  20. private static final double timeoutSecs = 1.5;
  21. @Override
  22. public void onEnable() {
  23. Bukkit.getPluginManager().registerEvents(this, this);
  24.  
  25. }
  26. @EventHandler
  27. public void onWater(PlayerMoveEvent e) {
  28. Player p = e.getPlayer();
  29. if (p == null) {
  30. return;
  31. }
  32. Location loc = p.getLocation();
  33. World world = loc.getWorld();
  34. int x = loc.getBlockX();
  35. int y = loc.getBlockY();
  36. int z = loc.getBlockZ();
  37. Location b1 = new Location(world, x + 1, y, z);
  38. Location b2 = new Location(world, x - 1, y, z);
  39. Location b3 = new Location(world, x + 1, y, z + 1);
  40. Location b4 = new Location(world, x + 1, y, z - 1);
  41. Location b5 = new Location(world, x - 1, y, z + 1);
  42. Location b6 = new Location(world, x - 1, y, z - 1);
  43. Location b7 = new Location(world, x, y, z + 1);
  44. Location b8 = new Location(world, x, y, z - 1);
  45. Material b = loc.getBlock().getType();
  46. if (b != Material.WATER) {
  47. return;
  48. }
  49. if (p.hasPermission("tekkitservers.walkonwater") && ((b == Material.WATER) || (b == Material.STATIONARY_WATER))) {
  50. loc.getBlock().setType(Material.ICE);
  51. b1.getBlock().setType(Material.ICE);
  52. b2.getBlock().setType(Material.ICE);
  53. b3.getBlock().setType(Material.ICE);
  54. b4.getBlock().setType(Material.ICE);
  55. b5.getBlock().setType(Material.ICE);
  56. b6.getBlock().setType(Material.ICE);
  57. b7.getBlock().setType(Material.ICE);
  58. b8.getBlock().setType(Material.ICE);
  59. BukkitScheduler scheduler = Bukkit.getScheduler();
  60. scheduler.scheduleAsyncDelayedTask(this, new Runnable(){
  61. @Override
  62. public void run() {
  63. if ((loc.getX() == x + 3) || (loc.getY() == y + 3) || (loc.getZ() == z + 3)) {
  64. loc.getBlock().setType(Material.STATIONARY_WATER);
  65. b1.getBlock().setType(Material.STATIONARY_WATER);
  66. b2.getBlock().setType(Material.STATIONARY_WATER);
  67. b3.getBlock().setType(Material.STATIONARY_WATER);
  68. b4.getBlock().setType(Material.STATIONARY_WATER);
  69. b5.getBlock().setType(Material.STATIONARY_WATER);
  70. b6.getBlock().setType(Material.STATIONARY_WATER);
  71. b7.getBlock().setType(Material.STATIONARY_WATER);
  72. b8.getBlock().setType(Material.STATIONARY_WATER);
  73. }
  74. }
  75. }, (long) (20 * timeoutSecs));
  76. }
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement