Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #57

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Dev #57

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/main/java/cc/baka9/catseedlogin/bukkit/Communication.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void socketServerStartAsync() {
/**
* 启动 socket server 监听bc端发来的请求
*/
private static void socketServerStart() {
public static void socketServerStart() {
try {
InetAddress inetAddress = InetAddress.getByName(Config.BungeeCord.Host);
serverSocket = new ServerSocket(Integer.parseInt(Config.BungeeCord.Port), 50, inetAddress);
Expand Down Expand Up @@ -97,9 +97,9 @@ private static void handleRequest(Socket socket) throws IOException {
private static void handleKeepLoggedInRequest(String playerName, String time, String sign) {
// 验证请求的合法性
// 对比玩家名,时间戳,和authKey加密的结果(加密是因为如果登录服不在内网环境下,则可能会被人使用这个功能给发包来直接绕过登录)
if (CommunicationAuth.encryption(playerName, time, Config.BungeeCord.AuthKey).equals(sign)) {
if (sign.equals(CommunicationAuth.encryption(playerName, time, Config.BungeeCord.AuthKey))) {
// 切换主线程给予登录状态
Bukkit.getScheduler().runTask(CatSeedLogin.instance, () -> {
CatScheduler.runTask( () -> {
LoginPlayer lp = Cache.getIgnoreCase(playerName);
if (lp != null) {
LoginPlayerHelper.add(lp);
Expand All @@ -115,9 +115,9 @@ private static void handleKeepLoggedInRequest(String playerName, String time, St

private static void handleConnectRequest(Socket socket, String playerName) {
// 切换主线程获取是否已登录
Bukkit.getScheduler().runTask(CatSeedLogin.instance, () -> {
CatScheduler.runTask( () -> {
boolean result = LoginPlayerHelper.isLogin(playerName);

// 切换异步线程返回结果
CatSeedLogin.instance.runTaskAsync(() -> {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cc/baka9/catseedlogin/bungee/Listeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void onPlayerDisconnect(PlayerDisconnectEvent event) {
public void onPreLogin(PreLoginEvent event) {
String playerName = event.getConnection().getName();
try {
if (loggedInPlayerList.contains(playerName) || Communication.sendConnectRequest(playerName) == 1) {
if (loggedInPlayerList.contains(playerName) && (Communication.sendConnectRequest(playerName) == 1)) {
event.setCancelReason(new TextComponent("您已经登录,请勿重复登录。"));
event.setCancelled(true);
}
Expand Down
Loading