Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void RegisterAllUnregisteredChests(double value, int tier)
- {
- // Bukkit, y u no give me World.getGeneratedChunks(); ?
- World world = Misc.getWorldOverworld(); // Misc.getOverworld is from my library.
- File regionDirectory = getRegionsLocation(world);
- if (regionDirectory == null)
- {
- SM.getPlugin().getLogger().severe("Unable to locate the region files for: " + world.getName());
- return;
- }
- File[] files = regionDirectory.listFiles(new FilenameFilter()
- {
- @Override
- public boolean accept(File dir, String name)
- { return name.toLowerCase().endsWith(".mca"); }
- });
- Pattern coordinatePattern = Pattern.compile("r\\.(.+)\\.(.+)\\.mca");
- for(File file : files)
- {
- Matcher matcher = coordinatePattern.matcher(file.getName());
- int regionX = 0;
- int regionZ = 0;
- if (matcher.find())
- {
- regionX = Integer.parseInt(matcher.group(1));
- regionZ = Integer.parseInt(matcher.group(2));
- }
- else
- {
- SM.getPlugin().getLogger().severe("Unable to handle region: " + file.getName()); // SM is a class containing static references to things like the plugin.
- continue;
- }
- regionX = regionX << 5;
- regionZ = regionZ << 5;
- RegionFile region = new RegionFile(file);
- for(int chunkX = 0; chunkX < 32; chunkX++)
- {
- for(int chunkZ = 0; chunkZ < 32; chunkZ++)
- {
- if(region.chunkExists(regionX + chunkX, regionZ + chunkZ))
- {
- for(BlockState block : world.getChunkAt(regionX + chunkX, regionZ + chunkZ).getTileEntities())
- {
- CoOrdinate coord = new CoOrdinate(block.getLocation());
- if(!this.containsKey(coord))
- this.addWithoutSorting(new ChestPosition(coord, tier, value));
- }
- }
- }
- }
- }
- this.sort();
- }
Advertisement
Add Comment
Please, Sign In to add comment