Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.30 KB | None | 0 0
  1. package me.lucaazalim.commands;
  2.  
  3. import org.bukkit.Location;
  4. import org.bukkit.Material;
  5. import org.bukkit.Sound;
  6. import org.bukkit.block.Block;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11.  
  12. import me.lucaazalim.listeners.Fertilizar_Delay;
  13.  
  14. public class CommandFertilizar implements CommandExecutor{
  15.  
  16. private int i = 0;
  17.  
  18. public Fertilizar_Delay time = new Fertilizar_Delay();
  19.  
  20. @Override
  21. public boolean onCommand(CommandSender sender, Command arg1, String label, String[] arg3) {
  22. if (sender instanceof Player){
  23. Player p = (Player) sender;
  24. if (p.hasPermission("vip")){
  25. Location loc = p.getLocation();
  26. if (time.hasDelay(p) && !p.hasPermission("f.bypass")){
  27. //p.sendMessage(Main.plugin.getMsg("msg_delay").replaceAll("@tempo", time.getDelayString(p)));
  28. p.sendMessage("§cVocê terá que esperar "+ time.getDelayString(p) +" para fertilizar suas plantações novamente!");
  29. return false;
  30. } else {
  31. //time.setDelay(p, Main.config.getConfig().getInt("fertilizar_delay"));
  32. time.setDelay(p,(1));// 1hora
  33. }
  34. int xx = 20;
  35. int yy = 20;
  36. int zz = 20;
  37. for (int x = -xx; x <= xx; x++) {
  38. for (int y = -yy; y <= yy; y++) {
  39. for (int z = -zz; z <= zz; z++)
  40. {
  41. Block b = loc.clone().add(x, y, z).getBlock();
  42. f(b, p);
  43. }
  44. }
  45. }
  46. if (i > 0){
  47. p.playSound(p.getLocation(), Sound.LEVEL_UP, 10, (float) 2.0);
  48. p.sendMessage("§aSuas plantações foram fertilizadas com sucesso!");
  49. } else {
  50. p.sendMessage("§cNão há plantações por perto para ser fertilizadas!");
  51. }
  52. i = 0;
  53. } else {
  54. p.sendMessage("§cRecurso não disponível para seu grupo!");
  55. p.playSound(p.getLocation(), Sound.CLICK, 1, 1);
  56. }
  57. }
  58. return false;
  59. }
  60. public void f(Block b, Player p) {
  61. switch (b.getTypeId())
  62. {
  63. case 115:
  64. b.setData((byte) 7);
  65.  
  66. i++;
  67. break;
  68. case 59:
  69. b.setData((byte) 7);
  70.  
  71. i++;
  72. break;
  73. case 142:
  74. b.setData((byte) 7);
  75.  
  76.  
  77. i++;
  78. break;
  79. case 141:
  80. i++;
  81. switch (b.getData())
  82. {
  83. case 0:
  84. b.setData((byte) 8);
  85.  
  86.  
  87. i++;
  88. break;
  89. case 1:
  90. b.setData((byte) 9);
  91.  
  92.  
  93. i++;
  94. break;
  95. case 2:
  96. b.setData((byte) 10);
  97.  
  98.  
  99. i++;
  100. break;
  101. case 3:
  102. b.setData((byte) 11);
  103.  
  104.  
  105. i++;
  106. break;
  107. }
  108. case 176:
  109. b.setData((byte) 7);
  110.  
  111. Location bLoc = b.getLocation();
  112. Block z1 = bLoc.clone().add(0.0D, 0.0D, 1.0D).getBlock();
  113. Block z2 = bLoc.clone().add(0.0D, 0.0D, -1.0D).getBlock();
  114. Block x1 = bLoc.clone().add(1.0D, 0.0D, 0.0D).getBlock();
  115. Block x2 = bLoc.clone().add(-1.0D, 0.0D, 0.0D).getBlock();
  116. if (z1.getType() == Material.AIR) {
  117. z1.setType(Material.MELON_BLOCK);
  118. } else if (z2.getType() == Material.AIR) {
  119. z2.setType(Material.MELON_BLOCK);
  120. } else if (x1.getType() == Material.AIR) {
  121. x1.setType(Material.MELON_BLOCK); } else {
  122. if (x2.getType() != Material.AIR) break;
  123. x2.setType(Material.MELON_BLOCK);
  124. }
  125. i++;
  126. break;
  127. case 104:
  128.  
  129. b.setData((byte) 7);
  130. Location pumpkinLoc = b.getLocation();
  131. Block z1_ = pumpkinLoc.clone().add(0.0D, 0.0D, 1.0D).getBlock();
  132. Block z2_ = pumpkinLoc.clone().add(0.0D, 0.0D, -1.0D).getBlock();
  133. Block x1_ = pumpkinLoc.clone().add(1.0D, 0.0D, 0.0D).getBlock();
  134. Block x2_ = pumpkinLoc.clone().add(-1.0D, 0.0D, 0.0D).getBlock();
  135. if (z1_.getType() == Material.AIR) {
  136. z1_.setType(Material.PUMPKIN);
  137. } else if (z2_.getType() == Material.AIR) {
  138. z2_.setType(Material.PUMPKIN);
  139. } else if (x1_.getType() == Material.AIR) {
  140. x1_.setType(Material.PUMPKIN); } else {
  141. if (x2_.getType() != Material.AIR) break;
  142. x2_.setType(Material.PUMPKIN);
  143. }
  144. i++;
  145. break;
  146. case 105:
  147. b.setData((byte) 7);
  148.  
  149. Location melonLoc = b.getLocation();
  150. Block mz1 = melonLoc.clone().add(0.0D, 0.0D, 1.0D).getBlock();
  151. Block mz2 = melonLoc.clone().add(0.0D, 0.0D, -1.0D).getBlock();
  152. Block mx1 = melonLoc.clone().add(1.0D, 0.0D, 0.0D).getBlock();
  153. Block mx2 = melonLoc.clone().add(-1.0D, 0.0D, 0.0D).getBlock();
  154. if (mz1.getType() == Material.AIR) {
  155. mz1.setType(Material.MELON);
  156. } else if (mz2.getType() == Material.AIR) {
  157. mz2.setType(Material.MELON);
  158. } else if (mx1.getType() == Material.AIR) {
  159. mx1.setType(Material.MELON); } else {
  160. if (mx2.getType() != Material.AIR) break;
  161. mx2.setType(Material.MELON);
  162. }
  163. i++;
  164. break;
  165. case 83:
  166. Location bLocz = b.getLocation();
  167.  
  168. Block c1 = bLocz.clone().add(0.0D, 1.0D, 0.0D).getBlock();
  169. Block c2 = c1.getLocation().add(0.0D, 1.0D, 0.0D).getBlock();
  170. Block c3 = c1.getLocation().subtract(0.0, 2.0, 0.0).getBlock();
  171. if (c3.getType() != Material.SUGAR_CANE_BLOCK){
  172. if (c1.getType() == Material.AIR)
  173. {
  174. c1.setType(Material.SUGAR_CANE_BLOCK);
  175. c2.setType(Material.SUGAR_CANE_BLOCK);
  176. c3 = c1.getLocation().add(0.0, 1, 0).getBlock();
  177. if (c3.getType() == Material.AIR){
  178. c3.setType(Material.SUGAR_CANE_BLOCK);
  179. }
  180. } else {
  181. if (c1.getType() != Material.AIR)
  182. break;
  183. c1.setType(Material.SUGAR_CANE_BLOCK);
  184. }
  185. i++;
  186. }
  187. break;
  188. }
  189. }
  190.  
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement