Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. Lisner
  2. ------
  3. package cog.stem;
  4.  
  5. import java.util.Random;
  6. import org.bukkit.Material;
  7. import org.bukkit.Server;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.block.BlockFace;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.BlockFromToEvent;
  13. import org.bukkit.plugin.PluginManager;
  14.  
  15. public class ListenerClass implements Listener
  16. {
  17. private static Random r = new Random();
  18.  
  19. public ListenerClass(COG plugin) {
  20. plugin.getServer().getPluginManager().registerEvents(this, plugin);
  21. }
  22.  
  23. @EventHandler
  24. public void onFromTo(BlockFromToEvent e)
  25. {
  26. int id = e.getBlock().getTypeId(Material.AIR);
  27. if ((id >= 8) && (id <= 11)) {
  28. Block b = e.getToBlock();
  29. int toid = b.getTypeId();
  30. if ((toid == 0) &&
  31. (generatesCobble(id, b))) {
  32. for (BlockFace face : facesCobble) {
  33. Block r = e.getBlock().getRelative(face, 1);
  34. if (r.getTypeId() == 0) {
  35. for (BlockFace face2 : faces) {
  36. int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8;
  37. int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9;
  38. Block o = r.getRelative(face2, 1);
  39. if ((o.getTypeId() == mirrorID1) || (o.getTypeId() == mirrorID2)) {
  40. int i = 1;
  41. while (i == 1) {
  42. if (r.nextInt(100) <= CobbleOres.Cobblestone) {
  43. r.setType(Material.COBBLESTONE);
  44. i = 0;
  45. } else if (r.nextInt(100) <= CobbleOres.Coal) {
  46. r.setType(Material.COAL_ORE);
  47. i = 0;
  48. } else if (r.nextInt(100) <= CobbleOres.Iron) {
  49. r.setType(Material.IRON_ORE);
  50. i = 0;
  51. } else if (r.nextInt(100) <= CobbleOres.Lapis) {
  52. r.setType(Material.LAPIS_ORE);
  53. i = 0;
  54. } else if (r.nextInt(100) <= CobbleOres.Redstone) {
  55. r.setType(Material.REDSTONE_ORE);
  56. i = 0;
  57. } else if (r.nextInt(100) <= CobbleOres.Gold) {
  58. r.setType(Material.GOLD_ORE);
  59. i = 0;
  60. } else if (r.nextInt(100) <= CobbleOres.Diamond) {
  61. r.setType(Material.DIAMOND_ORE);
  62. i = 0;
  63. } else if (r.nextInt(100) <= CobbleOres.Emerald) {
  64. r.setType(Material.EMERALD_ORE);
  65. i = 0;
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. }
  75.  
  76. private final BlockFace[] faces = {
  77. BlockFace.SELF,
  78. BlockFace.UP,
  79. BlockFace.DOWN,
  80. BlockFace.NORTH,
  81. BlockFace.EAST,
  82. BlockFace.SOUTH,
  83. BlockFace.WEST };
  84.  
  85.  
  86. private final BlockFace[] facesCobble = {
  87. BlockFace.NORTH,
  88. BlockFace.EAST,
  89. BlockFace.SOUTH,
  90. BlockFace.WEST };
  91.  
  92.  
  93. public boolean generatesCobble(int id, Block b)
  94. {
  95. int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8;
  96. int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9;
  97. for (BlockFace face : faces) {
  98. Block r = b.getRelative(face, 1);
  99. if ((r.getTypeId() == mirrorID1) || (r.getTypeId() == mirrorID2)) {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. }
  106.  
  107.  
  108. COG
  109. ----
  110. package cog.stem;
  111.  
  112. import org.bukkit.configuration.file.FileConfiguration;
  113.  
  114. public class COG extends org.bukkit.plugin.java.JavaPlugin
  115. {
  116. public COG() {}
  117.  
  118. public static String prefix = net.md_5.bungee.api.ChatColor.GRAY + "[" + net.md_5.bungee.api.ChatColor.DARK_GRAY + "CobbleOres" + net.md_5.bungee.api.ChatColor.GRAY + "] " + net.md_5.bungee.api.ChatColor.WHITE;
  119.  
  120. public static int Cobblestone = 45;
  121. public static int Coal = 35;
  122. public static int Iron = 25;
  123. public static int Lapis = 15;
  124. public static int Redstone = 15;
  125. public static int Gold = 10;
  126. public static int Diamond = 5;
  127. public static int Emerald = 1;
  128.  
  129. public void onEnable() {
  130. new ListenerClass(this);
  131. if (getConfig().getString("Dont Remove") != null) {
  132. Cobblestone = getConfig().getInt("Cobblestone");
  133. Coal = getConfig().getInt("Coal");
  134. Iron = getConfig().getInt("Iron");
  135. Lapis = getConfig().getInt("Lapis");
  136. Redstone = getConfig().getInt("Redstone");
  137. Gold = getConfig().getInt("Gold");
  138. Diamond = getConfig().getInt("Diamond");
  139. Emerald = getConfig().getInt("Emerald");
  140. } else {
  141. getConfig().set("Cobblestone", Integer.valueOf(Cobblestone));
  142. getConfig().set("Coal", Integer.valueOf(Coal));
  143. getConfig().set("Iron", Integer.valueOf(Iron));
  144. getConfig().set("Lapis", Integer.valueOf(Lapis));
  145. getConfig().set("Redstone", Integer.valueOf(Redstone));
  146. getConfig().set("Gold", Integer.valueOf(Gold));
  147. getConfig().set("Diamond", Integer.valueOf(Diamond));
  148. getConfig().set("Emerald", Integer.valueOf(Emerald));
  149. }
  150. getConfig().set("Dont Remove", "Or Config Will Reset Also Don't Put Numbers Over 100");
  151. saveConfig();
  152. }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement