Пример #1
0
 public static void abort(boolean process) {
   Task.stop(task);
   if (process && task != null) {
     for (ChunkCoord chunkTask : task.remaining) {
       chunkTask.process();
     }
   }
   task = null;
 }
Пример #2
0
 @Override
 public void run() {
   // Load a maximum of 10 chunks at a time
   for (int i = 0; i < 10; ) {
     ChunkCoord next = remaining.poll();
     if (next == null) {
       abort(false);
       break;
     } else if (next.process()) {
       i++;
     }
   }
 }
Пример #3
0
 public static void add(World world, int cx, int cz, Runnable taskWhenFinished) {
   ChunkCoord coord = new ChunkCoord();
   coord.x = cx;
   coord.z = cz;
   coord.world = world;
   coord.taskWhenFinished = taskWhenFinished;
   if (task == null) {
     task = new LoadChunksTask();
     task.start(0, 1);
   }
   synchronized (task) {
     task.remaining.offer(coord);
   }
 }
Пример #4
0
 public static void abortWorld(World world, boolean process) {
   if (task == null) {
     return;
   }
   Iterator<ChunkCoord> iter = task.remaining.iterator();
   while (iter.hasNext()) {
     ChunkCoord coord = iter.next();
     if (coord.world == world) {
       iter.remove();
       if (process) {
         coord.process();
       }
     }
   }
 }