diff --git a/build.gradle b/build.gradle index 900baaa..4fa6390 100644 --- a/build.gradle +++ b/build.gradle @@ -10,15 +10,15 @@ sourceCompatibility = 17 targetCompatibility = 17 group 'me.exzork.gcauth' -version '2.4.0' +version '2.4.1' repositories { mavenCentral() } dependencies { - implementation files('lib/grasscutter-1.1.2-dev.jar') - implementation 'org.springframework.security:spring-security-crypto:5.6.3' + implementation files('lib/grasscutter-1.2.3-dev.jar') + implementation 'org.springframework.security:spring-security-crypto:5.7.1' implementation 'commons-logging:commons-logging:1.2' implementation 'com.auth0:java-jwt:3.19.2' implementation 'javax.servlet:javax.servlet-api:4.0.1' diff --git a/settings.gradle b/settings.gradle index 97ba25b..7a19cf4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1 @@ rootProject.name = 'GCAuth' - diff --git a/src/main/java/me/exzork/gcauth/GCAuth.java b/src/main/java/me/exzork/gcauth/GCAuth.java index 6fdf0a1..fa0fd5f 100644 --- a/src/main/java/me/exzork/gcauth/GCAuth.java +++ b/src/main/java/me/exzork/gcauth/GCAuth.java @@ -5,9 +5,7 @@ import com.google.gson.GsonBuilder; import emu.grasscutter.Grasscutter; import emu.grasscutter.auth.DefaultAuthentication; import emu.grasscutter.plugin.Plugin; -import static emu.grasscutter.Configuration.ACCOUNT; -import emu.grasscutter.plugin.PluginManager; import me.exzork.gcauth.handler.*; import me.exzork.gcauth.utils.Authentication; @@ -17,6 +15,8 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; +import static emu.grasscutter.config.Configuration.ACCOUNT; + public class GCAuth extends Plugin { private static Config config; diff --git a/src/main/java/me/exzork/gcauth/handler/GCAuthAuthenticationHandler.java b/src/main/java/me/exzork/gcauth/handler/GCAuthAuthenticationHandler.java index 16f1faf..d13eaab 100644 --- a/src/main/java/me/exzork/gcauth/handler/GCAuthAuthenticationHandler.java +++ b/src/main/java/me/exzork/gcauth/handler/GCAuthAuthenticationHandler.java @@ -8,7 +8,7 @@ import emu.grasscutter.server.http.objects.LoginResultJson; import me.exzork.gcauth.utils.Authentication; public class GCAuthAuthenticationHandler implements AuthenticationSystem { - private final Authenticator gcAuthAuthenticator = new GCAuthenticators.GCAuthAuthenticator(); + private final Authenticator gcAuthAuthenticator = new GCAuthenticators.GCAuthAuthenticator();; private final Authenticator tokenAuthenticator = new DefaultAuthenticators.TokenAuthenticator(); private final Authenticator sessionKeyAuthenticator = new DefaultAuthenticators.SessionKeyAuthenticator(); private final GCAuthExternalAuthenticator externalAuthenticator = new GCAuthExternalAuthenticator(); diff --git a/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java b/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java index b48f51b..25067cb 100644 --- a/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java +++ b/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java @@ -1,14 +1,11 @@ package me.exzork.gcauth.handler; import com.google.gson.Gson; -import com.mchange.v1.util.ArrayUtils; -import emu.grasscutter.Grasscutter; import emu.grasscutter.auth.AuthenticationSystem; import emu.grasscutter.auth.ExternalAuthenticator; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.Account; import express.http.Response; -import io.javalin.http.Context; import io.javalin.http.util.RateLimit; import me.exzork.gcauth.GCAuth; import me.exzork.gcauth.json.AuthResponseJson; @@ -18,12 +15,11 @@ import me.exzork.gcauth.json.RegisterAccount; import me.exzork.gcauth.utils.Authentication; import java.util.Arrays; -import java.util.concurrent.TimeUnit; public class GCAuthExternalAuthenticator implements ExternalAuthenticator { - private String[] endPoints = GCAuth.getInstance().getConfig().rateLimit.endPoints; - private int maxRequests = GCAuth.getInstance().getConfig().rateLimit.maxRequests; - private String timeUnit = GCAuth.getInstance().getConfig().rateLimit.timeUnit; + private final String[] endPoints = GCAuth.getInstance().getConfig().rateLimit.endPoints; + private final int maxRequests = GCAuth.getInstance().getConfig().rateLimit.maxRequests; + private final String timeUnit = GCAuth.getInstance().getConfig().rateLimit.timeUnit; @Override public void handleLogin(AuthenticationSystem.AuthenticationRequest authenticationRequest) { AuthResponseJson authResponse = new AuthResponseJson(); diff --git a/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java b/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java index 9d7b6b6..44f7ed4 100644 --- a/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java +++ b/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java @@ -1,6 +1,5 @@ package me.exzork.gcauth.handler; -import emu.grasscutter.Grasscutter; import emu.grasscutter.auth.AuthenticationSystem; import emu.grasscutter.auth.Authenticator; import emu.grasscutter.game.Account; @@ -11,7 +10,6 @@ import me.exzork.gcauth.utils.Authentication; public class GCAuthenticators { public static class GCAuthAuthenticator implements Authenticator { - @Override public LoginResultJson authenticate(AuthenticationSystem.AuthenticationRequest authenticationRequest) { var response = new LoginResultJson(); diff --git a/src/main/java/me/exzork/gcauth/utils/Authentication.java b/src/main/java/me/exzork/gcauth/utils/Authentication.java index f824ed7..e557f13 100644 --- a/src/main/java/me/exzork/gcauth/utils/Authentication.java +++ b/src/main/java/me/exzork/gcauth/utils/Authentication.java @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit; public final class Authentication { public static final HashMap otps = new HashMap<>(); - private static Algorithm key = Algorithm.HMAC256(generateRandomNumber(32)); + private static final Algorithm key = Algorithm.HMAC256(generateRandomNumber(32)); public static Algorithm getKey() { return key; } @@ -119,7 +119,6 @@ public final class Authentication { public static TimeUnit getTimeUnit(String timeUnit) { return switch (timeUnit.toLowerCase()) { case "seconds" -> TimeUnit.SECONDS; - case "minutes" -> TimeUnit.MINUTES; case "hours" -> TimeUnit.HOURS; case "days" -> TimeUnit.DAYS; default -> TimeUnit.MINUTES; diff --git a/src/main/resources/plugin.json b/src/main/resources/plugin.json index 899645a..d7fc659 100644 --- a/src/main/resources/plugin.json +++ b/src/main/resources/plugin.json @@ -1,7 +1,7 @@ { "name": "GCAuth", "description": "GCAuth is a plugin that allows you to implement authentication for your server.", - "version": "2.2.0", + "version": "2.4.1", "author": ["ExZork"], "mainClass": "me.exzork.gcauth.GCAuth" }