mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 21:10:23 +00:00
Add temporary backwards compatability for ServerHelper
This commit is contained in:
parent
d20f63e835
commit
c1139ca04c
@ -1,8 +1,5 @@
|
|||||||
package emu.grasscutter;
|
package emu.grasscutter;
|
||||||
|
|
||||||
import static emu.grasscutter.config.Configuration.SERVER;
|
|
||||||
import static emu.grasscutter.utils.Language.translate;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
import ch.qos.logback.classic.Level;
|
||||||
import ch.qos.logback.classic.Logger;
|
import ch.qos.logback.classic.Logger;
|
||||||
import emu.grasscutter.auth.AuthenticationSystem;
|
import emu.grasscutter.auth.AuthenticationSystem;
|
||||||
@ -15,6 +12,7 @@ import emu.grasscutter.data.ResourceLoader;
|
|||||||
import emu.grasscutter.database.DatabaseManager;
|
import emu.grasscutter.database.DatabaseManager;
|
||||||
import emu.grasscutter.plugin.PluginManager;
|
import emu.grasscutter.plugin.PluginManager;
|
||||||
import emu.grasscutter.plugin.api.ServerHelper;
|
import emu.grasscutter.plugin.api.ServerHelper;
|
||||||
|
import emu.grasscutter.plugin.api.ServerHook;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.server.http.HttpServer;
|
import emu.grasscutter.server.http.HttpServer;
|
||||||
import emu.grasscutter.server.http.dispatch.DispatchHandler;
|
import emu.grasscutter.server.http.dispatch.DispatchHandler;
|
||||||
@ -27,12 +25,6 @@ import emu.grasscutter.server.http.handlers.GenericHandler;
|
|||||||
import emu.grasscutter.server.http.handlers.LogHandler;
|
import emu.grasscutter.server.http.handlers.LogHandler;
|
||||||
import emu.grasscutter.tools.Tools;
|
import emu.grasscutter.tools.Tools;
|
||||||
import emu.grasscutter.utils.*;
|
import emu.grasscutter.utils.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOError;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jline.reader.EndOfFileException;
|
import org.jline.reader.EndOfFileException;
|
||||||
@ -44,6 +36,16 @@ import org.jline.terminal.TerminalBuilder;
|
|||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOError;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.SERVER;
|
||||||
|
import static emu.grasscutter.utils.Language.translate;
|
||||||
|
|
||||||
public final class Grasscutter {
|
public final class Grasscutter {
|
||||||
public static final File configFile = new File("./config.json");
|
public static final File configFile = new File("./config.json");
|
||||||
public static final Reflections reflector = new Reflections("emu.grasscutter");
|
public static final Reflections reflector = new Reflections("emu.grasscutter");
|
||||||
@ -122,6 +124,8 @@ public final class Grasscutter {
|
|||||||
gameServer = new GameServer();
|
gameServer = new GameServer();
|
||||||
// Create a server hook instance with both servers.
|
// Create a server hook instance with both servers.
|
||||||
new ServerHelper(gameServer, httpServer);
|
new ServerHelper(gameServer, httpServer);
|
||||||
|
// noinspection removal
|
||||||
|
new ServerHook(gameServer, httpServer);
|
||||||
|
|
||||||
// Create plugin manager instance.
|
// Create plugin manager instance.
|
||||||
pluginManager = new PluginManager();
|
pluginManager = new PluginManager();
|
||||||
|
@ -2,17 +2,20 @@ package emu.grasscutter.plugin;
|
|||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.plugin.api.ServerHelper;
|
import emu.grasscutter.plugin.api.ServerHelper;
|
||||||
|
import emu.grasscutter.plugin.api.ServerHook;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.utils.FileUtils;
|
import emu.grasscutter.utils.FileUtils;
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
/** The base class for all plugins to extend. */
|
/** The base class for all plugins to extend. */
|
||||||
|
@SuppressWarnings("removal")
|
||||||
public abstract class Plugin {
|
public abstract class Plugin {
|
||||||
private final ServerHelper server = ServerHelper.getInstance();
|
private final ServerHelper server = ServerHook.getInstance();
|
||||||
|
|
||||||
private PluginIdentifier identifier;
|
private PluginIdentifier identifier;
|
||||||
private URLClassLoader classLoader;
|
private URLClassLoader classLoader;
|
||||||
@ -100,8 +103,8 @@ public abstract class Plugin {
|
|||||||
*
|
*
|
||||||
* @return A server hook singleton.
|
* @return A server hook singleton.
|
||||||
*/
|
*/
|
||||||
public final ServerHelper getHandle() {
|
public final ServerHook getHandle() {
|
||||||
return this.server;
|
return (ServerHook) this.server;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/** Hooks into the {@link GameServer} class, adding convenient ways to do certain things. */
|
/** Hooks into the {@link GameServer} class, adding convenient ways to do certain things. */
|
||||||
public final class ServerHelper {
|
public class ServerHelper {
|
||||||
private static ServerHelper instance;
|
private static ServerHelper instance;
|
||||||
private final GameServer gameServer;
|
private final GameServer gameServer;
|
||||||
private final HttpServer httpServer;
|
private final HttpServer httpServer;
|
||||||
|
30
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
Normal file
30
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package emu.grasscutter.plugin.api;
|
||||||
|
|
||||||
|
import emu.grasscutter.server.game.GameServer;
|
||||||
|
import emu.grasscutter.server.http.HttpServer;
|
||||||
|
|
||||||
|
@Deprecated(since = "2.0.0", forRemoval = true)
|
||||||
|
public final class ServerHook extends ServerHelper {
|
||||||
|
private static ServerHook instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hooks into a server.
|
||||||
|
*
|
||||||
|
* @param gameServer The game server to hook into.
|
||||||
|
* @param httpServer The HTTP server to hook into.
|
||||||
|
*/
|
||||||
|
public ServerHook(GameServer gameServer, HttpServer httpServer) {
|
||||||
|
super(gameServer, httpServer);
|
||||||
|
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the server hook instance.
|
||||||
|
*
|
||||||
|
* @return A {@link ServerHook} singleton.
|
||||||
|
*/
|
||||||
|
public static ServerHook getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user