Continue updating/refactoring classes

Most code is matched from `Grasscutter-Quests`.
This commit is contained in:
KingRainbow44
2023-04-01 22:17:10 -04:00
parent 772532515e
commit 9fbb7fb3be
97 changed files with 14397 additions and 12921 deletions

View File

@@ -6,11 +6,12 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerDebugMode;
import emu.grasscutter.Grasscutter.ServerRunMode;
import emu.grasscutter.utils.JsonUtils;
import lombok.NoArgsConstructor;
import java.util.Set;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Locale;
import java.util.Set;
import static emu.grasscutter.Grasscutter.config;
@@ -18,14 +19,6 @@ import static emu.grasscutter.Grasscutter.config;
* *when your JVM fails*
*/
public class ConfigContainer {
public Structure folderStructure = new Structure();
public Database databaseInfo = new Database();
public Language language = new Language();
public Account account = new Account();
public Server server = new Server();
// DO NOT. TOUCH. THE VERSION NUMBER.
public int version = version();
private static int version() {
return 4;
}
@@ -40,8 +33,7 @@ public class ConfigContainer {
Grasscutter.getLogger().info("Updating legacy ..");
Grasscutter.saveConfig(null);
}
} catch (Exception ignored) {
}
} catch (Exception ignored) { }
var existing = config.version;
var latest = version();
@@ -59,8 +51,7 @@ public class ConfigContainer {
} catch (Exception exception) {
Grasscutter.getLogger().error("Failed to update a configuration field.", exception);
}
});
updated.version = version();
}); updated.version = version();
try { // Save configuration & reload.
Grasscutter.saveConfig(updated);
@@ -70,6 +61,15 @@ public class ConfigContainer {
}
}
public Structure folderStructure = new Structure();
public Database databaseInfo = new Database();
public Language language = new Language();
public Account account = new Account();
public Server server = new Server();
// DO NOT. TOUCH. THE VERSION NUMBER.
public int version = version();
/* Option containers. */
public static class Database {
@@ -145,7 +145,7 @@ public class ConfigContainer {
public int accessPort = 0;
/* Entities within a certain range will be loaded for the player */
public int loadEntitiesForPlayerRange = 100;
public int loadEntitiesForPlayerRange = 300;
public boolean enableScriptInBigWorld = false;
public boolean enableConsole = true;
@@ -154,13 +154,24 @@ public class ConfigContainer {
/* Controls whether packets should be logged in console or not */
public ServerDebugMode logPackets = ServerDebugMode.NONE;
/* Show packet payload in console or no (in any case the payload is shown in encrypted view) */
public Boolean isShowPacketPayload = false;
public boolean isShowPacketPayload = false;
/* Show annoying loop packets or no */
public Boolean isShowLoopPackets = false;
public boolean isShowLoopPackets = false;
public boolean cacheSceneEntitiesEveryRun = false;
public GameOptions gameOptions = new GameOptions();
public JoinOptions joinOptions = new JoinOptions();
public ConsoleAccount serverAccount = new ConsoleAccount();
public VisionOptions[] visionOptions = new VisionOptions[] {
new VisionOptions("VISION_LEVEL_NORMAL" , 80 , 20),
new VisionOptions("VISION_LEVEL_LITTLE_REMOTE" , 16 , 40),
new VisionOptions("VISION_LEVEL_REMOTE" , 1000 , 250),
new VisionOptions("VISION_LEVEL_SUPER" , 4000 , 1000),
new VisionOptions("VISION_LEVEL_NEARBY" , 40 , 20),
new VisionOptions("VISION_LEVEL_SUPER_NEARBY" , 20 , 20)
};
}
/* Data containers. */
@@ -188,10 +199,10 @@ public class ConfigContainer {
public ServerDebugMode logPackets = ServerDebugMode.ALL;
/* Show packet payload in console or no (in any case the payload is shown in encrypted view) */
public Boolean isShowPacketPayload = false;
public boolean isShowPacketPayload = false;
/* Show annoying loop packets or no */
public Boolean isShowLoopPackets = false;
public boolean isShowLoopPackets = false;
/* Controls whether http requests should be logged in console or not */
public ServerDebugMode logRequests = ServerDebugMode.ALL;
@@ -224,6 +235,7 @@ public class ConfigContainer {
public boolean staminaUsage = true;
public boolean energyUsage = true;
public boolean fishhookTeleport = true;
public boolean questing = false;
public ResinOptions resinOptions = new ResinOptions();
public Rates rates = new Rates();
@@ -253,6 +265,18 @@ public class ConfigContainer {
}
}
public static class VisionOptions {
public String name;
public int visionRange;
public int gridWidth;
public VisionOptions(String name, int visionRange, int gridWidth) {
this.name = name;
this.visionRange = visionRange;
this.gridWidth = gridWidth;
}
}
public static class JoinOptions {
public int[] welcomeEmotes = {2007, 1002, 4010};
public String welcomeMessage = "Welcome to a Grasscutter server.";
@@ -261,12 +285,12 @@ public class ConfigContainer {
public static class Mail {
public String title = "Welcome to Grasscutter!";
public String content = """
Hi there!\r
First of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r
\r
Check out our:\r
<type="browser" text="Discord" href="https://discord.gg/T5vZU6UyeG"/>
""";
Hi there!\r
First of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r
\r
Check out our:\r
<type="browser" text="Discord" href="https://discord.gg/T5vZU6UyeG"/>
""";
public String sender = "Lawnmower";
public emu.grasscutter.game.mail.Mail.MailItem[] items = {
new emu.grasscutter.game.mail.Mail.MailItem(13509, 1, 1),
@@ -292,13 +316,13 @@ public class ConfigContainer {
/* Objects. */
@NoArgsConstructor
public static class Region {
public String Name = "os_usa";
public String Title = "Grasscutter";
public String Ip = "127.0.0.1";
public int Port = 22102;
public Region() {
}
public Region(
String name, String title,
String address, int port
@@ -306,7 +330,7 @@ public class ConfigContainer {
this.Name = name;
this.Title = title;
this.Ip = address;
this.Port = port;
this.Port = port;
}
}
}