Added ServerInterface.getWorlds.

This commit is contained in:
TomyLobo 2011-12-15 11:49:44 +01:00
parent 32bb810ce7
commit 6d4b4718db
2 changed files with 23 additions and 0 deletions

View File

@ -19,6 +19,9 @@
package com.sk89q.worldedit;
import java.util.Collections;
import java.util.List;
/**
*
* @author sk89q
@ -57,4 +60,8 @@ public abstract class ServerInterface {
public int schedule(long delay, long period, Runnable task) {
return -1;
}
public List<LocalWorld> getWorlds() {
return Collections.emptyList();
}
}

View File

@ -19,8 +19,12 @@
package com.sk89q.worldedit.bukkit;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.*;
import org.bukkit.entity.CreatureType;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface;
public class BukkitServerInterface extends ServerInterface {
@ -52,4 +56,16 @@ public class BukkitServerInterface extends ServerInterface {
public int schedule(long delay, long period, Runnable task) {
return Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay, period);
}
@Override
public List<LocalWorld> getWorlds() {
List<World> worlds = server.getWorlds();
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
for (World world : worlds) {
ret.add(BukkitUtil.getLocalWorld(world));
}
return ret;
}
}