Implement EditSessionFactory

This commit is contained in:
Ammar Askar
2012-10-18 15:34:09 +05:00
parent ae75061492
commit 04c00034cf
7 changed files with 85 additions and 13 deletions

View File

@ -112,6 +112,11 @@ public class WorldEdit {
*/
public static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
/**
* Holds the current instance of this class, for static access
*/
private static WorldEdit instance;
/**
* Holds WorldEdit's version.
*/
@ -131,6 +136,11 @@ public class WorldEdit {
* List of commands.
*/
private final CommandsManager<LocalPlayer> commands;
/**
* Holds the factory responsible for the creation of edit sessions
*/
private EditSessionFactory editSessionFactory = new EditSessionFactory();
/**
* Stores a list of WorldEdit sessions, keyed by players' names. Sessions
@ -155,6 +165,7 @@ public class WorldEdit {
* @param config
*/
public WorldEdit(ServerInterface server, final LocalConfiguration config) {
instance = this;
this.server = server;
this.config = config;
@ -253,6 +264,15 @@ public class WorldEdit {
server.onCommandRegistration(commands.registerAndReturn(clazz), commands);
}
/**
* Gets the current instance of this class
*
* @return
*/
public static WorldEdit getInstance() {
return instance;
}
/**
* Gets the LocalSession for a player name if it exists
*
@ -1529,6 +1549,28 @@ public class WorldEdit {
return server;
}
/**
* Get the edit session factory
*
* @return
*/
public EditSessionFactory getEditSessionFactory() {
return this.editSessionFactory;
}
/**
* Set the edit session factory
*
* @param factory
*/
public void setEditSessionFactory(EditSessionFactory factory) {
if (factory == null) {
throw new IllegalArgumentException("New EditSessionFactory may not be null");
}
logger.info("Accepted EditSessionFactory of type " + factory.getClass().getName() + " from " + factory.getClass().getPackage().getName());
this.editSessionFactory = factory;
}
/**
* Get the version.
*