SHARE
TWEET

Untitled

a guest Jul 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ru.zoom4ikdan4ik.orecleaner.utils;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Random;
  6. import java.util.logging.Logger;
  7. import org.bukkit.Chunk;
  8. import org.bukkit.Location;
  9. import org.bukkit.Material;
  10. import org.bukkit.World;
  11. import org.bukkit.block.Block;
  12. import org.bukkit.block.BlockState;
  13. import org.bukkit.material.MaterialData;
  14. import ru.zoom4ikdan4ik.orecleaner.Main;
  15. import ru.zoom4ikdan4ik.orecleaner.managers.ConfigManager;
  16.  
  17. public class Utils
  18.   extends ConfigManager
  19. {
  20.   protected static int chunks = 0;
  21.   protected static int maxChunks = 0;
  22.  
  23.   private static String cleanList(String str)
  24.   {
  25.     return str.replace("[", "").replace("]", "");
  26.   }
  27.  
  28.   private static List<Integer> changeToIntList(Object string)
  29.   {
  30.     List<Integer> list = new ArrayList();
  31.     String str = cleanList(string.toString());
  32.     String[] info = str.replace(":", " ").replace("%", "").split(" ");
  33.     int id = 0;
  34.     int meta = -1;
  35.     int procent = 100;
  36.     id = Integer.parseInt(info[0]);
  37.     list.add(0, Integer.valueOf(id));
  38.     if ((info.length > 1) && (info.length > 2))
  39.     {
  40.       meta = Byte.parseByte(info[1]);
  41.       list.add(1, Integer.valueOf(meta));
  42.       procent = Integer.parseInt(info[2]);
  43.       list.add(2, Integer.valueOf(procent));
  44.     }
  45.     else
  46.     {
  47.       list.add(1, Integer.valueOf(meta));
  48.       procent = Integer.parseInt(info[1]);
  49.       list.add(2, Integer.valueOf(procent));
  50.     }
  51.     return list;
  52.   }
  53.  
  54.   protected static void clearBlocks(World world, Chunk chunk)
  55.   {
  56.     Random random = new Random();
  57.     Material material = Material.STONE;
  58.     if (air) {
  59.       material = Material.AIR;
  60.     }
  61.     int count = 0;
  62.     for (int x = 0; x < 16; x++) {
  63.       for (int z = 0; z < 16; z++) {
  64.         for (int y = 0; y < 128; y++)
  65.         {
  66.           Block block = chunk.getBlock(x, y, z);
  67.           Location location = block.getLocation();
  68.           for (int j = 0; j < oreList.size(); j++)
  69.           {
  70.             List<Integer> blockInfo = changeToIntList(oreList.get(j));
  71.             int id = ((Integer)blockInfo.get(0)).intValue();
  72.             int meta = ((Integer)blockInfo.get(1)).intValue();
  73.             int procent = ((Integer)blockInfo.get(2)).intValue();
  74.             int blockId = block.getTypeId();
  75.             byte blockMeta = block.getState().getData().getData();
  76.             if ((id == blockId) &&
  77.               ((meta == blockMeta) || (meta == -1)) && (
  78.               (random.nextInt(100) + 1 >= procent) || (procent == 100)))
  79.             {
  80.               if (debugOre)
  81.               {
  82.                 Main.log.info("-======-" + world.getName() + "-======-");
  83.                 Main.log.info("-======-������ ���� � ID: " + blockId + " Meta: " + blockMeta +
  84.                   "-======-");
  85.                 Main.log.info("X: " + location.getBlockX());
  86.                 Main.log.info("Y: " + location.getBlockY());
  87.                 Main.log.info("Z: " + location.getBlockZ());
  88.               }
  89.               block.setType(material);
  90.               count++;
  91.             }
  92.           }
  93.         }
  94.       }
  95.     }
  96.     chunks += 1;
  97.     if (debug) {
  98.       Main.log.info("[" + chunks + "/" + maxChunks + "] " + "� ���� ����� ���� ������� " + count + " ���! " +
  99.         chunks / (maxChunks / 100) + " %");
  100.     }
  101.   }
  102. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top