From 38c88a95f939a76ed375e74ab48b699830948b17 Mon Sep 17 00:00:00 2001 From: mlus <1319237806@qq.com> Date: Wed, 14 Jan 2026 20:26:26 +0800 Subject: [PATCH] fix #151 fix #160 --- gradle.properties | 2 +- src/main/java/vip/fubuki/playersync/config/JdbcConfig.java | 3 +++ src/main/java/vip/fubuki/playersync/sync/VanillaSync.java | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 07e41cb..80f8314 100644 --- a/gradle.properties +++ b/gradle.properties @@ -30,7 +30,7 @@ mod_name=PlayerSync # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPL-3.0 license # The mod version. See https://semver.org/ -mod_version=2.1.4 +mod_version=2.1.5 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/vip/fubuki/playersync/config/JdbcConfig.java b/src/main/java/vip/fubuki/playersync/config/JdbcConfig.java index fd99bbe..91117fd 100644 --- a/src/main/java/vip/fubuki/playersync/config/JdbcConfig.java +++ b/src/main/java/vip/fubuki/playersync/config/JdbcConfig.java @@ -19,6 +19,7 @@ public class JdbcConfig { public static ModConfigSpec.BooleanValue USE_SSL; public static ModConfigSpec.BooleanValue SYNC_CHAT; public static ModConfigSpec.BooleanValue IS_CHAT_SERVER; + public static ModConfigSpec.BooleanValue KICK_WHEN_ALREADY_ONLINE; public static final ModConfigSpec.ConfigValue ITEM_PLACEHOLDER_TITLE_OVERRIDE; public static final ModConfigSpec.ConfigValue ITEM_PLACEHOLDER_DESCRIPTION_OVERRIDE; public static ModConfigSpec.ConfigValue CHAT_SERVER_IP; @@ -43,6 +44,8 @@ public class JdbcConfig { .define("sync_advancements", true); SYNC_CHAT = COMMON_BUILDER.comment("Whether synchronize chat").define("sync_chat", false); IS_CHAT_SERVER = COMMON_BUILDER.comment("Whether recieve messages from other servers as host").define("IsChatServer",false); + KICK_WHEN_ALREADY_ONLINE = COMMON_BUILDER.comment("Whether to kick player when already online on another server") + .define("kick_when_already_online", true); CHAT_SERVER_IP = COMMON_BUILDER.define("ChatServerIP","127.0.0.1"); CHAT_SERVER_PORT = COMMON_BUILDER.defineInRange("ChatServerPort",7900,0,65535); USE_LEGACY_SERIALIZATION = COMMON_BUILDER.comment( diff --git a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java index 5a26855..09154de 100644 --- a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java +++ b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java @@ -174,7 +174,7 @@ public class VanillaSync { } // Second query: Check if player is already online on another server - if (online && lastServer != JdbcConfig.SERVER_ID.get()) { + if (JdbcConfig.KICK_WHEN_ALREADY_ONLINE.get() && online && lastServer != JdbcConfig.SERVER_ID.get()) { JDBCsetUp.QueryResult qr2 = JDBCsetUp.executeQuery("SELECT last_update,enable FROM server_info WHERE id='" + lastServer + "'"); try (ResultSet rs2 = qr2.resultSet()) { if (rs2.next()) {