Advertisement
Guest User

Untitled

a guest
Dec 5th, 2013
1,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. final Timer delaytimer= new Timer();
  2. TimerTask delaytask = new TimerTask(){
  3. public void run(){
  4.  
  5.  
  6.  
  7. String worldstring = Arenas.getString(arena + ".arena.world");
  8. final World world = Bukkit.getServer().getWorld(worldstring);
  9.  
  10.  
  11.  
  12. double X1 = Arenas.getInt(arena + ".corner.x");
  13. double Y1 = Arenas.getInt(arena + ".corner.y");
  14. double Z1 = Arenas.getInt(arena + ".corner.z");
  15.  
  16. double X2 = Arenas.getInt(arena + ".corner2.x");
  17. double Y2 = Arenas.getInt(arena + ".corner2.y");
  18. double Z2 = Arenas.getInt(arena + ".corner2.z");
  19.  
  20.  
  21.  
  22.  
  23. Location loc1 = new Location(Bukkit.getWorld(Arenas.getString(arena + ".arena.world")), X1, Y1, Z1);
  24. Location loc2 = new Location(Bukkit.getWorld(Arenas.getString(arena + ".arena.world")), X2, Y2, Z2);
  25. int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
  26. int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
  27. int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
  28. int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX());
  29. int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY());
  30. int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
  31.  
  32. for(int x = minX; x <= maxX; x++){
  33. for(int y = minY; y <= maxY; y++){
  34. for(int z = minZ; z <= maxZ; z++){
  35. byte data = world.getBlockAt(x, y, z).getData();
  36.  
  37.  
  38. if (data != random) {
  39. Block blockk = world.getBlockAt(x, y, z); // odstranuje bloky
  40. blockk.setType(Material.AIR);
  41.  
  42.  
  43.  
  44. }
  45.  
  46. }
  47. }
  48. }
  49.  
  50. final Timer generatetimer= new Timer(); //generuje hrací plochu
  51. TimerTask generatetask = new TimerTask(){
  52. public void run(){
  53. statuss = Temp.getString(arena + ".status");
  54. int i = 0;
  55. int n = 0;
  56. double X = Arenas.getDouble(arena + ".corner.x");
  57. int X2 = (int) X;
  58. double Y = Arenas.getDouble(arena + ".corner.y");
  59. int Y2 = (int) Y;
  60. double Z = Arenas.getDouble(arena + ".corner.z");
  61. int Z2 = (int) Z;
  62. int size = Arenas.getInt(arena + ".size");
  63. for (i = 0; i <= size*size-1; i++) {
  64. int random = 0 + (int)(Math.random()*14);
  65.  
  66. double zbytek = i % size;
  67. if (zbytek == 0) {n = (i / size) * 3;}
  68. Block block = world.getBlockAt(X2+1+i*3-n*size, Y2, Z2+1+n);
  69. block.setType(Material.WOOL);
  70. block.setData((byte) random);
  71.  
  72. Block block21 = world.getBlockAt(X2+2+i*3-n*size, Y2, Z2+1+n);
  73. block21.setType(Material.WOOL);
  74. block21.setData((byte) random);
  75.  
  76. Block block31 = world.getBlockAt(X2+3+i*3-n*size, Y2, Z2+1+n);
  77. block31.setType(Material.WOOL);
  78. block31.setData((byte) random);
  79.  
  80. Block block12 = world.getBlockAt(X2+1+i*3-n*size, Y2, Z2+2+n);
  81. block12.setType(Material.WOOL);
  82. block12.setData((byte) random);
  83.  
  84. Block block22 = world.getBlockAt(X2+2+i*3-n*size, Y2, Z2+2+n);
  85. block22.setType(Material.WOOL);
  86. block22.setData((byte) random);
  87.  
  88. Block block32 = world.getBlockAt(X2+3+i*3-n*size, Y2, Z2+2+n);
  89. block32.setType(Material.WOOL);
  90. block32.setData((byte) random);
  91.  
  92. Block block13 = world.getBlockAt(X2+1+i*3-n*size, Y2, Z2+3+n);
  93. block13.setType(Material.WOOL);
  94. block13.setData((byte) random);
  95.  
  96. Block block23 = world.getBlockAt(X2+2+i*3-n*size, Y2, Z2+3+n);
  97. block23.setType(Material.WOOL);
  98. block23.setData((byte) random);
  99.  
  100. Block block33 = world.getBlockAt(X2+3+i*3-n*size, Y2, Z2+3+n);
  101. block33.setType(Material.WOOL);
  102. block33.setData((byte) random);
  103. }
  104. //calcelnuti pokud hra zkončila
  105. if (statuss.equals("lobby")) {
  106. generatetimer.cancel();
  107. }
  108. }
  109. };
  110. generatetimer.schedule(generatetask, 4000);
  111.  
  112.  
  113. }
  114. };
  115. delaytimer.schedule(delaytask, runtime*1000+1000);
  116.  
  117.  
  118.  
  119. if (statuss.equals("lobby")) {
  120. delaytimer.cancel();
  121. }
  122.  
  123.  
  124. //calcelnuti pokud hra zkončila
  125. if (statuss.equals("lobby")) {
  126. progresstimer.cancel();
  127. }
  128.  
  129.  
  130. }
  131. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement