-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17473c5
Showing
34 changed files
with
9,727 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Compiled source # | ||
################### | ||
bin | ||
lib | ||
out | ||
target | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
|
||
# Git # | ||
####### | ||
.git | ||
|
||
# Packages # | ||
############ | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
|
||
# Logs and databases # | ||
###################### | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# OS generated files # | ||
###################### | ||
.DS_Store | ||
ehthumbs.db | ||
Icon? | ||
Thumbs.db | ||
|
||
# Project files # | ||
################# | ||
.classpath | ||
.externalToolBuilders | ||
.project | ||
.settings | ||
MANIFEST.MF | ||
|
||
# Netbeans files # | ||
################## | ||
build | ||
dist | ||
nbproject | ||
build.xml | ||
nb-configuration.xml | ||
|
||
# IntelliJ IDEA files # | ||
####################### | ||
.idea | ||
*.iml | ||
*.ipr | ||
*.iws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.spout</groupId> | ||
<artifactId>flo</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>Flo</name> | ||
<description>A Control Panel for Spout Servers</description> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.spout</groupId> | ||
<artifactId>spoutapi</artifactId> | ||
<version>dev-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.narrowtux</groupId> | ||
<artifactId>blueberry</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.yaml</groupId> | ||
<artifactId>snakeyaml</artifactId> | ||
<version>1.10</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.3</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.1</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.2.2</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.spout.flo; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.spout.flo.server.Server; | ||
import org.spout.flo.web.FloWebServer; | ||
|
||
public class Flo { | ||
private static Flo instance = null; | ||
|
||
public static Flo instance() { | ||
return instance; | ||
} | ||
|
||
private FloWebServer webServer; | ||
private List<Server> servers = new LinkedList<Server>(); | ||
|
||
Flo () { | ||
instance = this; | ||
webServer = new FloWebServer(); | ||
|
||
Runtime.getRuntime().addShutdownHook(new Thread() { | ||
@Override | ||
public void run() { | ||
Flo.instance().stop(); | ||
} | ||
}); | ||
} | ||
|
||
public void stop() { | ||
webServer.stop(); | ||
} | ||
|
||
public List<Server> getServers() { | ||
return servers; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.spout.flo; | ||
|
||
public class Start { | ||
public static void main(String args[]) { | ||
@SuppressWarnings("unused") | ||
Flo flo = new Flo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.spout.flo.server; | ||
|
||
public class Plugin { | ||
|
||
boolean enabled = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.spout.flo.server; | ||
|
||
public class PluginException extends Exception { | ||
private static final long serialVersionUID = -5864237892530538787L; | ||
|
||
public PluginException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.spout.flo.server; | ||
|
||
import java.util.List; | ||
|
||
public abstract class PluginManager { | ||
private Server parent; | ||
|
||
protected PluginManager(Server parent) { | ||
this.parent = parent; | ||
} | ||
|
||
/** | ||
* Gets the server this plugin manager works on | ||
* @return the server of this plugin manager | ||
*/ | ||
public Server getServer() { | ||
return parent; | ||
} | ||
|
||
/** | ||
* Enables or disables the given plugin | ||
* @param plugin the plugin to enable/disable | ||
* @param enabled true to enable, false to disable | ||
* @throws PluginException when an error occurs | ||
*/ | ||
public abstract void setPluginEnabled(Plugin plugin, boolean enabled) throws PluginException; | ||
|
||
/** | ||
* Installs a plugin on the server | ||
* @param toInstall the plugin to install | ||
* @throws PluginException when an error occurs | ||
*/ | ||
public abstract void installPlugin(Plugin toInstall) throws PluginException; | ||
|
||
/** | ||
* Removes a plugin from the server | ||
* @param toRemove the plugin to remove | ||
* @throws PluginException when an error occurs | ||
*/ | ||
public abstract void removePlugin(Plugin toRemove) throws PluginException; | ||
|
||
/** | ||
* Gets a list of all installed plugins, wether they are enabled or not | ||
* @return a list of all installed plugins | ||
*/ | ||
public abstract List<Plugin> getInstalledPlugins(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.spout.flo.server; | ||
|
||
import org.spout.api.signal.Signal; | ||
import org.spout.api.signal.SignalSubscriberObject; | ||
|
||
public abstract class Server extends SignalSubscriberObject { | ||
/** | ||
* Emitted when the servers status changes. | ||
* @sarg org.spout.flo.server.ServerStatus the new status of the server | ||
*/ | ||
public static final Signal SIGNAL_STATUS_CHANGE = new Signal("STATUS_CHANGE", ServerStatus.class); | ||
|
||
/** | ||
* Emitted when the servers console printed a new message | ||
* @sarg java.lang.String the message | ||
*/ | ||
public static final Signal SIGNAL_CONSOLE_MESSAGE = new Signal("CONSOLE_MESSAGE", String.class); | ||
|
||
/** | ||
* Emitted when an error occurs that should be sent to watching web frontends | ||
* @sarg java.lang.String the message | ||
*/ | ||
public static final Signal SIGNAL_ERROR = new Signal("ERROR", String.class); | ||
|
||
private String name; | ||
|
||
public Server() { | ||
registerSignal(SIGNAL_CONSOLE_MESSAGE); | ||
registerSignal(SIGNAL_STATUS_CHANGE); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getVersion() { | ||
return "0"; | ||
} | ||
|
||
public abstract PluginManager getPluginManager(); | ||
|
||
public abstract ServerStatus getStatus(); | ||
|
||
public abstract void start(); | ||
|
||
public abstract void stop(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.spout.flo.server; | ||
|
||
/** | ||
* Represents the current status of a server | ||
*/ | ||
public enum ServerStatus { | ||
/** | ||
* When the server is completely shut down | ||
*/ | ||
STOPPED(false), | ||
/** | ||
* When the server is starting up, but not ready for players yet | ||
*/ | ||
STARTING(true), | ||
/** | ||
* When the server is running and ready for players | ||
*/ | ||
STARTED(true), | ||
/** | ||
* When the server is currently shutting down | ||
*/ | ||
STOPPING(true), | ||
/** | ||
* When the server or the JVM have crashed | ||
*/ | ||
CRASHED(false), | ||
/** | ||
* When the server doesn't react to status polls | ||
*/ | ||
UNRESPONSIVE(true), ; | ||
|
||
private final boolean isRunning; | ||
|
||
private ServerStatus(boolean running) { | ||
this.isRunning = running; | ||
} | ||
|
||
public boolean isRunning() { | ||
return isRunning; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/spout/flo/server/SpoutPluginManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.spout.flo.server; | ||
|
||
import java.util.List; | ||
|
||
public class SpoutPluginManager extends PluginManager { | ||
|
||
public SpoutPluginManager(Server parent) { | ||
super(parent); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
@Override | ||
public void setPluginEnabled(Plugin plugin, boolean enabled) throws PluginException { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void installPlugin(Plugin toInstall) throws PluginException { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void removePlugin(Plugin toRemove) throws PluginException { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public List<Plugin> getInstalledPlugins() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.spout.flo.server; | ||
|
||
public class SpoutServer extends Server { | ||
SpoutPluginManager pluginManager; | ||
ServerStatus status = ServerStatus.STOPPED; | ||
|
||
@Override | ||
public PluginManager getPluginManager() { | ||
return pluginManager; | ||
} | ||
|
||
@Override | ||
public ServerStatus getStatus() { | ||
return status; | ||
} | ||
|
||
@Override | ||
public void start() { | ||
if (!getStatus().isRunning()) { // Only start the server if not already started | ||
emit(SIGNAL_STATUS_CHANGE, ServerStatus.STARTING); | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
if (getStatus().isRunning()) { // Only stop the server if not already stopped | ||
emit(SIGNAL_STATUS_CHANGE, ServerStatus.STOPPING); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.