mcExcavation.java 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. package com.gmail.nossr50;
  2. import org.bukkit.ChatColor;
  3. import org.bukkit.Location;
  4. import org.bukkit.Material;
  5. import org.bukkit.block.Block;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.inventory.ItemStack;
  8. import org.bukkit.plugin.Plugin;
  9. import com.gmail.nossr50.datatypes.PlayerProfile;
  10. public class mcExcavation {
  11. private static mcMMO plugin;
  12. public mcExcavation(mcMMO instance) {
  13. plugin = instance;
  14. }
  15. public static void gigaDrillBreakerActivationCheck(Player player, Block block, Plugin pluginx){
  16. PlayerProfile PP = mcUsers.getProfile(player);
  17. if(mcm.isShovel(player.getItemInHand())){
  18. if(block != null){
  19. if(!mcm.abilityBlockCheck(block))
  20. return;
  21. }
  22. if(PP.getShovelPreparationMode()){
  23. PP.setShovelPreparationMode(false);
  24. }
  25. int ticks = 2;
  26. int x = PP.getExcavationInt();
  27. while(x >= 50){
  28. x-=50;
  29. ticks++;
  30. }
  31. if(!PP.getGigaDrillBreakerMode() && PP.getGigaDrillBreakerCooldown() == 0){
  32. player.sendMessage(ChatColor.GREEN+"**GIGA DRILL BREAKER ACTIVATED**");
  33. for(Player y : pluginx.getServer().getOnlinePlayers()){
  34. if(y != null && y != player && mcm.getDistance(player.getLocation(), y.getLocation()) < 10)
  35. y.sendMessage(ChatColor.GREEN+player.getName()+ChatColor.DARK_GREEN+" has used "+ChatColor.RED+"Giga Drill Breaker!");
  36. }
  37. PP.setGigaDrillBreakerTicks(ticks * 1000);
  38. PP.setGigaDrillBreakerActivatedTimeStamp(System.currentTimeMillis());
  39. PP.setGigaDrillBreakerMode(true);
  40. }
  41. }
  42. }
  43. public static boolean canBeGigaDrillBroken(Block block){
  44. int i = block.getTypeId();
  45. if(i == 2||i == 3||i == 12||i == 13){
  46. return true;
  47. } else {
  48. return false;
  49. }
  50. }
  51. public static void excavationProcCheck(Block block, Player player){
  52. PlayerProfile PP = mcUsers.getProfile(player);
  53. int type = block.getTypeId();
  54. Location loc = block.getLocation();
  55. ItemStack is = null;
  56. Material mat = null;
  57. if(block.getData() == (byte) 5){
  58. return;
  59. }
  60. if(type == 2){
  61. if(PP.getExcavationInt() > 250){
  62. //CHANCE TO GET EGGS
  63. if(mcLoadProperties.eggs == true && Math.random() * 100 > 99){
  64. PP.addExcavationXP(10 * mcLoadProperties.xpGainMultiplier);
  65. mat = Material.getMaterial(344);
  66. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  67. loc.getWorld().dropItemNaturally(loc, is);
  68. }
  69. //CHANCE TO GET APPLES
  70. if(mcLoadProperties.apples == true && Math.random() * 100 > 99){
  71. PP.addExcavationXP(10 * mcLoadProperties.xpGainMultiplier);
  72. mat = Material.getMaterial(260);
  73. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  74. loc.getWorld().dropItemNaturally(loc, is);
  75. }
  76. }
  77. }
  78. //DIRT SAND OR GRAVEL
  79. if(type == 3 || type == 13 || type == 2 || type == 12){
  80. PP.addExcavationXP(4 * mcLoadProperties.xpGainMultiplier);
  81. if(PP.getExcavationInt() > 750){
  82. //CHANCE TO GET CAKE
  83. if(mcLoadProperties.cake == true && Math.random() * 2000 > 1999){
  84. PP.addExcavationXP(300 * mcLoadProperties.xpGainMultiplier);
  85. mat = Material.getMaterial(354);
  86. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  87. loc.getWorld().dropItemNaturally(loc, is);
  88. }
  89. }
  90. if(PP.getExcavationInt() > 350){
  91. //CHANCE TO GET DIAMOND
  92. if(mcLoadProperties.diamond == true && Math.random() * 750 > 749){
  93. PP.addExcavationXP(100 * mcLoadProperties.xpGainMultiplier);
  94. mat = Material.getMaterial(264);
  95. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  96. loc.getWorld().dropItemNaturally(loc, is);
  97. }
  98. }
  99. if(PP.getExcavationInt() > 250){
  100. //CHANCE TO GET YELLOW MUSIC
  101. if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){
  102. PP.addExcavationXP(300 * mcLoadProperties.xpGainMultiplier);
  103. mat = Material.getMaterial(2256);
  104. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  105. loc.getWorld().dropItemNaturally(loc, is);
  106. }
  107. }
  108. if(PP.getExcavationInt() > 350){
  109. //CHANCE TO GET GREEN MUSIC
  110. if(mcLoadProperties.music == true && Math.random() * 2000 > 1999){
  111. PP.addExcavationXP(300 * mcLoadProperties.xpGainMultiplier);
  112. mat = Material.getMaterial(2257);
  113. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  114. loc.getWorld().dropItemNaturally(loc, is);
  115. }
  116. }
  117. }
  118. //SAND
  119. if(type == 12){
  120. //CHANCE TO GET GLOWSTONE
  121. if(mcLoadProperties.glowstone == true && PP.getExcavationInt() > 50 && Math.random() * 100 > 95){
  122. PP.addExcavationXP(8 * mcLoadProperties.xpGainMultiplier);
  123. mat = Material.getMaterial(348);
  124. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  125. loc.getWorld().dropItemNaturally(loc, is);
  126. }
  127. //CHANCE TO GET SLOWSAND
  128. if(mcLoadProperties.slowsand == true && PP.getExcavationInt() > 650 && Math.random() * 200 > 199){
  129. PP.addExcavationXP(8 * mcLoadProperties.xpGainMultiplier);
  130. mat = Material.getMaterial(88);
  131. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  132. loc.getWorld().dropItemNaturally(loc, is);
  133. }
  134. }
  135. //GRASS OR DIRT
  136. if(type == 2 || type == 3){
  137. if(PP.getExcavationInt() > 50){
  138. //CHANCE FOR COCOA BEANS
  139. if(mcLoadProperties.eggs == true && Math.random() * 75 > 74){
  140. PP.addExcavationXP(10 * mcLoadProperties.xpGainMultiplier);
  141. mat = Material.getMaterial(351);
  142. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  143. is.setDurability((byte) 3); //COCOA
  144. loc.getWorld().dropItemNaturally(loc, is);
  145. }
  146. }
  147. //CHANCE FOR SHROOMS
  148. if(mcLoadProperties.mushrooms == true && PP.getExcavationInt() > 500 && Math.random() * 200 > 199){
  149. PP.addExcavationXP(8 * mcLoadProperties.xpGainMultiplier);
  150. if(Math.random() * 10 > 5){
  151. mat = Material.getMaterial(39);
  152. } else {
  153. mat = Material.getMaterial(40);
  154. }
  155. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  156. loc.getWorld().dropItemNaturally(loc, is);
  157. }
  158. //CHANCE TO GET GLOWSTONE
  159. if(mcLoadProperties.glowstone == true && PP.getExcavationInt() > 25 && Math.random() * 100 > 95){
  160. PP.addExcavationXP(8 * mcLoadProperties.xpGainMultiplier);
  161. mat = Material.getMaterial(348);
  162. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  163. loc.getWorld().dropItemNaturally(loc, is);
  164. }
  165. }
  166. //GRAVEL
  167. if(type == 13){
  168. //CHANCE TO GET NETHERRACK
  169. if(mcLoadProperties.netherrack == true && PP.getExcavationInt() > 850 && Math.random() * 200 > 199){
  170. PP.addExcavationXP(3 * mcLoadProperties.xpGainMultiplier);
  171. mat = Material.getMaterial(87);
  172. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  173. loc.getWorld().dropItemNaturally(loc, is);
  174. }
  175. //CHANCE TO GET SULPHUR
  176. if(mcLoadProperties.sulphur == true && PP.getExcavationInt() > 75){
  177. if(Math.random() * 10 > 9){
  178. PP.addExcavationXP(3 * mcLoadProperties.xpGainMultiplier);
  179. mat = Material.getMaterial(289);
  180. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  181. loc.getWorld().dropItemNaturally(loc, is);
  182. }
  183. }
  184. //CHANCE TO GET BONES
  185. if(mcLoadProperties.bones == true && PP.getExcavationInt() > 175){
  186. if(Math.random() * 10 > 9){
  187. PP.addExcavationXP(3 * mcLoadProperties.xpGainMultiplier);
  188. mat = Material.getMaterial(352);
  189. is = new ItemStack(mat, 1, (byte)0, (byte)0);
  190. loc.getWorld().dropItemNaturally(loc, is);
  191. }
  192. }
  193. }
  194. mcSkills.XpCheck(player);
  195. }
  196. }