Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SneakyThrows
- public void restoreWorld(final Arena arena) {
- checkApplicable(arena);
- final Region region = arena.getSettings().getRegion();
- final World world = region.getWorld();
- for (final Player player : world.getPlayers())
- player.kickPlayer("World is getting restored.");
- processedWorlds.add(world);
- final List<Block> blocks = region.getBlocks();
- new ChunkedTask(100_000) {
- final Set<Chunk> chunks = new HashSet<>();
- @Override
- protected void onProcess(final int index) {
- final Block block = blocks.get(index);
- chunks.add(block.getChunk());
- }
- @Override
- protected boolean canContinue(final int index) {
- return index < blocks.size();
- }
- @Override
- protected String getLabel() {
- return "blocks";
- }
- @Override
- protected void onFinish() {
- Common.log("Arena " + arena.getName() + " finished converting blocks to chunks.");
- System.out.println("Auto save: " + world.isAutoSave());
- new ChunkedTask(50) {
- final List<Chunk> chunksCopy = new ArrayList<>(chunks);
- @Override
- protected void onProcess(final int index) {
- final Chunk chunk = chunksCopy.get(index);
- System.out.println("Auto save: " + world.isAutoSave());
- chunk.unload(false);
- chunk.load(false);
- }
- @Override
- protected boolean canContinue(final int index) {
- return index < chunksCopy.size();
- }
- @Override
- protected String getLabel() {
- return "chunks";
- }
- @Override
- protected void onFinish() {
- Common.log("Arena " + arena.getName() + " finished resetting world " + world.getName() + ".");
- processedWorlds.remove(world);
- System.out.println("Auto save: " + world.isAutoSave());
- }
- }.startChain();
- }
- }.startChain();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement