mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 08:47:39 +00:00
Remove deprecated API & Fix resource checking
This commit is contained in:
parent
7db45a0a12
commit
28da66fff4
@ -1,60 +1,37 @@
|
||||
package emu.grasscutter;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.SERVER;
|
||||
import static emu.grasscutter.utils.lang.Language.translate;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import emu.grasscutter.auth.AuthenticationSystem;
|
||||
import emu.grasscutter.auth.DefaultAuthentication;
|
||||
import emu.grasscutter.command.CommandMap;
|
||||
import emu.grasscutter.command.DefaultPermissionHandler;
|
||||
import emu.grasscutter.command.PermissionHandler;
|
||||
import ch.qos.logback.classic.*;
|
||||
import emu.grasscutter.auth.*;
|
||||
import emu.grasscutter.command.*;
|
||||
import emu.grasscutter.config.ConfigContainer;
|
||||
import emu.grasscutter.data.ResourceLoader;
|
||||
import emu.grasscutter.database.DatabaseManager;
|
||||
import emu.grasscutter.plugin.PluginManager;
|
||||
import emu.grasscutter.plugin.api.ServerHelper;
|
||||
import emu.grasscutter.plugin.api.ServerHook;
|
||||
import emu.grasscutter.server.dispatch.DispatchServer;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.server.http.HttpServer;
|
||||
import emu.grasscutter.server.http.dispatch.AuthenticationHandler;
|
||||
import emu.grasscutter.server.http.dispatch.RegionHandler;
|
||||
import emu.grasscutter.server.http.documentation.DocumentationServerHandler;
|
||||
import emu.grasscutter.server.http.documentation.HandbookHandler;
|
||||
import emu.grasscutter.server.http.handlers.AnnouncementsHandler;
|
||||
import emu.grasscutter.server.http.handlers.GachaHandler;
|
||||
import emu.grasscutter.server.http.handlers.GenericHandler;
|
||||
import emu.grasscutter.server.http.handlers.LogHandler;
|
||||
import emu.grasscutter.server.http.dispatch.*;
|
||||
import emu.grasscutter.server.http.documentation.*;
|
||||
import emu.grasscutter.server.http.handlers.*;
|
||||
import emu.grasscutter.tools.Tools;
|
||||
import emu.grasscutter.utils.Crypto;
|
||||
import emu.grasscutter.utils.JsonUtils;
|
||||
import emu.grasscutter.utils.StartupArguments;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import emu.grasscutter.utils.*;
|
||||
import emu.grasscutter.utils.lang.Language;
|
||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOError;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jline.reader.EndOfFileException;
|
||||
import org.jline.reader.LineReader;
|
||||
import org.jline.reader.LineReaderBuilder;
|
||||
import org.jline.reader.UserInterruptException;
|
||||
import org.jline.terminal.Terminal;
|
||||
import org.jline.terminal.TerminalBuilder;
|
||||
import lombok.*;
|
||||
import org.jline.reader.*;
|
||||
import org.jline.terminal.*;
|
||||
import org.reflections.Reflections;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.SERVER;
|
||||
import static emu.grasscutter.utils.lang.Language.translate;
|
||||
|
||||
public final class Grasscutter {
|
||||
public static final File configFile = new File("./config.json");
|
||||
public static final Reflections reflector = new Reflections("emu.grasscutter");
|
||||
@ -156,8 +133,6 @@ public final class Grasscutter {
|
||||
|
||||
// Create a server hook instance with both servers.
|
||||
new ServerHelper(gameServer, httpServer);
|
||||
// noinspection removal
|
||||
new ServerHook(gameServer, httpServer);
|
||||
|
||||
// Create plugin manager instance.
|
||||
pluginManager = new PluginManager();
|
||||
|
@ -1,27 +1,19 @@
|
||||
package emu.grasscutter.game.world;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.DataLoader;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.InvestigationMonsterData;
|
||||
import emu.grasscutter.data.excels.RewardPreviewData;
|
||||
import emu.grasscutter.data.*;
|
||||
import emu.grasscutter.data.excels.*;
|
||||
import emu.grasscutter.data.excels.world.WorldLevelData;
|
||||
import emu.grasscutter.game.entity.gadget.chest.BossChestInteractHandler;
|
||||
import emu.grasscutter.game.entity.gadget.chest.ChestInteractHandler;
|
||||
import emu.grasscutter.game.entity.gadget.chest.NormalChestInteractHandler;
|
||||
import emu.grasscutter.game.entity.gadget.chest.*;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.InvestigationMonsterOuterClass;
|
||||
import emu.grasscutter.scripts.data.SceneGroup;
|
||||
import emu.grasscutter.scripts.data.SceneMonster;
|
||||
import emu.grasscutter.server.game.BaseGameSystem;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import emu.grasscutter.scripts.data.*;
|
||||
import emu.grasscutter.server.game.*;
|
||||
import org.luaj.vm2.LuaError;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class WorldDataSystem extends BaseGameSystem {
|
||||
private final Map<String, ChestInteractHandler> chestInteractHandlerMap; // chestType-Handler
|
||||
private final Map<String, SceneGroup> sceneInvestigationGroupMap; // <sceneId_groupId, Group>
|
||||
@ -57,7 +49,6 @@ public class WorldDataSystem extends BaseGameSystem {
|
||||
return chestInteractHandlerMap;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RewardPreviewData getRewardByBossId(int monsterId) {
|
||||
var investigationMonsterData =
|
||||
GameData.getInvestigationMonsterDataMap().values().parallelStream()
|
||||
@ -65,11 +56,8 @@ public class WorldDataSystem extends BaseGameSystem {
|
||||
.filter(imd -> imd.getMonsterIdList().get(0) == monsterId)
|
||||
.findFirst();
|
||||
|
||||
if (investigationMonsterData.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return GameData.getRewardPreviewDataMap()
|
||||
.get(investigationMonsterData.get().getRewardPreviewId());
|
||||
return investigationMonsterData.map(monsterData -> GameData.getRewardPreviewDataMap()
|
||||
.get(monsterData.getRewardPreviewId())).orElse(null);
|
||||
}
|
||||
|
||||
private SceneGroup getInvestigationGroup(int sceneId, int groupId) {
|
||||
|
@ -3,21 +3,18 @@ package emu.grasscutter.plugin;
|
||||
import ch.qos.logback.classic.Level;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.plugin.api.ServerHelper;
|
||||
import emu.grasscutter.plugin.api.ServerHook;
|
||||
import emu.grasscutter.server.game.GameServer;
|
||||
import emu.grasscutter.utils.FileUtils;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLClassLoader;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
/** The base class for all plugins to extend. */
|
||||
@EqualsAndHashCode
|
||||
@SuppressWarnings("removal")
|
||||
public abstract class Plugin {
|
||||
private final ServerHelper server = ServerHook.getInstance();
|
||||
private final ServerHelper server = ServerHelper.getInstance();
|
||||
|
||||
private PluginIdentifier identifier;
|
||||
private URLClassLoader classLoader;
|
||||
@ -31,6 +28,7 @@ public abstract class Plugin {
|
||||
*
|
||||
* @param identifier The plugin's identifier.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void initializePlugin(PluginIdentifier identifier, URLClassLoader classLoader) {
|
||||
if (this.identifier != null) {
|
||||
Grasscutter.getLogger().warn(this.identifier.name + " had a reinitialization attempt.");
|
||||
@ -109,8 +107,8 @@ public abstract class Plugin {
|
||||
*
|
||||
* @return A server hook singleton.
|
||||
*/
|
||||
public final ServerHook getHandle() {
|
||||
return (ServerHook) this.server;
|
||||
public final ServerHelper getHandle() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@ import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/** Hooks into the {@link GameServer} class, adding convenient ways to do certain things. */
|
||||
public class ServerHelper {
|
||||
public final class ServerHelper {
|
||||
private static ServerHelper instance;
|
||||
private final GameServer gameServer;
|
||||
private final HttpServer httpServer;
|
||||
|
@ -1,30 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,31 +1,25 @@
|
||||
package emu.grasscutter.utils;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
||||
import static emu.grasscutter.utils.lang.Language.translate;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.config.ConfigContainer;
|
||||
import emu.grasscutter.data.DataLoader;
|
||||
import emu.grasscutter.game.world.Position;
|
||||
import io.javalin.http.Context;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import io.netty.buffer.*;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.nio.file.*;
|
||||
import java.time.*;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import javax.annotation.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
||||
import static emu.grasscutter.utils.lang.Language.translate;
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "BooleanMethodIsAlwaysInverted"})
|
||||
public final class Utils {
|
||||
@ -196,10 +190,6 @@ public final class Utils {
|
||||
// Check for game data.
|
||||
if (!fileExists(dataFolder)) createFolder(dataFolder);
|
||||
|
||||
// Make sure the data folder is populated, if there are any missing files copy them from
|
||||
// resources
|
||||
DataLoader.checkAllFiles();
|
||||
|
||||
// Check for Server resources.
|
||||
if (!Files.exists(getResourcePath("Server"))) {
|
||||
logger.info(translate("messages.status.resources.missing_server"));
|
||||
@ -217,6 +207,9 @@ public final class Utils {
|
||||
|
||||
// Exit if there are any missing files.
|
||||
if (exit) System.exit(1);
|
||||
|
||||
// Validate the data directory.
|
||||
DataLoader.checkAllFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user