mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Removed plugin-integr. (#47)
This commit is contained in:
parent
d2947b811d
commit
ef57f8b02f
8 changed files with 17 additions and 222 deletions
|
@ -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'
|
||||
|
|
|
@ -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<String, SignedObjectHolder<HashedDir>> 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue