Allow just one edit instance per resource

This commit is contained in:
Daniel Saukel 2016-07-11 20:38:18 +02:00
parent 4767d61198
commit 3fc5102020
2 changed files with 13 additions and 2 deletions

View File

@ -58,6 +58,11 @@ public class EditCommand extends BRCommand {
}
DResourceWorld resource = worlds.getResourceByName(mapName);
if (resource == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_MAP.getMessage(mapName));
return;
}
DEditWorld editWorld = resource.instantiateAsEditWorld();
DGroup dGroup = DGroup.getByPlayer(player);
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);

View File

@ -236,14 +236,20 @@ public class DResourceWorld {
}
/**
* @return an instance of this world
* @return an old or a new instance of this world.
*/
public DEditWorld instantiateAsEditWorld() {
for (DEditWorld instance : worlds.getEditWorlds()) {
if (instance.getName().equals(getName())) {
return instance;
}
}
return (DEditWorld) instantiate(false);
}
/**
* @return an instance of this world
* @return a new instance of this world
*/
public DGameWorld instantiateAsGameWorld() {
return (DGameWorld) instantiate(true);