Implemented new Server methods (getWorld + changes to createWorld)
Dieser Commit ist enthalten in:
Ursprung
50e42496e3
Commit
6751433a8e
@ -136,6 +136,8 @@ public class World implements IBlockAccess {
|
|||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Craftbukkit start
|
||||||
|
|
||||||
this.q = (WorldProvider) object;
|
this.q = (WorldProvider) object;
|
||||||
this.q.a(this);
|
this.q.a(this);
|
||||||
this.G = this.a(this.t);
|
this.G = this.a(this.t);
|
||||||
|
@ -4,7 +4,9 @@ import org.bukkit.command.*;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.minecraft.server.EntityPlayer;
|
import net.minecraft.server.EntityPlayer;
|
||||||
@ -30,6 +32,7 @@ public final class CraftServer implements Server {
|
|||||||
private final CommandMap commandMap = new SimpleCommandMap(this);
|
private final CommandMap commandMap = new SimpleCommandMap(this);
|
||||||
protected final MinecraftServer console;
|
protected final MinecraftServer console;
|
||||||
protected final ServerConfigurationManager server;
|
protected final ServerConfigurationManager server;
|
||||||
|
private final Map<String, World> worlds = new HashMap<String, World>();
|
||||||
|
|
||||||
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
|
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
|
||||||
this.console = console;
|
this.console = console;
|
||||||
@ -155,15 +158,7 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<World> getWorlds() {
|
public List<World> getWorlds() {
|
||||||
List<World> worlds = new ArrayList<World>();
|
return new ArrayList<World>(worlds.values());
|
||||||
|
|
||||||
synchronized (console.worlds) {
|
|
||||||
for (WorldServer world : console.worlds) {
|
|
||||||
worlds.add(world.getWorld());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return worlds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerConfigurationManager getHandle() {
|
public ServerConfigurationManager getHandle() {
|
||||||
@ -203,6 +198,11 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
public World createWorld(String name, World.Environment environment) {
|
public World createWorld(String name, World.Environment environment) {
|
||||||
File folder = new File(name);
|
File folder = new File(name);
|
||||||
|
World world = getWorld(name);
|
||||||
|
|
||||||
|
if (world != null) {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
if ((folder.exists()) && (!folder.isDirectory())) {
|
if ((folder.exists()) && (!folder.isDirectory())) {
|
||||||
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
|
||||||
@ -248,4 +248,12 @@ public final class CraftServer implements Server {
|
|||||||
public MinecraftServer getServer() {
|
public MinecraftServer getServer() {
|
||||||
return console;
|
return console;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public World getWorld(String name) {
|
||||||
|
return worlds.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWorld(World world) {
|
||||||
|
worlds.put(world.getName().toLowerCase(), world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,21 @@ import org.bukkit.World;
|
|||||||
public class CraftWorld implements World {
|
public class CraftWorld implements World {
|
||||||
private final WorldServer world;
|
private final WorldServer world;
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
private final CraftServer server;
|
||||||
|
|
||||||
private static final Random rand = new Random();
|
private static final Random rand = new Random();
|
||||||
|
|
||||||
public CraftWorld(WorldServer world) {
|
public CraftWorld(WorldServer world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.server = world.getServer();
|
||||||
|
|
||||||
if (world.q instanceof WorldProviderHell) {
|
if (world.q instanceof WorldProviderHell) {
|
||||||
environment = Environment.NETHER;
|
environment = Environment.NETHER;
|
||||||
} else {
|
} else {
|
||||||
environment = Environment.NORMAL;
|
environment = Environment.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.addWorld(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getBlockAt(int x, int y, int z) {
|
public Block getBlockAt(int x, int y, int z) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren