aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/elytrium/limboauth
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/elytrium/limboauth')
-rw-r--r--src/main/java/net/elytrium/limboauth/LimboAuth.java16
-rw-r--r--src/main/java/net/elytrium/limboauth/Settings.java20
-rw-r--r--src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java11
3 files changed, 24 insertions, 23 deletions
diff --git a/src/main/java/net/elytrium/limboauth/LimboAuth.java b/src/main/java/net/elytrium/limboauth/LimboAuth.java
index 0837fea..eed58f3 100644
--- a/src/main/java/net/elytrium/limboauth/LimboAuth.java
+++ b/src/main/java/net/elytrium/limboauth/LimboAuth.java
@@ -78,13 +78,11 @@ import net.elytrium.java.commons.reflection.ReflectionException;
import net.elytrium.java.commons.updates.UpdatesChecker;
import net.elytrium.limboapi.api.Limbo;
import net.elytrium.limboapi.api.LimboFactory;
-import net.elytrium.limboapi.api.chunk.Dimension;
import net.elytrium.limboapi.api.chunk.VirtualWorld;
import net.elytrium.limboapi.api.command.LimboCommandMeta;
import net.elytrium.limboapi.api.file.SchematicFile;
import net.elytrium.limboapi.api.file.StructureFile;
import net.elytrium.limboapi.api.file.WorldFile;
-import net.elytrium.limboapi.api.player.GameMode;
import net.elytrium.limboauth.command.ChangePasswordCommand;
import net.elytrium.limboauth.command.DestroySessionCommand;
import net.elytrium.limboauth.command.ForceChangePasswordCommand;
@@ -201,10 +199,10 @@ public class LimboAuth {
Metrics metrics = this.metricsFactory.make(this, 13700);
metrics.addCustomChart(new SimplePie("floodgate_auth", () -> String.valueOf(Settings.IMP.MAIN.FLOODGATE_NEED_AUTH)));
metrics.addCustomChart(new SimplePie("premium_auth", () -> String.valueOf(Settings.IMP.MAIN.ONLINE_MODE_NEED_AUTH)));
- metrics.addCustomChart(new SimplePie("db_type", () -> Settings.IMP.DATABASE.STORAGE_TYPE));
+ metrics.addCustomChart(new SimplePie("db_type", () -> String.valueOf(Settings.IMP.DATABASE.STORAGE_TYPE)));
metrics.addCustomChart(new SimplePie("load_world", () -> String.valueOf(Settings.IMP.MAIN.LOAD_WORLD)));
metrics.addCustomChart(new SimplePie("totp_enabled", () -> String.valueOf(Settings.IMP.MAIN.ENABLE_TOTP)));
- metrics.addCustomChart(new SimplePie("dimension", () -> Settings.IMP.MAIN.DIMENSION));
+ metrics.addCustomChart(new SimplePie("dimension", () -> String.valueOf(Settings.IMP.MAIN.DIMENSION)));
metrics.addCustomChart(new SimplePie("save_uuid", () -> String.valueOf(Settings.IMP.MAIN.SAVE_UUID)));
metrics.addCustomChart(new SingleLineChart("registered_players", () -> Math.toIntExact(this.playerDao.countOf())));
@@ -225,7 +223,7 @@ public class LimboAuth {
+ " please install floodgate plugin.");
}
- ComponentSerializer<Component, Component, String> serializer = Serializers.valueOf(Settings.IMP.SERIALIZER.toUpperCase(Locale.ROOT)).getSerializer();
+ ComponentSerializer<Component, Component, String> serializer = Settings.IMP.SERIALIZER.getSerializer();
if (serializer == null) {
LOGGER.warn("The specified serializer could not be founded, using default. (LEGACY_AMPERSAND)");
setSerializer(new Serializer(Objects.requireNonNull(Serializers.LEGACY_AMPERSAND.getSerializer())));
@@ -284,7 +282,7 @@ public class LimboAuth {
this.bruteforceCache.clear();
Settings.DATABASE dbConfig = Settings.IMP.DATABASE;
- DatabaseLibrary databaseLibrary = DatabaseLibrary.valueOf(dbConfig.STORAGE_TYPE.toUpperCase(Locale.ROOT));
+ DatabaseLibrary databaseLibrary = dbConfig.STORAGE_TYPE;
try {
this.connectionSource = databaseLibrary.connectToORM(
this.dataDirectoryFile.toPath().toAbsolutePath(),
@@ -334,7 +332,7 @@ public class LimboAuth {
Settings.MAIN.AUTH_COORDS authCoords = Settings.IMP.MAIN.AUTH_COORDS;
VirtualWorld authWorld = this.factory.createVirtualWorld(
- Dimension.valueOf(Settings.IMP.MAIN.DIMENSION),
+ Settings.IMP.MAIN.DIMENSION,
authCoords.X, authCoords.Y, authCoords.Z,
(float) authCoords.YAW, (float) authCoords.PITCH
);
@@ -374,7 +372,7 @@ public class LimboAuth {
.createLimbo(authWorld)
.setName("LimboAuth")
.setWorldTime(Settings.IMP.MAIN.WORLD_TICKS)
- .setGameMode(GameMode.valueOf(Settings.IMP.MAIN.GAME_MODE))
+ .setGameMode(Settings.IMP.MAIN.GAME_MODE)
.registerCommand(new LimboCommandMeta(this.filterCommands(Settings.IMP.MAIN.REGISTER_COMMAND)))
.registerCommand(new LimboCommandMeta(this.filterCommands(Settings.IMP.MAIN.LOGIN_COMMAND)))
.registerCommand(new LimboCommandMeta(this.filterCommands(Settings.IMP.MAIN.TOTP_COMMAND)));
@@ -436,7 +434,7 @@ public class LimboAuth {
String findSql;
String database = Settings.IMP.DATABASE.DATABASE;
String tableName = tableInfo.getTableName();
- DatabaseLibrary databaseLibrary = DatabaseLibrary.valueOf(Settings.IMP.DATABASE.STORAGE_TYPE.toUpperCase(Locale.ROOT));
+ DatabaseLibrary databaseLibrary = Settings.IMP.DATABASE.STORAGE_TYPE;
switch (databaseLibrary) {
case SQLITE: {
findSql = "SELECT name FROM PRAGMA_TABLE_INFO('" + tableName + "')";
diff --git a/src/main/java/net/elytrium/limboauth/Settings.java b/src/main/java/net/elytrium/limboauth/Settings.java
index fb342b3..c08cc08 100644
--- a/src/main/java/net/elytrium/limboauth/Settings.java
+++ b/src/main/java/net/elytrium/limboauth/Settings.java
@@ -19,6 +19,12 @@ package net.elytrium.limboauth;
import java.util.List;
import net.elytrium.java.commons.config.YamlConfig;
+import net.elytrium.java.commons.mc.serialization.Serializers;
+import net.elytrium.limboapi.api.chunk.Dimension;
+import net.elytrium.limboapi.api.player.GameMode;
+import net.elytrium.limboauth.dependencies.DatabaseLibrary;
+import net.elytrium.limboauth.migration.MigrationHash;
+import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.util.Ticks;
@@ -38,7 +44,7 @@ public class Settings extends YamlConfig {
"GSON - \"[{\"text\":\"Example\",\"bold\":true,\"color\":\"red\"},{\"text\":\" \",\"bold\":true},{\"text\":\"Text\",\"bold\":true,\"color\":\"blue\"}]\". (https://minecraft.tools/en/json_text.php/)",
"GSON_COLOR_DOWNSAMPLING - Same as GSON, but uses downsampling."
})
- public String SERIALIZER = "LEGACY_AMPERSAND";
+ public Serializers SERIALIZER = Serializers.LEGACY_AMPERSAND;
public String PREFIX = "LimboAuth &6>>&f";
@Create
@@ -51,9 +57,9 @@ public class Settings extends YamlConfig {
public int AUTH_TIME = 60000;
public boolean ENABLE_BOSSBAR = true;
@Comment("Available colors: PINK, BLUE, RED, GREEN, YELLOW, PURPLE, WHITE")
- public String BOSSBAR_COLOR = "RED";
+ public BossBar.Color BOSSBAR_COLOR = BossBar.Color.RED;
@Comment("Available overlays: PROGRESS, NOTCHED_6, NOTCHED_10, NOTCHED_12, NOTCHED_20")
- public String BOSSBAR_OVERLAY = "NOTCHED_20";
+ public BossBar.Overlay BOSSBAR_OVERLAY = BossBar.Overlay.NOTCHED_20;
public int MIN_PASSWORD_LENGTH = 4;
@Comment("Max password length for the BCrypt hashing algorithm, which is used in this plugin, can't be higher than 71. You can set a lower value than 71.")
public int MAX_PASSWORD_LENGTH = 71;
@@ -111,9 +117,9 @@ public class Settings extends YamlConfig {
"SHA512_NO_SALT - SHA512(password) that looks like $SHA$hash (NexAuth)",
"SHA512_P_REVERSED_HASH - SHA512(password) that looks like $SHA$hash$salt (nLogin)",
})
- public String MIGRATION_HASH = "";
+ public MigrationHash MIGRATION_HASH = MigrationHash.AUTHME;
@Comment("Available dimensions: OVERWORLD, NETHER, THE_END")
- public String DIMENSION = "THE_END";
+ public Dimension DIMENSION = Dimension.THE_END;
public long PURGE_CACHE_MILLIS = 3600000;
public long PURGE_PREMIUM_CACHE_MILLIS = 28800000;
public long PURGE_BRUTEFORCE_CACHE_MILLIS = 28800000;
@@ -149,7 +155,7 @@ public class Settings extends YamlConfig {
public int WORLD_LIGHT_LEVEL = 15;
@Comment("Available: ADVENTURE, CREATIVE, SURVIVAL, SPECTATOR")
- public String GAME_MODE = "ADVENTURE";
+ public GameMode GAME_MODE = GameMode.ADVENTURE;
@Comment({
"Custom isPremium URL",
@@ -384,7 +390,7 @@ public class Settings extends YamlConfig {
public static class DATABASE {
@Comment("Database type: mysql, postgresql, sqlite or h2.")
- public String STORAGE_TYPE = "h2";
+ public DatabaseLibrary STORAGE_TYPE = DatabaseLibrary.H2;
@Comment("Settings for Network-based database (like MySQL, PostgreSQL): ")
public String HOSTNAME = "127.0.0.1:3306";
diff --git a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java
index 493e96c..20188eb 100644
--- a/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java
+++ b/src/main/java/net/elytrium/limboauth/handler/AuthSessionHandler.java
@@ -378,8 +378,8 @@ public class AuthSessionHandler implements LimboSessionHandler {
public static void reload() {
Serializer serializer = LimboAuth.getSerializer();
- bossbarColor = BossBar.Color.valueOf(Settings.IMP.MAIN.BOSSBAR_COLOR.toUpperCase(Locale.ROOT));
- bossbarOverlay = BossBar.Overlay.valueOf(Settings.IMP.MAIN.BOSSBAR_OVERLAY.toUpperCase(Locale.ROOT));
+ bossbarColor = Settings.IMP.MAIN.BOSSBAR_COLOR;
+ bossbarOverlay = Settings.IMP.MAIN.BOSSBAR_OVERLAY;
ipLimitKick = serializer.deserialize(Settings.IMP.MAIN.STRINGS.IP_LIMIT_KICK);
databaseErrorKick = serializer.deserialize(Settings.IMP.MAIN.STRINGS.DATABASE_ERROR_KICK);
wrongNicknameCaseKick = Settings.IMP.MAIN.STRINGS.WRONG_NICKNAME_CASE_KICK;
@@ -447,11 +447,8 @@ public class AuthSessionHandler implements LimboSessionHandler {
Settings.IMP.MAIN.CRACKED_TITLE_SETTINGS.toTimes()
);
}
- if (Settings.IMP.MAIN.MIGRATION_HASH.isEmpty()) {
- migrationHash = null;
- } else {
- migrationHash = MigrationHash.valueOf(Settings.IMP.MAIN.MIGRATION_HASH);
- }
+
+ migrationHash = Settings.IMP.MAIN.MIGRATION_HASH;
}
public static boolean checkPassword(String password, RegisteredPlayer player, Dao<RegisteredPlayer, String> playerDao) {