Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Lisner
- ------
- package cog.stem;
- import java.util.Random;
- import org.bukkit.Material;
- import org.bukkit.Server;
- import org.bukkit.block.Block;
- import org.bukkit.block.BlockFace;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockFromToEvent;
- import org.bukkit.plugin.PluginManager;
- public class ListenerClass implements Listener
- {
- private static Random r = new Random();
- public ListenerClass(COG plugin) {
- plugin.getServer().getPluginManager().registerEvents(this, plugin);
- }
- @EventHandler
- public void onFromTo(BlockFromToEvent e)
- {
- int id = e.getBlock().getTypeId(Material.AIR);
- if ((id >= 8) && (id <= 11)) {
- Block b = e.getToBlock();
- int toid = b.getTypeId();
- if ((toid == 0) &&
- (generatesCobble(id, b))) {
- for (BlockFace face : facesCobble) {
- Block r = e.getBlock().getRelative(face, 1);
- if (r.getTypeId() == 0) {
- for (BlockFace face2 : faces) {
- int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8;
- int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9;
- Block o = r.getRelative(face2, 1);
- if ((o.getTypeId() == mirrorID1) || (o.getTypeId() == mirrorID2)) {
- int i = 1;
- while (i == 1) {
- if (r.nextInt(100) <= CobbleOres.Cobblestone) {
- r.setType(Material.COBBLESTONE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Coal) {
- r.setType(Material.COAL_ORE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Iron) {
- r.setType(Material.IRON_ORE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Lapis) {
- r.setType(Material.LAPIS_ORE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Redstone) {
- r.setType(Material.REDSTONE_ORE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Gold) {
- r.setType(Material.GOLD_ORE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Diamond) {
- r.setType(Material.DIAMOND_ORE);
- i = 0;
- } else if (r.nextInt(100) <= CobbleOres.Emerald) {
- r.setType(Material.EMERALD_ORE);
- i = 0;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- private final BlockFace[] faces = {
- BlockFace.SELF,
- BlockFace.UP,
- BlockFace.DOWN,
- BlockFace.NORTH,
- BlockFace.EAST,
- BlockFace.SOUTH,
- BlockFace.WEST };
- private final BlockFace[] facesCobble = {
- BlockFace.NORTH,
- BlockFace.EAST,
- BlockFace.SOUTH,
- BlockFace.WEST };
- public boolean generatesCobble(int id, Block b)
- {
- int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8;
- int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9;
- for (BlockFace face : faces) {
- Block r = b.getRelative(face, 1);
- if ((r.getTypeId() == mirrorID1) || (r.getTypeId() == mirrorID2)) {
- return true;
- }
- }
- return false;
- }
- }
- COG
- ----
- package cog.stem;
- import org.bukkit.configuration.file.FileConfiguration;
- public class COG extends org.bukkit.plugin.java.JavaPlugin
- {
- public COG() {}
- 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;
- public static int Cobblestone = 45;
- public static int Coal = 35;
- public static int Iron = 25;
- public static int Lapis = 15;
- public static int Redstone = 15;
- public static int Gold = 10;
- public static int Diamond = 5;
- public static int Emerald = 1;
- public void onEnable() {
- new ListenerClass(this);
- if (getConfig().getString("Dont Remove") != null) {
- Cobblestone = getConfig().getInt("Cobblestone");
- Coal = getConfig().getInt("Coal");
- Iron = getConfig().getInt("Iron");
- Lapis = getConfig().getInt("Lapis");
- Redstone = getConfig().getInt("Redstone");
- Gold = getConfig().getInt("Gold");
- Diamond = getConfig().getInt("Diamond");
- Emerald = getConfig().getInt("Emerald");
- } else {
- getConfig().set("Cobblestone", Integer.valueOf(Cobblestone));
- getConfig().set("Coal", Integer.valueOf(Coal));
- getConfig().set("Iron", Integer.valueOf(Iron));
- getConfig().set("Lapis", Integer.valueOf(Lapis));
- getConfig().set("Redstone", Integer.valueOf(Redstone));
- getConfig().set("Gold", Integer.valueOf(Gold));
- getConfig().set("Diamond", Integer.valueOf(Diamond));
- getConfig().set("Emerald", Integer.valueOf(Emerald));
- }
- getConfig().set("Dont Remove", "Or Config Will Reset Also Don't Put Numbers Over 100");
- saveConfig();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement