mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
#506 Refactor WorldUnloadTask
This commit is contained in:
parent
7bc16b9aff
commit
8c117c8e2b
@ -17,7 +17,7 @@
|
|||||||
package de.erethon.dungeonsxl.world;
|
package de.erethon.dungeonsxl.world;
|
||||||
|
|
||||||
import de.erethon.dungeonsxl.DungeonsXL;
|
import de.erethon.dungeonsxl.DungeonsXL;
|
||||||
import de.erethon.dungeonsxl.player.DGamePlayer;
|
import java.util.Set;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,20 +33,12 @@ public class WorldUnloadTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (DGameWorld gameWorld : plugin.getDWorldCache().getGameWorlds()) {
|
Set<DInstanceWorld> instances = plugin.getDWorldCache().getInstances();
|
||||||
if (gameWorld.exists()) {
|
System.out.println(instances);
|
||||||
if (gameWorld.getWorld().getPlayers().isEmpty()) {
|
for (DInstanceWorld instance : instances.toArray(new DInstanceWorld[instances.size()])) {
|
||||||
if (DGamePlayer.getByWorld(gameWorld.getWorld()).isEmpty()) {
|
if (instance.exists()) {
|
||||||
gameWorld.delete();
|
if (instance.getWorld().getPlayers().isEmpty()) {
|
||||||
}
|
instance.delete();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DEditWorld editWorld : plugin.getDWorldCache().getEditWorlds()) {
|
|
||||||
if (editWorld.exists()) {
|
|
||||||
if (editWorld.getWorld().getPlayers().isEmpty()) {
|
|
||||||
editWorld.delete(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user