Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.zoom4ikdan4ik.orecleaner.utils;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import java.util.logging.Logger;
- import org.bukkit.Chunk;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.block.BlockState;
- import org.bukkit.material.MaterialData;
- import ru.zoom4ikdan4ik.orecleaner.Main;
- import ru.zoom4ikdan4ik.orecleaner.managers.ConfigManager;
- public class Utils
- extends ConfigManager
- {
- protected static int chunks = 0;
- protected static int maxChunks = 0;
- private static String cleanList(String str)
- {
- return str.replace("[", "").replace("]", "");
- }
- private static List<Integer> changeToIntList(Object string)
- {
- List<Integer> list = new ArrayList();
- String str = cleanList(string.toString());
- String[] info = str.replace(":", " ").replace("%", "").split(" ");
- int id = 0;
- int meta = -1;
- int procent = 100;
- id = Integer.parseInt(info[0]);
- list.add(0, Integer.valueOf(id));
- if ((info.length > 1) && (info.length > 2))
- {
- meta = Byte.parseByte(info[1]);
- list.add(1, Integer.valueOf(meta));
- procent = Integer.parseInt(info[2]);
- list.add(2, Integer.valueOf(procent));
- }
- else
- {
- list.add(1, Integer.valueOf(meta));
- procent = Integer.parseInt(info[1]);
- list.add(2, Integer.valueOf(procent));
- }
- return list;
- }
- protected static void clearBlocks(World world, Chunk chunk)
- {
- Random random = new Random();
- Material material = Material.STONE;
- if (air) {
- material = Material.AIR;
- }
- int count = 0;
- for (int x = 0; x < 16; x++) {
- for (int z = 0; z < 16; z++) {
- for (int y = 0; y < 128; y++)
- {
- Block block = chunk.getBlock(x, y, z);
- Location location = block.getLocation();
- for (int j = 0; j < oreList.size(); j++)
- {
- List<Integer> blockInfo = changeToIntList(oreList.get(j));
- int id = ((Integer)blockInfo.get(0)).intValue();
- int meta = ((Integer)blockInfo.get(1)).intValue();
- int procent = ((Integer)blockInfo.get(2)).intValue();
- int blockId = block.getTypeId();
- byte blockMeta = block.getState().getData().getData();
- if ((id == blockId) &&
- ((meta == blockMeta) || (meta == -1)) && (
- (random.nextInt(100) + 1 >= procent) || (procent == 100)))
- {
- if (debugOre)
- {
- Main.log.info("-======-" + world.getName() + "-======-");
- Main.log.info("-======-������ ���� � ID: " + blockId + " Meta: " + blockMeta +
- "-======-");
- Main.log.info("X: " + location.getBlockX());
- Main.log.info("Y: " + location.getBlockY());
- Main.log.info("Z: " + location.getBlockZ());
- }
- block.setType(material);
- count++;
- }
- }
- }
- }
- }
- chunks += 1;
- if (debug) {
- Main.log.info("[" + chunks + "/" + maxChunks + "] " + "� ���� ����� ���� ������� " + count + " ���! " +
- chunks / (maxChunks / 100) + " %");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement