diff --git a/gradle.properties b/gradle.properties index daddfbf..0518cc3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1.20.1-1.3.1a \ No newline at end of file +mod_version=1.20.1-1.3.2 \ No newline at end of file diff --git a/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java b/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java index 156f3ef..27d57e2 100644 --- a/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java +++ b/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java @@ -27,29 +27,27 @@ public void onPlayerJoin(Player player) throws SQLException { ResultSet resultSet = queryResult.getResultSet(); if(resultSet.next()) { String curios_data=resultSet.getString("curios_item"); - if(curios_data.length()>2) { - Map curios = LocalJsonUtil.StringToEntryMap(curios_data); - itemHandler.ifPresent(handler -> { - handler.reset(); - for (int i = 0; i < handler.getSlots(); i++) { - try { - handler.getEquippedCurios().setStackInSlot(i,ItemStack.EMPTY); - if (curios.get(i) != null){ - handler.getEquippedCurios().setStackInSlot(i, ItemStack.of(NbtUtils.snbtToStructure(curios.get(i).replace("|", ",")))); - } + itemHandler.ifPresent(handler ->{ + for (int i = 0; i < handler.getSlots(); i++) { + handler.getEquippedCurios().setStackInSlot(i,ItemStack.EMPTY); + } + }); - } catch (CommandSyntaxException e) { - throw new RuntimeException(e); + Map curios = LocalJsonUtil.StringToEntryMap(curios_data); + itemHandler.ifPresent(handler -> { + handler.reset(); + for (int i = 0; i < handler.getSlots(); i++) { + try { + if (curios.get(i) != null){ + handler.getEquippedCurios().setStackInSlot(i, ItemStack.of(NbtUtils.snbtToStructure(curios.get(i).replace("|", ",")))); } + + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); } - }); - }else { - itemHandler.ifPresent(handler ->{ - for (int i = 0; i < handler.getSlots(); i++) { - handler.getEquippedCurios().setStackInSlot(i,ItemStack.EMPTY); } }); - } + resultSet.close(); queryResult.getConnection().close(); }else{ diff --git a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java index 4bfe200..3709e30 100644 --- a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java +++ b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java @@ -13,6 +13,7 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.server.ServerStoppedEvent; +import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import vip.fubuki.playersync.config.JdbcConfig; @@ -52,7 +53,7 @@ public static void doPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) throws SQ int lastServer = resultSet.getInt("last_server"); queryResult=JDBCsetUp.executeQuery("SELECT * FROM player_data WHERE uuid='"+player_uuid+"'"); resultSet= queryResult.getResultSet(); - if(online) { + if(online && lastServer != JdbcConfig.SERVER_ID.get()) { queryResult=JDBCsetUp.executeQuery("SELECT last_update,enable FROM server_info WHERE id='"+lastServer+"'"); ResultSet getServerInfo = queryResult.getResultSet(); @@ -275,15 +276,17 @@ private static File[] ScanAdvancementsFile(String player_uuid, File gameDir) { return files; } -// @SubscribeEvent -// public void RegisterCommand(RegisterCommandsEvent event){ -// CommandDispatcher dispatcher=event.getDispatcher(); -// LiteralCommandNode cmd = dispatcher.register( -// Commands.literal("serializeNBT").executes(context -> {context.getSource().sendSuccess(Component.literal(context.getSource().getPlayer().getItemInHand(InteractionHand.MAIN_HAND).serializeNBT().toString()),true); -// return 0; -// }) -// ); -// } + static int tick = 0; + + @SubscribeEvent + public static void onUpdate(Event event) throws SQLException { + tick++; + if(tick == 1200) { + tick=0; + long current = System.currentTimeMillis(); + JDBCsetUp.executeUpdate("UPDATE server_info SET last_update ="+current+" WHERE id= "+ JdbcConfig.SERVER_ID.get()); + } + } } diff --git a/src/main/resources/META-INF/assets/playersync/lang/en_us.json b/src/main/resources/META-INF/assets/playersync/lang/en_us.json index a1ca7cd..a320d1a 100644 --- a/src/main/resources/META-INF/assets/playersync/lang/en_us.json +++ b/src/main/resources/META-INF/assets/playersync/lang/en_us.json @@ -1,3 +1,3 @@ { - "playersync.already_online": "You cannot join more than one synchronization server at the same time." + "playersync.already_online": "You can't join more than one synchronization server at the same time." } \ No newline at end of file diff --git a/src/main/resources/META-INF/assets/playersync/lang/zh_cn.json b/src/main/resources/META-INF/assets/playersync/lang/zh_cn.json index 0d21bfe..a19647d 100644 --- a/src/main/resources/META-INF/assets/playersync/lang/zh_cn.json +++ b/src/main/resources/META-INF/assets/playersync/lang/zh_cn.json @@ -1,3 +1,3 @@ { - "playersync.already_online": "你不能同时加入一个以上的同步服务器。" + "playersync.already_online": "你不能同时加入多个同步的服务器。" } \ No newline at end of file