Add support for console sudo in GalaxiBungee

This commit is contained in:
ME1312 2019-05-23 14:37:18 -04:00
parent 8514ea5c26
commit 49036b8943
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
8 changed files with 59 additions and 8 deletions

View File

@ -30,9 +30,15 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w20k</version>
<version>19w21a</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w21a</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Server</artifactId>

View File

@ -0,0 +1,39 @@
package net.ME1312.SubServers.Bungee.Library.Compatibility;
import net.ME1312.Galaxi.Event.ConsoleInputEvent;
import net.ME1312.Galaxi.Galaxi;
import net.ME1312.Galaxi.Library.Event.ListenerOrder;
import net.ME1312.Galaxi.Library.Event.Subscribe;
import net.ME1312.SubServers.Bungee.SubPlugin;
/**
* Galaxi Event Listener Class
*/
public class GalaxiEventListener {
private SubPlugin plugin;
/**
* Create & Register a Galaxi Event Listener
*
* @param plugin Plugin
*/
public GalaxiEventListener(SubPlugin plugin) throws Throwable {
this.plugin = plugin;
Galaxi.getInstance().getPluginManager().registerListener(Galaxi.getInstance().getAppInfo(), this);
plugin.canSudo = true;
}
@Subscribe(order = ListenerOrder.FIRST, override = true)
public void sudo(ConsoleInputEvent e) {
if (plugin.sudo != null) {
e.setCancelled(true);
if (e.getInput().equalsIgnoreCase("exit")) {
plugin.sudo = null;
Logger.get("SubServers").info("Reverting to the BungeeCord Console");
} else {
plugin.sudo.command(e.getInput());
}
}
}
}

View File

@ -7,6 +7,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Plugin.PluginInfo;
import net.ME1312.SubData.Server.*;
import net.ME1312.SubData.Server.Encryption.AES;
import net.ME1312.SubData.Server.Encryption.RSA;
@ -226,6 +227,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
subprotocol = SubProtocol.get();
Logger.get("SubServers").info("Loading BungeeCord Libraries...");
if (isGalaxi) Util.reflect(net.ME1312.SubServers.Bungee.Library.Compatibility.GalaxiEventListener.class.getConstructor(SubPlugin.class), this);
}
/**
@ -857,7 +859,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
ServerInfo next = new LinkedList<Map.Entry<String, ServerInfo>>(fallbacks.entrySet()).getFirst().getValue();
e.setCancelServer(next);
if (Util.isException(() -> Util.reflect(ServerKickEvent.class.getDeclaredMethod("setCancelServers", ServerInfo[].class), e, (Object) fallbacks.values().toArray(new ServerInfo[0])))) {
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedBlockingQueue<>(fallbacks.keySet()));
((UserConnection) e.getPlayer()).setServerJoinQueue(new LinkedList<>(fallbacks.keySet()));
((UserConnection) e.getPlayer()).connect(next, null, true);
}
}

View File

@ -48,7 +48,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w20k</version>
<version>19w21a</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -30,7 +30,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w20k</version>
<version>19w21a</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -20,7 +20,7 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w20k</version>
<version>19w21a</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -30,9 +30,15 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>19w20k</version>
<version>19w21a</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>19w21a</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>

View File

@ -36,9 +36,7 @@ import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
/**