From 738a642dba4f026954ee5a9b8180faf2f31d91e2 Mon Sep 17 00:00:00 2001 From: muhammadeko Date: Sun, 29 May 2022 18:10:05 +0700 Subject: [PATCH] change getPlayerUid and use plugin logger --- README.md | 13 +++++++------ build.gradle | 2 +- .../gcauth/handler/GCAuthExternalAuthenticator.java | 6 +++--- .../me/exzork/gcauth/handler/GCAuthenticators.java | 3 ++- .../java/me/exzork/gcauth/utils/Authentication.java | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1004501..b7fcc07 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,13 @@ Grasscutter Authentication System ### Version Compatibility -| GCAuth | Grasscutter Development | Grasscutter Stable | -|---------------|-------------------------|--------------------| -| 2.2.1+ | 1.1.2-dev | - | -| 2.1.4 - 2.1.6 | 1.1.1-dev | - | -| 2.0.0 - 2.1.3 | 1.0.3-dev | 1.1.0 | -| 1.0.0 | 1.0.2-dev | - | +| GCAuth | Grasscutter Development | Grasscutter Stable | +|---------------|--------------------------------------------------------------------------------------------------------------------------------|--------------------| +| 2.3.1+ | 1.1.2-dev ( [141b191](https://github.com/Grasscutters/Grasscutter/commit/ce07f56f9d10cc79c9b7104b66c2e4ff19cd4f53) and after ) | - | +| 2.2.1 - 2.3.0 | 1.1.2-dev ( before [141b191](https://github.com/Grasscutters/Grasscutter/commit/ce07f56f9d10cc79c9b7104b66c2e4ff19cd4f53) ) | - | +| 2.1.4 - 2.1.6 | 1.1.1-dev | - | +| 2.0.0 - 2.1.3 | 1.0.3-dev | 1.1.0 | +| 1.0.0 | 1.0.2-dev | - | ### Usage : - Place jar inside plugins folder of Grasscutter. diff --git a/build.gradle b/build.gradle index d2b21c3..95fffcc 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ sourceCompatibility = 17 targetCompatibility = 17 group 'me.exzork.gcauth' -version '2.3.0' +version '2.3.1' repositories { mavenCentral() diff --git a/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java b/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java index 1683201..31bd248 100644 --- a/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java +++ b/src/main/java/me/exzork/gcauth/handler/GCAuthExternalAuthenticator.java @@ -56,7 +56,7 @@ public class GCAuthExternalAuthenticator implements ExternalAuthenticator { authResponse.success = false; authResponse.message = "UNKNOWN"; // ENG = "An unknown error has occurred..." authResponse.jwt = ""; - Grasscutter.getLogger().error("[Dispatch] An error occurred while a user was logging in."); + GCAuth.getInstance().getLogger().error("[Dispatch] An error occurred while a user was logging in."); e.printStackTrace(); } response.send(authResponse); @@ -126,7 +126,7 @@ public class GCAuthExternalAuthenticator implements ExternalAuthenticator { authResponse.success = false; authResponse.message = "UNKNOWN"; // ENG = "An unknown error has occurred..." authResponse.jwt = ""; - Grasscutter.getLogger().error("[Dispatch] An error occurred while creating an account."); + GCAuth.getInstance().getLogger().error("[Dispatch] An error occurred while creating an account."); e.printStackTrace(); } if (authResponse.success) { @@ -190,7 +190,7 @@ public class GCAuthExternalAuthenticator implements ExternalAuthenticator { authResponse.success = false; authResponse.message = "UNKNOWN"; // ENG = "An unknown error has occurred..." authResponse.jwt = ""; - Grasscutter.getLogger().error("[Dispatch] Error while changing user password."); + GCAuth.getInstance().getLogger().error("[Dispatch] Error while changing user password."); e.printStackTrace(); } response.send(authResponse); diff --git a/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java b/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java index d0fab2b..9d7b6b6 100644 --- a/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java +++ b/src/main/java/me/exzork/gcauth/handler/GCAuthenticators.java @@ -5,6 +5,7 @@ import emu.grasscutter.auth.AuthenticationSystem; import emu.grasscutter.auth.Authenticator; import emu.grasscutter.game.Account; import emu.grasscutter.server.http.objects.LoginResultJson; +import me.exzork.gcauth.GCAuth; import me.exzork.gcauth.utils.Authentication; public class GCAuthenticators { @@ -31,7 +32,7 @@ public class GCAuthenticators { response.data.account.token = account.generateSessionKey(); response.data.account.email = account.getEmail(); - Grasscutter.getLogger().info("[GCAuth] Client " + requestData.account + " logged in"); + GCAuth.getInstance().getLogger().info("[GCAuth] Client " + requestData.account + " logged in"); return response; } } diff --git a/src/main/java/me/exzork/gcauth/utils/Authentication.java b/src/main/java/me/exzork/gcauth/utils/Authentication.java index c91357c..716bd31 100644 --- a/src/main/java/me/exzork/gcauth/utils/Authentication.java +++ b/src/main/java/me/exzork/gcauth/utils/Authentication.java @@ -71,7 +71,7 @@ public final class Authentication { return JWT.create() .withClaim("token", otp) .withClaim("username", account.getUsername()) - .withClaim("uid", account.getPlayerUid()) + .withClaim("uid", account.getReservedPlayerUid()) .withExpiresAt(Date.from(Instant.ofEpochSecond(System.currentTimeMillis() / 1000 + GCAuth.getInstance().getConfig().jwtExpiration))) .sign(key); }