Permalink
Browse files

Order matters...

Signed-off-by: Chris Sanders <NinjaZidane@hotmail.com>
  • Loading branch information...
1 parent a65988b commit 2d76d8345711dca2190a4bb7ef93c8ab32054e4d Chris Sanders committed May 4, 2012
@@ -118,7 +118,7 @@
private final Random random = new Random();
private final CommonSecurityManager securityManager = new CommonSecurityManager(0); //TODO Need to integrate this/evaluate security in the engine.
private final CommonPluginManager pluginManager = new CommonPluginManager(this, securityManager, 0.0);
- private final ConsoleManager consoleManager = new ConsoleManager(this);
+ private final ConsoleManager consoleManager;
private final EntityManager entityManager = new EntityManager();
private final EventManager eventManager = new SimpleEventManager();
private final RecipeManager recipeManager = new CommonRecipeManager();
@@ -147,6 +147,7 @@
public SpoutEngine() {
super(1, new ThreadAsyncExecutor());
+ consoleManager = new ConsoleManager(this);
}
public void init(String[] args) {
@@ -171,7 +172,7 @@ public void start() {
// Register commands
getRootCommand().addSubCommands(this, AdministrationCommands.class, commandRegFactory);
getRootCommand().addSubCommands(this, MessagingCommands.class, commandRegFactory);
- if (Spout.getEngine().debugMode()) {
+ if (debugMode) {
getRootCommand().addSubCommands(this, TestCommands.class, commandRegFactory);
}
@@ -74,6 +74,9 @@
*/
private final ServerBootstrap bootstrap = new ServerBootstrap();
+ public SpoutServer() {
+ }
+
public static void main(String[] args) {
SpoutServer server = new SpoutServer();
Spout.setEngine(server);
@@ -83,7 +83,7 @@
* Portions are heavily based on CraftBukkit.
*/
public final class ConsoleManager {
- private final Engine server;
+ private final Engine engine;
private ConsoleReader reader;
private ColoredCommandSource source;
private ConsoleCommandThread thread;
@@ -95,12 +95,12 @@
private boolean running = true;
private boolean jLine = false;
- public ConsoleManager(Engine server) {
- this.server = server;
+ public ConsoleManager(Engine engine) {
+ this.engine = engine;
consoleHandler = new FancyConsoleHandler();
- String logFile = server.getLogFile();
+ String logFile = engine.getLogFile();
if (new File(logFile).getParentFile() != null) {
new File(logFile).getParentFile().mkdirs();
}
@@ -119,7 +119,7 @@ public ConsoleManager(Engine server) {
try {
reader = new ConsoleReader();
} catch (IOException ex) {
- server.getLogger().log(Level.SEVERE, "Exception initializing console reader: {0}", ex.getMessage());
+ engine.getLogger().log(Level.SEVERE, "Exception initializing console reader: {0}", ex.getMessage());
ex.printStackTrace();
}
@@ -205,7 +205,7 @@ public void refreshCommands() {
reader.removeCompletor(c);
}
- Completor[] list = new Completor[]{new SimpleCompletor(server.getAllCommands()), new NullCompletor()};
+ Completor[] list = new Completor[]{new SimpleCompletor(engine.getAllCommands()), new NullCompletor()};
reader.addCompletor(new ArgumentCompletor(list));
}
@@ -250,9 +250,9 @@ public void run() {
continue;
}
- server.getScheduler().scheduleAsyncDelayedTask(null, new CommandTask(command.trim()));
+ engine.getScheduler().scheduleAsyncDelayedTask(null, new CommandTask(command.trim()));
} catch (Exception ex) {
- server.getLogger().severe("Impossible exception while executing command: " + ex.getMessage());
+ engine.getLogger().severe("Impossible exception while executing command: " + ex.getMessage());
ex.printStackTrace();
}
}
@@ -268,7 +268,7 @@ public ServerShutdownThread() {
@Override
public void run() {
- server.stop();
+ engine.stop();
}
}
@@ -281,7 +281,7 @@ public CommandTask(String command) {
@Override
public void run() {
- server.processCommand(source, command);
+ engine.processCommand(source, command);
}
}
@@ -294,13 +294,13 @@ public String getName() {
@Override
public boolean sendMessage(String text) {
- server.getLogger().info(text);
+ engine.getLogger().info(text);
return true;
}
@Override
public boolean sendRawMessage(String text) {
- server.getLogger().info(text);
+ engine.getLogger().info(text);
return true;
}
@@ -351,7 +351,7 @@ public synchronized void flush() throws IOException {
super.reset();
if (record.length() > 0 && !record.equals(separator)) {
- server.getLogger().logp(level, "LoggerOutputStream", "log" + level, record);
+ engine.getLogger().logp(level, "LoggerOutputStream", "log" + level, record);
}
}
}
@@ -384,7 +384,7 @@ public synchronized void flush() {
super.flush();
}
} catch (IOException ex) {
- server.getLogger().severe("I/O exception flushing console output");
+ engine.getLogger().severe("I/O exception flushing console output");
ex.printStackTrace();
}
}
@@ -402,7 +402,7 @@ public RotatingFileHandler(String logFile) {
try {
setOutputStream(new FileOutputStream(filename, true));
} catch (FileNotFoundException ex) {
- server.getLogger().log(Level.SEVERE, "Unable to open {0} for writing: {1}", new Object[]{filename, ex.getMessage()});
+ engine.getLogger().log(Level.SEVERE, "Unable to open {0} for writing: {1}", new Object[]{filename, ex.getMessage()});
ex.printStackTrace();
}
}
@@ -411,11 +411,11 @@ public RotatingFileHandler(String logFile) {
public synchronized void flush() {
if (!filename.equals(calculateFilename())) {
filename = calculateFilename();
- server.getLogger().log(Level.INFO, "Log rotating to {0}...", filename);
+ engine.getLogger().log(Level.INFO, "Log rotating to {0}...", filename);
try {
setOutputStream(new FileOutputStream(filename, true));
} catch (FileNotFoundException ex) {
- server.getLogger().log(Level.SEVERE, "Unable to open {0} for writing: {1}", new Object[]{filename, ex.getMessage()});
+ engine.getLogger().log(Level.SEVERE, "Unable to open {0} for writing: {1}", new Object[]{filename, ex.getMessage()});
ex.printStackTrace();
}
}
@@ -490,15 +490,15 @@ public void keyReleased(KeyEvent e) {
@Override
public void windowClosing(WindowEvent e) {
- server.stop();
+ engine.stop();
}
@Override
public void keyTyped(KeyEvent e) {
if (e.getKeyChar() == '\n') {
String command = jInput.getText().trim();
if (command.length() > 0) {
- ((SpoutServer) server).getScheduler().scheduleAsyncDelayedTask(null, new CommandTask(command));
+ engine.getScheduler().scheduleAsyncDelayedTask(null, new CommandTask(command));
}
jInput.setText("");
}

0 comments on commit 2d76d83

Please sign in to comment.