mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 10:15:52 +01:00
Optimizations for developers
This commit is contained in:
parent
42a73c8372
commit
e1de6636f0
@ -71,7 +71,7 @@ public class ExternalSubCreator extends SubCreator {
|
||||
try {
|
||||
if (file.isDirectory() && !file.getName().endsWith(".x")) {
|
||||
ObjectMap<String> config = (new UniversalFile(file, "template.yml").exists())?new YAMLConfig(new UniversalFile(file, "template.yml")).get().getMap("Template", new ObjectMap<String>()):new ObjectMap<String>();
|
||||
ServerTemplate template = new ServerTemplate(file.getName(), config.getBoolean("Enabled", true), config.getRawString("Icon", "::NULL::"), file, config.getMap("Build", new ObjectMap<String>()), config.getMap("Settings", new ObjectMap<String>()));
|
||||
ServerTemplate template = loadTemplate(file.getName(), config.getBoolean("Enabled", true), config.getRawString("Icon", "::NULL::"), file, config.getMap("Build", new ObjectMap<String>()), config.getMap("Settings", new ObjectMap<String>()));
|
||||
templatesR.put(file.getName().toLowerCase(), template);
|
||||
if (config.getKeys().contains("Display")) template.setDisplayName(config.getString("Display"));
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
}
|
||||
server.setAll(template.getConfigOptions());
|
||||
try {
|
||||
Logger.get(prefix).info("Loading Template: " + template.getDisplayName());
|
||||
Logger.get(prefix).info("Loading" + ((template.isDynamic())?" Dynamic":"") + " Template: " + template.getDisplayName());
|
||||
if (template.getBuildOptions().getBoolean("Update-Files", false)) updateDirectory(template.getDirectory(), dir);
|
||||
else Util.copyDirectory(template.getDirectory(), dir);
|
||||
|
||||
@ -369,7 +369,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
try {
|
||||
if (file.isDirectory() && !file.getName().endsWith(".x")) {
|
||||
ObjectMap<String> config = (new UniversalFile(file, "template.yml").exists()) ? new YAMLConfig(new UniversalFile(file, "template.yml")).get().getMap("Template", new ObjectMap<String>()) : new ObjectMap<String>();
|
||||
ServerTemplate template = new ServerTemplate(file.getName(), config.getBoolean("Enabled", true), config.getRawString("Icon", "::NULL::"), file, config.getMap("Build", new ObjectMap<String>()), config.getMap("Settings", new ObjectMap<String>()));
|
||||
ServerTemplate template = loadTemplate(file.getName(), config.getBoolean("Enabled", true), config.getRawString("Icon", "::NULL::"), file, config.getMap("Build", new ObjectMap<String>()), config.getMap("Settings", new ObjectMap<String>()));
|
||||
templates.put(file.getName().toLowerCase(), template);
|
||||
if (config.getKeys().contains("Display")) template.setDisplayName(config.getString("Display"));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import java.util.*;
|
||||
*/
|
||||
public abstract class SubCreator {
|
||||
public static class ServerTemplate {
|
||||
private final boolean dynamic;
|
||||
private String name;
|
||||
private String nick = null;
|
||||
private boolean enabled;
|
||||
@ -31,11 +32,17 @@ public abstract class SubCreator {
|
||||
* Create a SubCreator Template
|
||||
*
|
||||
* @param name Template Name
|
||||
* @param enabled Template Enabled Status
|
||||
* @param icon Template Item Icon Name
|
||||
* @param directory Template Directory
|
||||
* @param build Build Options
|
||||
* @param options Configuration Options
|
||||
*/
|
||||
public ServerTemplate(String name, boolean enabled, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options) {
|
||||
this(name, enabled, icon, directory, build, options, true);
|
||||
}
|
||||
|
||||
private ServerTemplate(String name, boolean enabled, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options, boolean dynamic) {
|
||||
if (Util.isNull(name, enabled, directory, build, options)) throw new NullPointerException();
|
||||
if (name.contains(" ")) throw new InvalidTemplateException("Template names cannot have spaces: " + name);
|
||||
this.name = name;
|
||||
@ -45,6 +52,7 @@ public abstract class SubCreator {
|
||||
this.type = (build.contains("Server-Type"))?ServerType.valueOf(build.getRawString("Server-Type").toUpperCase()):ServerType.CUSTOM;
|
||||
this.build = build;
|
||||
this.options = options;
|
||||
this.dynamic = dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,6 +158,15 @@ public abstract class SubCreator {
|
||||
return getBuildOptions().getBoolean("Can-Update", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this Template was generated by a SubCreator instance
|
||||
*
|
||||
* @return Custom Status
|
||||
*/
|
||||
public boolean isDynamic() {
|
||||
return dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Build Options for this Template
|
||||
*
|
||||
@ -490,6 +507,20 @@ public abstract class SubCreator {
|
||||
*/
|
||||
public abstract ServerTemplate getTemplate(String name);
|
||||
|
||||
/**
|
||||
* Create a SubCreator Template
|
||||
*
|
||||
* @param name Template Name
|
||||
* @param enabled Template Enabled Status
|
||||
* @param icon Template Item Icon Name
|
||||
* @param directory Template Directory
|
||||
* @param build Build Options
|
||||
* @param options Configuration Options
|
||||
*/
|
||||
protected ServerTemplate loadTemplate(String name, boolean enabled, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options) {
|
||||
return new ServerTemplate(name, enabled, icon, directory, build, options, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload SubCreator
|
||||
*/
|
||||
|
@ -91,7 +91,19 @@ public class PacketExCreateServer implements PacketObjectIn<Integer>, PacketObje
|
||||
} else {
|
||||
data.set(0x0000, tracker);
|
||||
data.set(0x0002, name);
|
||||
if (template.isDynamic()) {
|
||||
ObjectMap<String> template = new ObjectMap<>();
|
||||
template.set("name", this.template.getName());
|
||||
template.set("display", this.template.getDisplayName());
|
||||
template.set("enabled", this.template.isEnabled());
|
||||
template.set("icon", this.template.getIcon());
|
||||
template.set("dir", this.template.getDirectory().toString());
|
||||
template.set("build", this.template.getBuildOptions().clone());
|
||||
template.set("def", this.template.getConfigOptions().clone());
|
||||
data.set(0x0003, template);
|
||||
} else {
|
||||
data.set(0x0003, template.getName());
|
||||
}
|
||||
data.set(0x0004, version);
|
||||
data.set(0x0005, port);
|
||||
data.set(0x0006, log);
|
||||
|
@ -11,6 +11,7 @@ import net.ME1312.SubServers.Bungee.Host.External.ExternalSubCreator;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubCreator;
|
||||
import net.ME1312.SubServers.Bungee.SubProxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
@ -39,7 +40,8 @@ public class PacketExUploadTemplates implements PacketObjectIn<Integer>, PacketO
|
||||
for (String name : templates.getKeys()) {
|
||||
try {
|
||||
UniversalFile dir = new UniversalFile(templatedir, name);
|
||||
SubCreator.ServerTemplate template = new SubCreator.ServerTemplate(name, templates.getMap(name).getBoolean("enabled"), templates.getMap(name).getRawString("icon"), dir,
|
||||
SubCreator.ServerTemplate template = Util.reflect(SubCreator.class.getDeclaredMethod("loadTemplate", String.class, boolean.class, String.class, File.class, ObjectMap.class, ObjectMap.class),
|
||||
((ExternalHost) client.getHandler()).getCreator(), name, templates.getMap(name).getBoolean("enabled"), templates.getMap(name).getRawString("icon"), dir,
|
||||
templates.getMap(name).getMap("build").clone(), templates.getMap(name).getMap("settings").clone());
|
||||
map.put(name.toLowerCase(), template);
|
||||
if (!templates.getMap(name).getRawString("display").equals(name)) template.setDisplayName(templates.getMap(name).getRawString("display"));
|
||||
|
@ -340,8 +340,8 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
public void reload() throws IOException {
|
||||
List<String> ukeys = new ArrayList<String>();
|
||||
long begin = Calendar.getInstance().getTime().getTime();
|
||||
boolean status;
|
||||
if (!(status = ready)) resetDate = begin;
|
||||
boolean status = ready;
|
||||
if (!status) resetDate = begin;
|
||||
reloading = true;
|
||||
|
||||
ConfigUpdater.updateConfig(new UniversalFile(dir, "SubServers:config.yml"));
|
||||
@ -359,9 +359,9 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
!config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").equals(prevconfig.getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391")) ||
|
||||
!config.get().getMap("Settings").getMap("SubData").getRawString("Encryption", "NONE").equals(prevconfig.getMap("Settings").getMap("SubData").getRawString("Encryption", "NONE"))
|
||||
)) {
|
||||
SubDataServer subdata = this.subdata;
|
||||
subdata.close();
|
||||
Util.isException(subdata::waitFor);
|
||||
subdata = null;
|
||||
}
|
||||
|
||||
SmartFallback.dns_forward = config.get().getMap("Settings").getMap("Smart-Fallback", new ObjectMap<>()).getBoolean("DNS-Forward", false);
|
||||
@ -553,7 +553,31 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
running = ready = true;
|
||||
legServers.clear();
|
||||
|
||||
// Initialize SubData
|
||||
int plugins = 0;
|
||||
if (status) {
|
||||
List<Runnable> listeners = api.reloadListeners;
|
||||
if (listeners.size() > 0) {
|
||||
Logger.get("SubServers").info("Reloading SubAPI Plugins...");
|
||||
for (Runnable obj : listeners) {
|
||||
try {
|
||||
obj.run();
|
||||
plugins++;
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Problem " + ((status)?"reloading":"enabling") + " plugin").printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Host host : api.getHosts().values()) if (host instanceof ClientHandler && ((ClientHandler) host).getSubData()[0] != null) ((SubDataClient) ((ClientHandler) host).getSubData()[0]).sendPacket(new PacketOutExReload(null));
|
||||
for (Server server : api.getServers().values()) if (server.getSubData()[0] != null) ((SubDataClient) server.getSubData()[0]).sendPacket(new PacketOutExReload(null));
|
||||
}
|
||||
|
||||
reloading = false;
|
||||
Logger.get("SubServers").info(((plugins > 0)?plugins+" Plugin"+((plugins == 1)?"":"s")+", ":"") + hosts + " Host"+((hosts == 1)?"":"s")+", " + servers + " Server"+((servers == 1)?"":"s")+", and " + subservers + " SubServer"+((subservers == 1)?"":"s")+" "+((status)?"re":"")+"loaded in " + new DecimalFormat("0.000").format((Calendar.getInstance().getTime().getTime() - begin) / 1000D) + "s");
|
||||
if (status) startDataListeners();
|
||||
}
|
||||
|
||||
private void startDataListeners() throws IOException {
|
||||
if (subdata == null) {
|
||||
subprotocol.unregisterCipher("AES");
|
||||
subprotocol.unregisterCipher("AES-128");
|
||||
@ -605,7 +629,9 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
subdata = subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
|
||||
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
|
||||
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]), cipher);
|
||||
} // Add new entries to Allowed-Connections
|
||||
}
|
||||
|
||||
// Add new entries to Allowed-Connections
|
||||
for (String s : config.get().getMap("Settings").getMap("SubData").getStringList("Whitelist", new ArrayList<String>())) {
|
||||
try {
|
||||
subdata.whitelist(s);
|
||||
@ -613,28 +639,6 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
int plugins = 0;
|
||||
if (status) {
|
||||
List<Runnable> listeners = api.reloadListeners;
|
||||
if (listeners.size() > 0) {
|
||||
Logger.get("SubServers").info("Reloading SubAPI Plugins...");
|
||||
for (Runnable obj : listeners) {
|
||||
try {
|
||||
obj.run();
|
||||
plugins++;
|
||||
} catch (Throwable e) {
|
||||
new InvocationTargetException(e, "Problem " + ((status)?"reloading":"enabling") + " plugin").printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Host host : api.getHosts().values()) if (host instanceof ClientHandler && ((ClientHandler) host).getSubData()[0] != null) ((SubDataClient) ((ClientHandler) host).getSubData()[0]).sendPacket(new PacketOutExReload(null));
|
||||
for (Server server : api.getServers().values()) if (server.getSubData()[0] != null) ((SubDataClient) server.getSubData()[0]).sendPacket(new PacketOutExReload(null));
|
||||
}
|
||||
|
||||
reloading = false;
|
||||
Logger.get("SubServers").info(((plugins > 0)?plugins+" Plugin"+((plugins == 1)?"":"s")+", ":"") + hosts + " Host"+((hosts == 1)?"":"s")+", " + servers + " Server"+((servers == 1)?"":"s")+", and " + subservers + " SubServer"+((subservers == 1)?"":"s")+" "+((status)?"re":"")+"loaded in " + new DecimalFormat("0.000").format((Calendar.getInstance().getTime().getTime() - begin) / 1000D) + "s");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -650,6 +654,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
getLogger().warning("UPnP service is unavailable. SubServers can't port-forward for you from this device.");
|
||||
}
|
||||
|
||||
startDataListeners();
|
||||
super.startListeners();
|
||||
|
||||
if (autorun != null && autorun.size() > 0) {
|
||||
@ -819,9 +824,10 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
rPlayerLinkP.clear();
|
||||
rPlayers.clear();
|
||||
|
||||
try {
|
||||
if (subdata != null) try {
|
||||
SubDataServer subdata = this.subdata;
|
||||
subdata.close();
|
||||
Thread.sleep(500);
|
||||
subdata.waitFor();
|
||||
} catch (InterruptedException | IOException e) {}
|
||||
|
||||
if (shutdown) super.isRunning = false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit.Event;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.SubEvent;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
@ -11,12 +11,12 @@ import org.bukkit.event.HandlerList;
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public class SubNetworkConnectEvent extends Event implements SubEvent {
|
||||
private SubDataClient network;
|
||||
private DataClient network;
|
||||
|
||||
/**
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public SubNetworkConnectEvent(SubDataClient network) {
|
||||
public SubNetworkConnectEvent(DataClient network) {
|
||||
if (Util.isNull(network)) throw new NullPointerException();
|
||||
this.network = network;
|
||||
}
|
||||
@ -26,7 +26,7 @@ public class SubNetworkConnectEvent extends Event implements SubEvent {
|
||||
*
|
||||
* @return SubData Network
|
||||
*/
|
||||
public SubDataClient getNetwork() {
|
||||
public DataClient getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.ME1312.SubServers.Client.Sponge.Event;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubServers.Client.Sponge.Library.SubEvent;
|
||||
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
@ -11,12 +11,12 @@ import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public class SubNetworkConnectEvent extends AbstractEvent implements SubEvent {
|
||||
private SubDataClient network;
|
||||
private DataClient network;
|
||||
|
||||
/**
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public SubNetworkConnectEvent(SubDataClient network) {
|
||||
public SubNetworkConnectEvent(DataClient network) {
|
||||
if (Util.isNull(network)) throw new NullPointerException();
|
||||
this.network = network;
|
||||
}
|
||||
@ -26,7 +26,7 @@ public class SubNetworkConnectEvent extends AbstractEvent implements SubEvent {
|
||||
*
|
||||
* @return SubData Network
|
||||
*/
|
||||
public SubDataClient getNetwork() {
|
||||
public DataClient getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
|
@ -2,18 +2,18 @@ package net.ME1312.SubServers.Host.Event;
|
||||
|
||||
import net.ME1312.Galaxi.Event.Event;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.DataClient;
|
||||
|
||||
/**
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public class SubNetworkConnectEvent extends Event {
|
||||
private SubDataClient network;
|
||||
private DataClient network;
|
||||
|
||||
/**
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public SubNetworkConnectEvent(SubDataClient network) {
|
||||
public SubNetworkConnectEvent(DataClient network) {
|
||||
if (Util.isNull(network)) throw new NullPointerException();
|
||||
this.network = network;
|
||||
}
|
||||
@ -23,7 +23,7 @@ public class SubNetworkConnectEvent extends Event {
|
||||
*
|
||||
* @return SubData Network
|
||||
*/
|
||||
public SubDataClient getNetwork() {
|
||||
public DataClient getNetwork() {
|
||||
return network;
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ public class SubCreatorImpl {
|
||||
private TreeMap<String, CreatorTask> thread;
|
||||
|
||||
public static class ServerTemplate extends SubCreator.ServerTemplate {
|
||||
private final boolean dynamic;
|
||||
private String name;
|
||||
private String nick = null;
|
||||
private boolean enabled;
|
||||
@ -55,11 +56,17 @@ public class SubCreatorImpl {
|
||||
* Create a SubCreator Template
|
||||
*
|
||||
* @param name Template Name
|
||||
* @param enabled Template Enabled Status
|
||||
* @param icon Template Item Icon Name
|
||||
* @param directory Template Directory
|
||||
* @param build Build Options
|
||||
* @param options Configuration Options
|
||||
*/
|
||||
public ServerTemplate(String name, boolean enabled, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options) {
|
||||
this(name, enabled, icon, directory, build, options, true);
|
||||
}
|
||||
|
||||
private ServerTemplate(String name, boolean enabled, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options, boolean dynamic) {
|
||||
super(toRaw(name, enabled, icon, directory, build, options));
|
||||
if (name.contains(" ")) throw new InvalidTemplateException("Template names cannot have spaces: " + name);
|
||||
this.name = name;
|
||||
@ -69,6 +76,7 @@ public class SubCreatorImpl {
|
||||
this.type = (build.contains("Server-Type"))?ServerType.valueOf(build.getRawString("Server-Type").toUpperCase()):ServerType.CUSTOM;
|
||||
this.build = build;
|
||||
this.options = options;
|
||||
this.dynamic = dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,6 +183,15 @@ public class SubCreatorImpl {
|
||||
return getBuildOptions().getBoolean("Can-Update", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether this Template was generated by a SubCreator instance
|
||||
*
|
||||
* @return Custom Status
|
||||
*/
|
||||
public boolean isDynamic() {
|
||||
return dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Build Options for this Template
|
||||
*
|
||||
@ -201,6 +218,8 @@ public class SubCreatorImpl {
|
||||
tinfo.set("display", name);
|
||||
tinfo.set("icon", icon);
|
||||
tinfo.set("type", (build.contains("Server-Type"))?ServerType.valueOf(build.getRawString("Server-Type").toUpperCase()):ServerType.CUSTOM);
|
||||
tinfo.set("version-req", build.getBoolean("Require-Version", false));
|
||||
tinfo.set("can-update", build.getBoolean("Can-Update", false));
|
||||
return tinfo;
|
||||
}
|
||||
}
|
||||
@ -218,7 +237,7 @@ public class SubCreatorImpl {
|
||||
try {
|
||||
if (file.isDirectory() && !file.getName().endsWith(".x")) {
|
||||
ObjectMap<String> config = (new UniversalFile(file, "template.yml").exists())?new YAMLConfig(new UniversalFile(file, "template.yml")).get().getMap("Template", new ObjectMap<String>()):new ObjectMap<String>();
|
||||
ServerTemplate template = new ServerTemplate(file.getName(), config.getBoolean("Enabled", true), config.getRawString("Icon", "::NULL::"), file, config.getMap("Build", new ObjectMap<String>()), config.getMap("Settings", new ObjectMap<String>()));
|
||||
ServerTemplate template = new ServerTemplate(file.getName(), config.getBoolean("Enabled", true), config.getRawString("Icon", "::NULL::"), file, config.getMap("Build", new ObjectMap<String>()), config.getMap("Settings", new ObjectMap<String>()), false);
|
||||
templates.put(file.getName().toLowerCase(), template);
|
||||
if (config.getKeys().contains("Display")) template.setDisplayName(config.getString("Display"));
|
||||
}
|
||||
@ -300,7 +319,7 @@ public class SubCreatorImpl {
|
||||
}
|
||||
server.setAll(template.getConfigOptions());
|
||||
try {
|
||||
log.logger.info.println("Loading Template: " + template.getDisplayName());
|
||||
log.logger.info.println("Loading" + ((template.isDynamic())?" Dynamic":"") + " Template: " + template.getDisplayName());
|
||||
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketOutExLogMessage(address, "Loading Template: " + template.getDisplayName()));
|
||||
if (template.getBuildOptions().getBoolean("Update-Files", false)) updateDirectory(template.getDirectory(), dir);
|
||||
else Util.copyDirectory(template.getDirectory(), dir);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.ME1312.SubServers.Host.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
@ -8,7 +9,9 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Host.ExHost;
|
||||
import net.ME1312.SubServers.Host.Executable.SubCreatorImpl;
|
||||
import net.ME1312.SubServers.Host.Executable.SubCreatorImpl.ServerTemplate;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -85,15 +88,29 @@ public class PacketExCreateServer implements PacketObjectIn<Integer>, PacketObje
|
||||
client.sendPacket(new PacketExCreateServer(1, null, tracker));
|
||||
} else {
|
||||
String name = data.getRawString(0x0002);
|
||||
String template = data.getRawString(0x0003);
|
||||
ObjectMapValue<Integer> template = data.get(0x0003);
|
||||
Version version = (data.contains(0x0004)?data.getVersion(0x0004):null);
|
||||
Integer port = data.getInt(0x0005);
|
||||
UUID log = data.getUUID(0x0006);
|
||||
Boolean mode = (data.contains(0x0007)?data.getBoolean(0x0007):null);
|
||||
UUID player = (data.contains(0x0008)?data.getUUID(0x0008):null);
|
||||
|
||||
SubCreatorImpl.ServerTemplate templateV = host.templates.get(template.toLowerCase());
|
||||
if (templateV == null) templateV = host.templatesR.get(template.toLowerCase());
|
||||
SubCreatorImpl.ServerTemplate templateV;
|
||||
|
||||
if (template.isString()) {
|
||||
templateV = host.templates.get(template.asRawString().toLowerCase());
|
||||
if (templateV == null) templateV = host.templatesR.get(template.asRawString().toLowerCase());
|
||||
} else {
|
||||
ObjectMap<String> templateM = template.asMap().key();
|
||||
templateV = new ServerTemplate(
|
||||
templateM.getRawString("name"),
|
||||
templateM.getBoolean("enabled"),
|
||||
templateM.getRawString("icon"),
|
||||
new File(templateM.getRawString("dir").replace('/', File.separatorChar)),
|
||||
templateM.getMap("build"),
|
||||
templateM.getMap("def"));
|
||||
templateV.setDisplayName(templateM.getRawString("display"));
|
||||
}
|
||||
|
||||
host.creator.create(player, name, templateV, version, port, mode, log, tracker);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.ME1312.SubServers.Sync.Event;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubData.Client.DataClient;
|
||||
import net.ME1312.SubServers.Sync.Library.SubEvent;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
@ -10,12 +10,12 @@ import net.md_5.bungee.api.plugin.Event;
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public class SubNetworkConnectEvent extends Event implements SubEvent {
|
||||
private SubDataClient network;
|
||||
private DataClient network;
|
||||
|
||||
/**
|
||||
* SubData Network Connect Event
|
||||
*/
|
||||
public SubNetworkConnectEvent(SubDataClient network) {
|
||||
public SubNetworkConnectEvent(DataClient network) {
|
||||
if (Util.isNull(network)) throw new NullPointerException();
|
||||
this.network = network;
|
||||
}
|
||||
@ -25,7 +25,7 @@ public class SubNetworkConnectEvent extends Event implements SubEvent {
|
||||
*
|
||||
* @return SubData Network
|
||||
*/
|
||||
public SubDataClient getNetwork() {
|
||||
public DataClient getNetwork() {
|
||||
return network;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user