gt:         World world = BukkitUtil.getWorld(area.worldname);
context: package com.plotsquared.bukkit.util;
  
  import com.intellectualcrafters.plot.PS;
  import com.intellectualcrafters.plot.generator.AugmentedUtils;
  import com.intellectualcrafters.plot.object.BlockLoc;
  import com.intellectualcrafters.plot.object.ChunkLoc;
  import com.intellectualcrafters.plot.object.Location;
  import com.intellectualcrafters.plot.object.Plot;
  import com.intellectualcrafters.plot.object.PlotArea;
  import com.intellectualcrafters.plot.object.PlotBlock;
  import com.intellectualcrafters.plot.object.PlotLoc;
  import com.intellectualcrafters.plot.object.PlotPlayer;
  import com.intellectualcrafters.plot.object.RegionWrapper;
  import com.intellectualcrafters.plot.object.RunnableVal;
  import com.intellectualcrafters.plot.util.ChunkManager;
  import com.intellectualcrafters.plot.util.PlotChunk;
  import com.intellectualcrafters.plot.util.SetQueue;
  import com.intellectualcrafters.plot.util.StringMan;
  import com.intellectualcrafters.plot.util.TaskManager;
  import com.intellectualcrafters.plot.util.UUIDHandler;
  import com.intellectualcrafters.plot.util.WorldUtil;
  import com.plotsquared.bukkit.object.entity.EntityWrapper;
  import org.bukkit.Bukkit;
  import org.bukkit.Chunk;
  import org.bukkit.DyeColor;
  import org.bukkit.Material;
  import org.bukkit.Note;
  import org.bukkit.SkullType;
  import org.bukkit.World;
  import org.bukkit.block.Banner;
  import org.bukkit.block.Beacon;
  import org.bukkit.block.Block;
  import org.bukkit.block.BlockFace;
  import org.bukkit.block.BlockState;
  import org.bukkit.block.BrewingStand;
  import org.bukkit.block.CommandBlock;
  import org.bukkit.block.CreatureSpawner;
  import org.bukkit.block.Dispenser;
  import org.bukkit.block.Dropper;
  import org.bukkit.block.Furnace;
  import org.bukkit.block.Hopper;
  import org.bukkit.block.Jukebox;
  import org.bukkit.block.NoteBlock;
  import org.bukkit.block.Sign;
  import org.bukkit.block.Skull;
  import org.bukkit.block.banner.Pattern;
  import org.bukkit.entity.Animals;
  import org.bukkit.entity.Creature;
  import org.bukkit.entity.Entity;
  import org.bukkit.entity.EntityType;
  import org.bukkit.entity.Player;
  import org.bukkit.inventory.InventoryHolder;
  import org.bukkit.inventory.ItemStack;
  
  import java.util.ArrayDeque;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Map.Entry;
  import java.util.Set;
  
  public class BukkitChunkManager extends ChunkManager {
  
      public static boolean isIn(RegionWrapper region, int x, int z) {
          return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ;
      }
  
      private static byte getOrdinal(Object[] list, Object value) {
          for (byte i = 0; i < list.length; i++) {
              if (list[i].equals(value)) {
                  return i;
              }
          }
          return 0;
      }
  
      public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, RegionWrapper r1, RegionWrapper r2) {
          ContentMap map = new ContentMap();
          int relX = r2.minX - r1.minX;
          int relZ = r2.minZ - r1.minZ;
  
          map.saveEntitiesIn(pos1, r1, relX, relZ, true);
          map.saveEntitiesIn(pos2, r2, -relX, -relZ, true);
  
          int sx = pos1.getX() << 4;
          int sz = pos1.getZ() << 4;
  
          String worldName1 = world1.getName();
          String worldName2 = world2.getName();
  
          for (int x = Math.max(r1.minX, sx); x <= Math.min(r1.maxX, sx + 15); x++) {
              for (int z = Math.max(r1.minZ, sz); z <= Math.min(r1.maxZ, sz + 15); z++) {
                  map.saveBlocks(world1, 256, sx, sz, relX, relZ, false);
                  for (int y = 0; y < 256; y++) {
                      Block block1 = world1.getBlockAt(x, y, z);
                      int id1 = block1.getTypeId();
                      byte data1 = block1.getData();
                      int xx = x + relX;
                      int zz = z + relZ;
                      Block block2 = world2.getBlockAt(xx, y, zz);
                      int id2 = block2.getTypeId();
                      byte data2 = block2.getData();
                      if (id1 == 0) {
                          if (id2 != 0) {
                              SetQueue.IMP.setBlock(worldName1, x, y, z, (short) id2, data2);
                              SetQueue.IMP.setBlock(worldName2, xx, y, zz, (short) 0, (byte) 0);
                          }
                      } else if (id2 == 0) {
                          SetQueue.IMP.setBlock(worldName1, x, y, z, (short) 0, (byte) 0);
                          SetQueue.IMP.setBlock(worldName2, xx, y, zz, (short) id1, data1);
                      } else if (id1 == id2) {
                          if (data1 != data2) {
                              block1.setData(data2);
                              block2.setData(data1);
                          }
                      } else {
                          SetQueue.IMP.setBlock(worldName1, x, y, z, (short) id2, data2);
                          SetQueue.IMP.setBlock(worldName2, xx, y, zz, (short) id1, data1);
                      }
                  }
              }
          }
          return map;
      }
  
      @Override
      public Set<ChunkLoc> getChunkChunks(String world) {
          Set<ChunkLoc> chunks = super.getChunkChunks(world);
          for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
              ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
              if (!chunks.contains(loc)) {
                  chunks.add(loc);
              }
          }
          return chunks;
      }
  
      @Override
      public void regenerateChunk(String world, ChunkLoc loc) {
          World worldObj = Bukkit.getWorld(world);
          worldObj.regenerateChunk(loc.x, loc.z);
          SetQueue.IMP.queue.sendChunk(world, Collections.singletonList(loc));
          for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
              PlotPlayer pp = entry.getValue();
              Location pLoc = pp.getLocation();
              if (!StringMan.isEqual(world, pLoc.getWorld()) || !pLoc.getChunkLoc().equals(loc)) {
                  continue;
              }
              pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ()));
              pp.teleport(pLoc);
          }
      }
  
      @Override
      public boolean copyRegion(Location pos1, Location pos2, Location newPos, final Runnable whenDone) {
          final int relX = newPos.getX() - pos1.getX();
          final int relZ = newPos.getZ() - pos1.getZ();
          Location pos4 = new Location(newPos.getWorld(), newPos.getX() + relX, 256, newPos.getZ() + relZ);
  
          final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
          final World oldWorld = Bukkit.getWorld(pos1.getWorld());
          final World newWorld = Bukkit.getWorld(newPos.getWorld());
          final String newWorldName = newWorld.getName();
          List<ChunkLoc> chunks = new ArrayList<>();
          final ContentMap map = new ContentMap();
          ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
              @Override
              public void run(int[] value) {
                  int bx = value[2];
                  int bz = value[3];
                  int tx = value[4];
                  int tz = value[5];
                  ChunkLoc loc = new ChunkLoc(value[0], value[1]);
                  int cxx = loc.x << 4;
                  int czz = loc.z << 4;
                  Chunk chunk = oldWorld.getChunkAt(loc.x, loc.z);
                  map.saveEntitiesIn(chunk, region);
                  for (int x = bx & 15; x <= (tx & 15); x++) {
                      for (int z = bz & 15; z <= (tz & 15); z++) {
                          map.saveBlocks(oldWorld, 256, cxx + x, czz + z, relX, relZ, true);
                      }
                  }
              }
          }, new Runnable() {
              @Override
              public void run() {
                  for (Entry<PlotLoc, PlotBlock[]> entry : map.allBlocks.entrySet()) {
                      PlotLoc loc = entry.getKey();
                      PlotBlock[] blocks = entry.getValue();
                      for (int y = 0; y < blocks.length; y++) {
                          PlotBlock block = blocks[y];
                          if (block != null) {
                              SetQueue.IMP.setBlock(newWorldName, loc.x, y, loc.z, block);
                          }
                      }
                  }
                  SetQueue.IMP.addTask(new Runnable() {
                      @Override
                      public void run() {
                          map.restoreBlocks(newWorld, 0, 0);
                          map.restoreEntities(newWorld, relX, relZ);
                          TaskManager.runTask(whenDone);
                      }
                  });
              }
          }, 5);
          return true;
      }
  
      @Override
      public boolean regenerateRegion(final Location pos1, final Location pos2, final boolean ignoreAugment, final Runnable whenDone) {
          final String world = pos1.getWorld();
  
          final int p1x = pos1.getX();
          final int p1z = pos1.getZ();
          final int p2x = pos2.getX();
          final int p2z = pos2.getZ();
          final int bcx = p1x >> 4;
          final int bcz = p1z >> 4;
          final int tcx = p2x >> 4;
          final int tcz = p2z >> 4;
  
          final List<ChunkLoc> chunks = new ArrayList<>();
  
          for (int x = bcx; x <= tcx; x++) {
              for (int z = bcz; z <= tcz; z++) {
                  chunks.add(new ChunkLoc(x, z));
              }
          }
          final World worldObj = Bukkit.getWorld(world);
          TaskManager.runTask(new Runnable() {
              @Override
              public void run() {
                  long start = System.currentTimeMillis();
                  while (!chunks.isEmpty() && System.currentTimeMillis() - start < 5) {
                      final ChunkLoc chunk = chunks.remove(0);
                      int x = chunk.x;
                      int z = chunk.z;
                      int xxb = x << 4;
                      int zzb = z << 4;
                      int xxt = xxb + 15;
                      int zzt = zzb + 15;
                      Chunk chunkObj = worldObj.getChunkAt(x, z);
                      if (!chunkObj.load(false)) {
                          continue;
                      }
                      RegionWrapper currentPlotClear = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
                      if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
                          AugmentedUtils.bypass(ignoreAugment, new Runnable() {
                              @Override
                              public void run() {
                                  regenerateChunk(world, chunk);
                              }
                          });
                          continue;
                      }
                      boolean checkX1 = false;
  
                      int xxb2;
  
                      if (x == bcx) {
                          xxb2 = p1x - 1;
                          checkX1 = true;
                      } else {
                          xxb2 = xxb;
                      }
                      boolean checkX2 = false;
                      int xxt2;
                      if (x == tcx) {
                          xxt2 = p2x + 1;
                          checkX2 = true;
                      } else {
                          xxt2 = xxt;
                      }
                      boolean checkZ1 = false;
                      int zzb2;
                      if (z == bcz) {
                          zzb2 = p1z - 1;
                          checkZ1 = true;
                      } else {
                          zzb2 = zzb;
                      }
                      boolean checkZ2 = false;
                      int zzt2;
                      if (z == tcz) {
                          zzt2 = p2z + 1;
                          checkZ2 = true;
                      } else {
                          zzt2 = zzt;
                      }
                      final ContentMap map = new ContentMap();
                      if (checkX1) {
                          map.saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); //
                      }
                      if (checkX2) {
                          map.saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); //
                      }
                      if (checkZ1) {
                          map.saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); //
                      }
                      if (checkZ2) {
                          map.saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); //
                      }
                      if (checkX1 && checkZ1) {
                          map.saveRegion(worldObj, xxb, xxb2, zzb, zzb2); //
                      }
                      if (checkX2 && checkZ1) {
                          map.saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ?
                      }
                      if (checkX1 && checkZ2) {
                          map.saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ?
                      }
                      if (checkX2 && checkZ2) {
                          map.saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
                      }
                      map.saveEntitiesOut(chunkObj, currentPlotClear);
                      AugmentedUtils.bypass(ignoreAugment, new Runnable() {
                          @Override
                          public void run() {
                              setChunkInPlotArea(null, new RunnableVal<PlotChunk<?>>() {
                                  @Override
                                  public void run(PlotChunk<?> value) {
                                      int cx = value.getX();
                                      int cz = value.getZ();
                                      int bx = cx << 4;
                                      int bz = cz << 4;
                                      for (int x = 0; x < 16; x++) {
                                          for (int z = 0; z < 16; z++) {
                                              PlotLoc loc = new PlotLoc(bx + x, bz + z);
                                              PlotBlock[] ids = map.allBlocks.get(loc);
                                              if (ids != null) {
                                                  for (int y = 0; y < Math.min(128, ids.length); y++) {
                                                      PlotBlock id = ids[y];
                                                      if (id != null) {
                                                          value.setBlock(x, y, z, id);
                                                      } else {
                                                          value.setBlock(x, y, z, 0, (byte) 0);
                                                      }
                                                  }
                                                  for (int y = Math.min(128, ids.length); y < ids.length; y++) {
                                                      PlotBlock id = ids[y];
                                                      if (id != null) {
                                                          value.setBlock(x, y, z, id);
                                                      }
                                                  }
                                              }
                                          }
                                      }
                                  }
                              }, world, chunk);
                          }
                      });
                      map.restoreBlocks(worldObj, 0, 0);
                      map.restoreEntities(worldObj, 0, 0);
                  }
                  if (!chunks.isEmpty()) {
                      TaskManager.runTaskLater(this, 1);
                  } else {
                      TaskManager.runTaskLater(whenDone, 1);
                  }
              }
          });
          return true;
      }
  
      @Override
      public void clearAllEntities(Location pos1, Location pos2) {
          String world = pos1.getWorld();
          List<Entity> entities = BukkitUtil.getEntities(world);
          int bx = pos1.getX();
          int bz = pos1.getZ();
          int tx = pos2.getX();
          int tz = pos2.getZ();
          for (Entity entity : entities) {
              if (!(entity instanceof Player)) {
                  org.bukkit.Location loc = entity.getLocation();
                  if (loc.getX() >= bx && loc.getX() <= tx && loc.getZ() >= bz && loc.getZ() <= tz) {
                      entity.remove();
                  }
              }
          }
      }
  
      @Override
      public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
          return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
      }
  
      @SuppressWarnings("deprecation")
      @Override
      public void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe) {
          if (!PS.get().isMainThread(Thread.currentThread())) {
              TaskManager.runTask(new Runnable() {
                  @SuppressWarnings("deprecation")
                  @Override
                  public void run() {
                      BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
                  }
              });
          } else {
              BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
          }
      }
  
      @Override
      public void swap(Location bot1, Location top1, Location bot2, Location top2, final Runnable whenDone) {
          RegionWrapper region1 = new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
          RegionWrapper region2 = new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
          final World world1 = Bukkit.getWorld(bot1.getWorld());
          World world2 = Bukkit.getWorld(bot2.getWorld());
  
          int relX = bot2.getX() - bot1.getX();
          int relZ = bot2.getZ() - bot1.getZ();
  
          final ArrayDeque<ContentMap> maps = new ArrayDeque<>();
  
          for (int x = bot1.getX() >> 4; x <= top1.getX() >> 4; x++) {
              for (int z = bot1.getZ() >> 4; z <= top1.getZ() >> 4; z++) {
                  Chunk chunk1 = world1.getChunkAt(x, z);
                  Chunk chunk2 = world2.getChunkAt(x + (relX >> 4), z + (relZ >> 4));
                  maps.add(swapChunk(world1, world2, chunk1, chunk2, region1, region2));
              }
          }
          SetQueue.IMP.addTask(new Runnable() {
              @Override
              public void run() {
                  for (ContentMap map : maps) {
                      map.restoreBlocks(world1, 0, 0);
                      map.restoreEntities(world1, 0, 0);
                      TaskManager.runTaskLater(whenDone, 1);
                  }
              }
          });
      }
  
      @Override
      public int[] countEntities(Plot plot) {
          PlotArea area = plot.getArea();
  