mirror of
https://github.com/exzork/GCAuth.git
synced 2024-11-24 00:23:58 +00:00
Merge pull request #6 from exzork/development
Implement suggestion #4 and cleaning some import files
This commit is contained in:
commit
b43c76a434
@ -10,7 +10,7 @@ sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
group 'me.exzork.gcauth'
|
||||
version '2.1.0'
|
||||
version '2.1.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -42,5 +42,4 @@ jar{
|
||||
exclude("META-INF/NOTICE")
|
||||
}
|
||||
destinationDir = file(".")
|
||||
|
||||
}
|
@ -3,23 +3,9 @@ package me.exzork.gcauth;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.Account;
|
||||
import emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass;
|
||||
import emu.grasscutter.plugin.Plugin;
|
||||
import emu.grasscutter.server.dispatch.DispatchHttpJsonHandler;
|
||||
import emu.grasscutter.server.dispatch.json.ComboTokenReqJson;
|
||||
import emu.grasscutter.server.dispatch.json.ComboTokenResJson;
|
||||
import emu.grasscutter.server.dispatch.json.LoginResultJson;
|
||||
import emu.grasscutter.server.dispatch.json.LoginTokenRequestJson;
|
||||
import emu.grasscutter.server.event.dispatch.QueryAllRegionsEvent;
|
||||
import emu.grasscutter.server.event.dispatch.QueryCurrentRegionEvent;
|
||||
import express.Express;
|
||||
import me.exzork.gcauth.handler.*;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
@ -30,10 +16,12 @@ import java.nio.file.Files;
|
||||
|
||||
public class GCAuth extends Plugin {
|
||||
private static Config config;
|
||||
private static final File configFile = new File(Grasscutter.getConfig().PLUGINS_FOLDER+"GCAuth/config.json");
|
||||
private File configFile;
|
||||
private static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
public void onEnable() {
|
||||
configFile = new File(getDataFolder().toPath()+ "/config.json");
|
||||
if (!configFile.exists()) {
|
||||
try {
|
||||
Files.createDirectories(configFile.toPath().getParent());
|
||||
@ -42,10 +30,6 @@ public class GCAuth extends Plugin {
|
||||
}
|
||||
}
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if(Grasscutter.getDispatchServer().registerAuthHandler(new GCAuthAuthenticationHandler())) {
|
||||
Grasscutter.getLogger().info("[GCAuth] GCAuth Enabled!");
|
||||
|
||||
@ -64,7 +48,7 @@ public class GCAuth extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
public void loadConfig() {
|
||||
try (FileReader file = new FileReader(configFile)) {
|
||||
config = gson.fromJson(file,Config.class);
|
||||
saveConfig();
|
||||
@ -74,23 +58,12 @@ public class GCAuth extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveConfig() {
|
||||
public void saveConfig() {
|
||||
try (FileWriter file = new FileWriter(configFile)) {
|
||||
file.write(gson.toJson(config));
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("[GCAuth] Unable to save config file.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class RegionData {
|
||||
QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp parsedRegionQuery;
|
||||
String Base64;
|
||||
|
||||
public RegionData(QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp prq, String b64) {
|
||||
this.parsedRegionQuery = prq;
|
||||
this.Base64 = b64;
|
||||
}
|
||||
}
|
||||
public static Config getConfig() {return config;}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import emu.grasscutter.game.Account;
|
||||
import express.http.HttpContextHandler;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import me.exzork.gcauth.GCAuth;
|
||||
import me.exzork.gcauth.json.AuthResponseJson;
|
||||
import me.exzork.gcauth.json.ChangePasswordAccount;
|
||||
import me.exzork.gcauth.utils.Authentication;
|
||||
|
@ -2,14 +2,12 @@ package me.exzork.gcauth.handler;
|
||||
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.Account;
|
||||
import emu.grasscutter.server.dispatch.authentication.AuthenticationHandler;
|
||||
import emu.grasscutter.server.dispatch.json.LoginAccountRequestJson;
|
||||
import emu.grasscutter.server.dispatch.json.LoginResultJson;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import me.exzork.gcauth.GCAuth;
|
||||
import me.exzork.gcauth.utils.Authentication;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -6,7 +6,6 @@ import emu.grasscutter.game.Account;
|
||||
import express.http.HttpContextHandler;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import me.exzork.gcauth.GCAuth;
|
||||
import me.exzork.gcauth.json.AuthResponseJson;
|
||||
import me.exzork.gcauth.json.LoginGenerateToken;
|
||||
import me.exzork.gcauth.utils.Authentication;
|
||||
|
@ -7,7 +7,6 @@ import emu.grasscutter.game.Account;
|
||||
import express.http.HttpContextHandler;
|
||||
import express.http.Request;
|
||||
import express.http.Response;
|
||||
import me.exzork.gcauth.GCAuth;
|
||||
import me.exzork.gcauth.json.AuthResponseJson;
|
||||
import me.exzork.gcauth.json.RegisterAccount;
|
||||
import me.exzork.gcauth.utils.Authentication;
|
||||
|
Loading…
Reference in New Issue
Block a user