mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 02:08:27 +01:00
Minor API corrections to template swapping
This commit is contained in:
parent
ce38355c91
commit
6258256081
@ -27,7 +27,7 @@ public class GalaxiCommand {
|
||||
* @return The Command
|
||||
*/
|
||||
public static Command description(Command command, String value) {
|
||||
Util.isException(() -> Util.reflect(Class.forName("net.ME1312.Galaxi.Command.Command").getMethod("description", String.class), command, value));
|
||||
Util.isException(() -> Class.forName("net.ME1312.Galaxi.Command.Command").getMethod("description", String.class).invoke(command, value));
|
||||
return command;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class GalaxiCommand {
|
||||
* @return The Command
|
||||
*/
|
||||
public static Command help(Command command, String... lines) {
|
||||
Util.isException(() -> Util.reflect(Class.forName("net.ME1312.Galaxi.Command.Command").getMethod("help", String[].class), command, (Object) lines));
|
||||
Util.isException(() -> Class.forName("net.ME1312.Galaxi.Command.Command").getMethod("help", String[].class).invoke(command, (Object) lines));
|
||||
return command;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class GalaxiCommand {
|
||||
* @return The Command
|
||||
*/
|
||||
public static Command usage(Command command, String... args) {
|
||||
Util.isException(() -> Util.reflect(Class.forName("net.ME1312.Galaxi.Command.Command").getMethod("usage", String[].class), command, (Object) args));
|
||||
Util.isException(() -> Class.forName("net.ME1312.Galaxi.Command.Command").getMethod("usage", String[].class).invoke(command, (Object) args));
|
||||
return command;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ public class Logger {
|
||||
*/
|
||||
public static java.util.logging.Logger get(String prefix) {
|
||||
if (!existing.keySet().contains(prefix)) {
|
||||
java.util.logging.Logger log = Util.getDespiteException(() -> Util.reflect(Class.forName("net.ME1312.Galaxi.Log.Logger").getDeclaredMethod("toPrimitive"),
|
||||
Util.reflect(Class.forName("net.ME1312.Galaxi.Log.Logger").getConstructor(String.class), prefix)), null);
|
||||
java.util.logging.Logger log = Util.getDespiteException(() -> (java.util.logging.Logger) Class.forName("net.ME1312.Galaxi.Log.Logger").getMethod("toPrimitive")
|
||||
.invoke(Class.forName("net.ME1312.Galaxi.Log.Logger").getConstructor(String.class).newInstance(prefix)), null);
|
||||
|
||||
if (log == null) {
|
||||
log = java.util.logging.Logger.getAnonymousLogger();
|
||||
|
@ -50,15 +50,16 @@ public class SubCreateEvent extends Event implements SubEvent, Cancellable {
|
||||
*
|
||||
* @param player Player Updating
|
||||
* @param server Server to be Updated
|
||||
* @param template Server Template
|
||||
* @param version Server Version
|
||||
*/
|
||||
public SubCreateEvent(UUID player, SubServer server, Version version) {
|
||||
public SubCreateEvent(UUID player, SubServer server, SubCreator.ServerTemplate template, Version version) {
|
||||
if (Util.isNull(server)) throw new NullPointerException();
|
||||
this.player = player;
|
||||
this.update = server;
|
||||
this.name = server.getName();
|
||||
this.host = server.getHost();
|
||||
this.template = server.getTemplate();
|
||||
this.template = template;
|
||||
this.version = version;
|
||||
this.port = server.getAddress().getPort();
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class ExternalSubCreator extends SubCreator {
|
||||
ExternalSubLogger logger = new ExternalSubLogger(this, prefix, log, null);
|
||||
thread.put(name.toLowerCase(), new ContainedPair<>(server.getAddress().getPort(), logger));
|
||||
|
||||
final SubCreateEvent event = new SubCreateEvent(player, server, version);
|
||||
final SubCreateEvent event = new SubCreateEvent(player, server, ft, version);
|
||||
host.plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
logger.start();
|
||||
@ -214,7 +214,8 @@ public class ExternalSubCreator extends SubCreator {
|
||||
if (server.contains("Extra")) for (String extra : server.getMap("Extra").getKeys())
|
||||
subserver.addExtra(extra, server.getMap("Extra").getObject(extra));
|
||||
|
||||
if (!(subserver.getStopAction() == StopAction.REMOVE_SERVER || subserver.getStopAction() == StopAction.RECYCLE_SERVER || subserver.getStopAction() == StopAction.DELETE_SERVER)) {
|
||||
if ((update != null && host.plugin.servers.get().getMap("Servers").contains(name)) ||
|
||||
!(subserver.getStopAction() == StopAction.REMOVE_SERVER || subserver.getStopAction() == StopAction.RECYCLE_SERVER || subserver.getStopAction() == StopAction.DELETE_SERVER)) {
|
||||
host.plugin.servers.get().getMap("Servers").set(name, server);
|
||||
host.plugin.servers.save();
|
||||
}
|
||||
|
@ -313,7 +313,8 @@ public class InternalSubCreator extends SubCreator {
|
||||
if (server.contains("Extra")) for (String extra : server.getMap("Extra").getKeys())
|
||||
subserver.addExtra(extra, server.getMap("Extra").getObject(extra));
|
||||
|
||||
if (!(subserver.getStopAction() == StopAction.REMOVE_SERVER || subserver.getStopAction() == StopAction.RECYCLE_SERVER || subserver.getStopAction() == StopAction.DELETE_SERVER)) {
|
||||
if ((update != null && host.plugin.servers.get().getMap("Servers").contains(name)) ||
|
||||
!(subserver.getStopAction() == StopAction.REMOVE_SERVER || subserver.getStopAction() == StopAction.RECYCLE_SERVER || subserver.getStopAction() == StopAction.DELETE_SERVER)) {
|
||||
host.plugin.servers.get().getMap("Servers").set(name, server);
|
||||
host.plugin.servers.save();
|
||||
}
|
||||
@ -442,7 +443,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
});
|
||||
this.thread.put(server.getName().toLowerCase(), task);
|
||||
|
||||
final SubCreateEvent event = new SubCreateEvent(player, server, version);
|
||||
final SubCreateEvent event = new SubCreateEvent(player, server, ft, version);
|
||||
host.plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
task.start();
|
||||
|
@ -1059,7 +1059,7 @@ public final class SubProxy extends BungeeCommon implements Listener {
|
||||
if (init) fallback.put(e.getPlayer().getUniqueId(), state);
|
||||
|
||||
e.setCancelServer(state.servers.getFirst());
|
||||
if (Util.isException(() -> Util.reflect(ServerKickEvent.class.getDeclaredMethod("setCancelServers", ServerInfo[].class), e, (Object) state.servers.toArray(new ServerInfo[0])))) {
|
||||
if (Util.isException(() -> ServerKickEvent.class.getMethod("setCancelServers", ServerInfo[].class).invoke(e, (Object) state.servers.toArray(new ServerInfo[0])))) {
|
||||
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedList<>(state.names));
|
||||
}
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ public final class ExProxy extends BungeeCommon implements Listener {
|
||||
if (init) fallback.put(e.getPlayer().getUniqueId(), state);
|
||||
|
||||
e.setCancelServer(state.servers.getFirst());
|
||||
if (Util.isException(() -> Util.reflect(ServerKickEvent.class.getDeclaredMethod("setCancelServers", ServerInfo[].class), e, (Object) state.servers.toArray(new ServerInfo[0])))) {
|
||||
if (Util.isException(() -> ServerKickEvent.class.getMethod("setCancelServers", ServerInfo[].class).invoke(e, (Object) state.servers.toArray(new ServerInfo[0])))) {
|
||||
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedList<>(state.names));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user