From 3b2c4d9d868f664ad992f19c6ac7c92248ad13af Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Sat, 10 Nov 2018 20:42:45 +0300 Subject: [PATCH] Removed plugin-integr. --- LaunchServer/build.gradle | 8 --- .../ru/gravit/launchserver/LaunchServer.java | 45 +++++---------- .../auth/provider/AcceptAuthProvider.java | 3 +- .../plugin/LaunchServerPluginBridge.java | 57 ------------------- .../bukkit/LaunchServerCommandBukkit.java | 27 --------- .../bukkit/LaunchServerPluginBukkit.java | 36 ------------ .../bungee/LaunchServerCommandBungee.java | 31 ---------- .../bungee/LaunchServerPluginBungee.java | 32 ----------- 8 files changed, 17 insertions(+), 222 deletions(-) delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/LaunchServerPluginBridge.java delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerCommandBukkit.java delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerPluginBukkit.java delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerCommandBungee.java delete mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerPluginBungee.java diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 4eb05505..365f9e0e 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -2,18 +2,12 @@ def mainAgentName = "ru.gravit.launchserver.StarterAgent" repositories { - maven { - url "https://hub.spigotmc.org/nexus/content/repositories/snapshots" - } maven { url "http://maven.geomajas.org/" } maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - maven { - url "http://repo.md-5.net/content/groups/public" - } } sourceCompatibility = '1.8' @@ -41,8 +35,6 @@ dependencies { compile project(':libLauncher') // pack - compileOnly 'org.spigotmc:spigot-api:1.8-R0.1-SNAPSHOT' // api - compileOnly 'net.md-5:bungeecord-api:1.8-SNAPSHOT' // api compileOnly 'org.ow2.asm:asm-debug-all:5.0.4' bundleOnly 'org.ow2.asm:asm-all:5.0.4' bundle 'org.apache.logging.log4j:log4j-core:2.9.0' diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 2f1bb61c..ddc82673 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -270,7 +270,7 @@ public static void main(String... args) throws Throwable { // Start LaunchServer Instant start = Instant.now(); try { - try (LaunchServer lsrv = new LaunchServer(IOHelper.WORKING_DIR, false)) { + try (LaunchServer lsrv = new LaunchServer(IOHelper.WORKING_DIR)) { lsrv.run(); } } catch (Throwable exc) { @@ -304,8 +304,6 @@ public static void main(String... args) throws Throwable { public final RSAPublicKey publicKey; public final RSAPrivateKey privateKey; - - public final boolean portable; // Launcher binary public final LauncherBinary launcherBinary; @@ -340,10 +338,7 @@ public static void main(String... args) throws Throwable { public volatile Map> updatesDirMap; - public LaunchServer(Path dir, boolean portable) throws IOException, InvalidKeySpecException { - //setScriptBindings(); - this.portable = portable; - + public LaunchServer(Path dir) throws IOException, InvalidKeySpecException { // Setup config locations this.dir = dir; configFile = dir.resolve("LaunchServer.cfg"); @@ -362,19 +357,16 @@ public LaunchServer(Path dir, boolean portable) throws IOException, InvalidKeySp // Set command handler CommandHandler localCommandHandler; - if (portable) - localCommandHandler = new StdCommandHandler(this, false); - else - try { - Class.forName("jline.Terminal"); + try { + Class.forName("jline.Terminal"); - // JLine2 available - localCommandHandler = new JLineCommandHandler(this); - LogHelper.info("JLine2 terminal enabled"); - } catch (ClassNotFoundException ignored) { - localCommandHandler = new StdCommandHandler(this, true); - LogHelper.warning("JLine2 isn't in classpath, using std"); - } + // JLine2 available + localCommandHandler = new JLineCommandHandler(this); + LogHelper.info("JLine2 terminal enabled"); + } catch (ClassNotFoundException ignored) { + localCommandHandler = new StdCommandHandler(this, true); + LogHelper.warning("JLine2 isn't in classpath, using std"); + } commandHandler = localCommandHandler; // Set key pair @@ -505,13 +497,8 @@ private void generateConfigIfNotExists() throws IOException { } // Set server address - if (portable) { - LogHelper.warning("Setting LaunchServer address to 'localhost'"); - newConfig.setAddress("localhost"); - } else { - LogHelper.println("LaunchServer address: "); - newConfig.setAddress(commandHandler.readLine()); - } + LogHelper.println("LaunchServer address: "); + newConfig.setAddress(commandHandler.readLine()); // Write LaunchServer config LogHelper.info("Writing LaunchServer config file"); @@ -548,10 +535,8 @@ public void run() { throw new IllegalStateException("LaunchServer has been already started"); // Add shutdown hook, then start LaunchServer - if (!portable) { - JVMHelper.RUNTIME.addShutdownHook(CommonHelper.newThread(null, false, this::close)); - CommonHelper.newThread("Command Thread", true, commandHandler).start(); - } + JVMHelper.RUNTIME.addShutdownHook(CommonHelper.newThread(null, false, this::close)); + CommonHelper.newThread("Command Thread", true, commandHandler).start(); rebindServerSocket(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java index 4830cece..ad957d51 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AcceptAuthProvider.java @@ -2,6 +2,7 @@ import ru.gravit.launcher.serialize.config.entry.BooleanConfigEntry; import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.ClientPermissions; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry; @@ -15,7 +16,7 @@ public AcceptAuthProvider(BlockConfigEntry block, LaunchServer server) { @Override public AuthProviderResult auth(String login, String password, String ip) { - return new AuthProviderResult(login, SecurityHelper.randomStringToken()); // Same as login + return new AuthProviderResult(login, SecurityHelper.randomStringToken(), isAdminAccess ? ClientPermissions.getSuperuserAccount() : ClientPermissions.DEFAULT); // Same as login } @Override diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/LaunchServerPluginBridge.java b/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/LaunchServerPluginBridge.java deleted file mode 100644 index a6dc52c3..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/LaunchServerPluginBridge.java +++ /dev/null @@ -1,57 +0,0 @@ -package ru.gravit.launchserver.integration.plugin; - -import java.nio.file.Path; -import java.time.Duration; -import java.time.Instant; - -import ru.gravit.utils.helper.JVMHelper; -import ru.gravit.utils.helper.LogHelper; -import ru.gravit.launchserver.LaunchServer; - -public final class LaunchServerPluginBridge implements Runnable, AutoCloseable { - /** - * Permission. - */ - public static final String perm = "launchserver.corecmdcall"; - /** - * Err text. - */ - public static final String nonInitText = "Лаунчсервер не был полностью загружен"; - - static { - //SecurityHelper.verifyCertificates(LaunchServer.class); - JVMHelper.verifySystemProperties(LaunchServer.class, false); - } - - private final LaunchServer server; - - public LaunchServerPluginBridge(Path dir) throws Throwable { - LogHelper.addOutput(dir.resolve("LaunchServer.log")); - LogHelper.printVersion("LaunchServer"); - - // Create new LaunchServer - Instant start = Instant.now(); - try { - server = new LaunchServer(dir, true); - } catch (Throwable exc) { - LogHelper.error(exc); - throw exc; - } - Instant end = Instant.now(); - LogHelper.debug("LaunchServer started in %dms", Duration.between(start, end).toMillis()); - } - - @Override - public void close() { - server.close(); - } - - public void eval(String... command) { - server.commandHandler.eval(command, false); - } - - @Override - public void run() { - server.run(); - } -} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerCommandBukkit.java b/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerCommandBukkit.java deleted file mode 100644 index 3bd03a34..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerCommandBukkit.java +++ /dev/null @@ -1,27 +0,0 @@ -package ru.gravit.launchserver.integration.plugin.bukkit; - -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import ru.gravit.launchserver.integration.plugin.LaunchServerPluginBridge; - -public final class LaunchServerCommandBukkit implements CommandExecutor { - public final LaunchServerPluginBukkit plugin; - - public LaunchServerCommandBukkit(LaunchServerPluginBukkit plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) { - // Eval command - LaunchServerPluginBridge bridge = plugin.bridge; - if (bridge == null) - sender.sendMessage(ChatColor.RED + LaunchServerPluginBridge.nonInitText); - else - bridge.eval(args); - return true; - } -} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerPluginBukkit.java b/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerPluginBukkit.java deleted file mode 100644 index 0b48e7f1..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bukkit/LaunchServerPluginBukkit.java +++ /dev/null @@ -1,36 +0,0 @@ -package ru.gravit.launchserver.integration.plugin.bukkit; - -import org.bukkit.command.PluginCommand; -import org.bukkit.plugin.java.JavaPlugin; - -import ru.gravit.launchserver.integration.plugin.LaunchServerPluginBridge; - -public final class LaunchServerPluginBukkit extends JavaPlugin { - public volatile LaunchServerPluginBridge bridge = null; - - @Override - public void onDisable() { - super.onDisable(); - if (bridge != null) { - bridge.close(); - bridge = null; - } - } - - @Override - public void onEnable() { - super.onEnable(); - - // Initialize LaunchServer - try { - bridge = new LaunchServerPluginBridge(getDataFolder().toPath()); - } catch (Throwable exc) { - exc.printStackTrace(); - } - - // Register command - PluginCommand com = getCommand("launchserver"); - com.setPermission(LaunchServerPluginBridge.perm); - com.setExecutor(new LaunchServerCommandBukkit(this)); - } -} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerCommandBungee.java b/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerCommandBungee.java deleted file mode 100644 index 1071edd1..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerCommandBungee.java +++ /dev/null @@ -1,31 +0,0 @@ -package ru.gravit.launchserver.integration.plugin.bungee; - -import ru.gravit.launchserver.integration.plugin.LaunchServerPluginBridge; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; -import net.md_5.bungee.api.plugin.Command; -//import net.md_5.bungee.command.ConsoleCommandSender; - -public final class LaunchServerCommandBungee extends Command { - private static final BaseComponent[] NOT_INITIALIZED_MESSAGE = TextComponent.fromLegacyText(ChatColor.RED + LaunchServerPluginBridge.nonInitText); - - // Instance - public final LaunchServerPluginBungee plugin; - - public LaunchServerCommandBungee(LaunchServerPluginBungee plugin) { - super("launchserver", LaunchServerPluginBridge.perm, "ru/gravit/launcher", "ls", "l"); - this.plugin = plugin; - } - - @Override - public void execute(CommandSender sender, String[] args) { - // Eval command - LaunchServerPluginBridge bridge = plugin.bridge; - if (bridge == null) - sender.sendMessage(NOT_INITIALIZED_MESSAGE); - else - bridge.eval(args); - } -} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerPluginBungee.java b/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerPluginBungee.java deleted file mode 100644 index 9b254a31..00000000 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/integration/plugin/bungee/LaunchServerPluginBungee.java +++ /dev/null @@ -1,32 +0,0 @@ -package ru.gravit.launchserver.integration.plugin.bungee; - -import ru.gravit.launchserver.integration.plugin.LaunchServerPluginBridge; -import net.md_5.bungee.api.plugin.Plugin; - -public final class LaunchServerPluginBungee extends Plugin { - public volatile LaunchServerPluginBridge bridge = null; - - @Override - public void onDisable() { - super.onDisable(); - if (bridge != null) { - bridge.close(); - bridge = null; - } - } - - @Override - public void onEnable() { - super.onEnable(); - - // Initialize LaunchServer - try { - bridge = new LaunchServerPluginBridge(getDataFolder().toPath()); - } catch (Throwable exc) { - exc.printStackTrace(); - } - - // Register command - getProxy().getPluginManager().registerCommand(this, new LaunchServerCommandBungee(this)); - } -}