Skip to content

Commit

Permalink
Partial commit. Changes include:
Browse files Browse the repository at this point in the history
- Removed world manager (to be replaced)
- Added support for '*' in the CLI.
- Reworked restart timer to actually work.
- Changed some internals for (hopefully) better performance.
- Removed out of date java8 options, since we require java8 anyway.
- Removed permgen (java8 again).
- Cleaned up some code.
  • Loading branch information
dries007 committed Jul 16, 2017
1 parent 88b45e4 commit 4824afc
Show file tree
Hide file tree
Showing 43 changed files with 616 additions and 658 deletions.
17 changes: 3 additions & 14 deletions README.md
Expand Up @@ -21,24 +21,13 @@ Typos? [Go here.](https://github.com/DoubleDoorDevelopment/D3Backend/issues/10)
1. Tell us what you clicked exactly (if applicable)
1. If we ask you for more information and you don't replay within 14 days, the issue will be considerer inactive.

ToDo
----

- [ ] Implement email system
- [ ] Implement a server wrapper
- [ ] Shut the actual server down if empty, restart if someone connects.
- [ ] Keep clients connected during server restart
- [ ] Multi 'node' support
- [ ] Add a 'look and feel' config (change name, add bootstrap theme, ...)
- [ ] In release: Use minified js and css

HttpS
-----
Http**S**
---------

Step 1: Make a jks file.<br>
Option 1: [Self signed certificate](https://www.sslshopper.com/article-how-to-create-a-self-signed-certificate-using-java-keytool.html) Please use this for internal network or testing only.<br>
Option 2: [Proper, CA signed certificate](https://docs.oracle.com/cd/E19798-01/821-1751/ghlgv/index.html)<br>
**Protip:** [CA signed certificates don't have to be expensive...](https://www.startssl.com/)<br>
**ProTip:** Have a look at LetsEncrypt for a free signed SSL cert. There is no support for it in our backend, but you can run the tool externally.

Step 2: Put the path (relative to run dir or absolute) and password in the config file.

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -16,7 +16,7 @@ apply plugin: "idea-utils"
archivesBaseName = "D3Backend"
group = "net.doubledoordev.backend"

version = "0.10.2"
version = "0.11.0"
if (System.getenv().BUILD_NUMBER != null) version += "." + System.getenv().BUILD_NUMBER

def vendor = "DoubleDoorDevelopment"
Expand Down
1 change: 1 addition & 0 deletions src/main/java/freemarker_implicit.ftl
Expand Up @@ -3,5 +3,6 @@
[#-- @ftlvariable name="fm" type="net.doubledoordev.backend.server.FileManager" --]
[#-- @ftlvariable name="user" type="net.doubledoordev.backend.permissions.User" --]
[#-- @ftlvariable name="server" type="net.doubledoordev.backend.server.Server" --]
[#-- @ftlvariable name="wm" type="net.doubledoordev.backend.server.WorldManager" --]
[#-- @ftlvariable name="Helper" type="net.doubledoordev.backend.util.Helper" --]
[#-- @ftlvariable name="Settings" type="net.doubledoordev.backend.util.Settings" --]
16 changes: 6 additions & 10 deletions src/main/java/net/doubledoordev/backend/Main.java
Expand Up @@ -118,7 +118,6 @@ public static void main(String[] args) throws Exception
if (debug) LOGGER.info("DEBUG MODE");
if (safe) LOGGER.info("SAFE MODE");

// todo: get JDK and classload tools.jar + native library; if not jdk: disable warmroast
LOGGER.info("\n\n D3Backend Copyright (C) 2015 - 2016 Dries007 & Double Door Development\n" +
" This program comes with ABSOLUTELY NO WARRANTY;\n" +
" This is free software, and you are welcome to redistribute it under certain conditions;\n" +
Expand All @@ -129,7 +128,10 @@ public static void main(String[] args) throws Exception
for (Object key : properties.keySet()) LOGGER.info("- {} = {}", key, properties.get(key));

LOGGER.info("Making necessary folders...");
mkdirs();
//noinspection ResultOfMethodCallIgnored
Constants.SERVERS.mkdir();
//noinspection ResultOfMethodCallIgnored
Constants.BACKUPS.mkdir();
LOGGER.info("Starting webserver...");

final HttpServer webserver = new HttpServer();
Expand Down Expand Up @@ -182,7 +184,7 @@ public static void main(String[] args) throws Exception
adminKey = UUID.randomUUID().toString();
LOGGER.warn("Your userlist is empty.");
LOGGER.warn("Make a new account and use the special admin token in the '2 + 2 = ?' field.");
LOGGER.warn("You can only use this key once. It will be regenerated if the userlist is empty when the backend starts.");
LOGGER.warn("You can only use this key once. It will be regenerated if the user list is empty when the backend starts.");
LOGGER.warn("Admin token: " + adminKey);
}

Expand All @@ -204,17 +206,11 @@ public static void main(String[] args) throws Exception
}
}

@SuppressWarnings("ResultOfMethodCallIgnored")
private static void mkdirs()
{
Constants.SERVERS.mkdir();
}

public static synchronized void shutdown()
{
running = false;
Cache.stop();
Settings.save();
Cache.init();
LOGGER.info("Attempting graceful shutdown of all servers...");
for (final Server server : SETTINGS.servers.values())
{
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/net/doubledoordev/backend/commands/Bindings.java
Expand Up @@ -45,7 +45,11 @@ public Server getServer(ArgumentStack context) throws ParameterException
@BindingMatch(type = Server[].class, behavior = BindingBehavior.CONSUMES)
public Server[] getServers(ArgumentStack context) throws ParameterException
{
Pattern pattern = Pattern.compile(context.next());
String selector = context.next();
if (Settings.getServerByName(selector) != null) return new Server[]{Settings.getServerByName(selector)};
if (selector.equals("*")) return Settings.SETTINGS.servers.values().toArray(new Server[0]);

Pattern pattern = Pattern.compile(selector);
List<Server> servers = new ArrayList<>();
for (Server server : Settings.SETTINGS.servers.values()) if (pattern.matcher(server.getID()).matches()) servers.add(server);
return servers.toArray(new Server[servers.size()]);
Expand All @@ -60,7 +64,11 @@ public User getUser(ArgumentStack context) throws ParameterException
@BindingMatch(type = User[].class, behavior = BindingBehavior.CONSUMES, consumedCount = 1)
public User[] getUsers(ArgumentStack context) throws ParameterException
{
Pattern pattern = Pattern.compile(context.next());
String selector = context.next();
if (Settings.getUserByName(selector) != null) return new User[]{Settings.getUserByName(selector)};
if (selector.equals("*")) return Settings.SETTINGS.users.values().toArray(new User[0]);

Pattern pattern = Pattern.compile(selector);
List<User> users = new ArrayList<>();
for (User server : Settings.SETTINGS.users.values()) if (pattern.matcher(server.getUsername()).matches()) users.add(server);
return users.toArray(new User[users.size()]);
Expand Down
Expand Up @@ -153,8 +153,7 @@ public void run()
return;
}

//todo: open gui
JOptionPane.showMessageDialog(null, "You opened D3Backend without a console. Since we don't have a gui yet, and we need input for commands, this is not supported.\nUse a commandline enviroment to open the jar for now.");
JOptionPane.showMessageDialog(null, "You opened D3Backend without a console. Use a commandline environment to open the jar for now.");
System.exit(1);
}

Expand Down
Expand Up @@ -28,7 +28,7 @@
import java.util.TimerTask;

/**
* todo: reimplement
* TODO: fix
* @author Dries007
*/
public class BackupTask extends TimerTask
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/net/doubledoordev/backend/server/JvmData.java
Expand Up @@ -18,23 +18,33 @@

package net.doubledoordev.backend.server;

import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import net.doubledoordev.backend.util.IUpdateFromJson;

/**
* @author Dries007
*/
public class JvmData
public class JvmData implements IUpdateFromJson
{
@Expose
public int ramMin = 1024;
public int ramMin = 512;
@Expose
public int ramMax = 2048;
@Expose
public int permGen = 128;
@Expose
public String extraJavaParameters = "";
@Expose
public String extraMCParameters = "";
@Expose
public String jarName = "minecraft_server.jar";

@Override
public void updateFrom(JsonObject json)
{
if (json.has("ramMin")) ramMin = json.get("ramMin").getAsInt();
if (json.has("ramMax")) ramMax = json.get("ramMax").getAsInt();
if (json.has("extraJavaParameters")) extraJavaParameters = json.get("extraJavaParameters").getAsString();
if (json.has("extraMCParameters")) extraMCParameters = json.get("extraMCParameters").getAsString();
if (json.has("jarName")) jarName = json.get("jarName").getAsString();
}
}

0 comments on commit 4824afc

Please sign in to comment.