Skip to content

Commit

Permalink
fixed #16
Browse files Browse the repository at this point in the history
  • Loading branch information
mlus-asuka committed May 3, 2024
1 parent 41298da commit 37218c4
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_version=1.20.1-1.3.1a
mod_version=1.20.1-1.3.2
34 changes: 16 additions & 18 deletions src/main/java/vip/fubuki/playersync/sync/ModsSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, String> 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<Integer, String> 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{
Expand Down
23 changes: 13 additions & 10 deletions src/main/java/vip/fubuki/playersync/sync/VanillaSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -275,15 +276,17 @@ private static File[] ScanAdvancementsFile(String player_uuid, File gameDir) {
return files;
}

// @SubscribeEvent
// public void RegisterCommand(RegisterCommandsEvent event){
// CommandDispatcher<CommandSourceStack> dispatcher=event.getDispatcher();
// LiteralCommandNode<CommandSourceStack> 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());
}
}

}

Original file line number Diff line number Diff line change
@@ -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."
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"playersync.already_online": "你不能同时加入一个以上的同步服务器"
"playersync.already_online": "你不能同时加入多个同步的服务器"
}

0 comments on commit 37218c4

Please sign in to comment.