add sync condition

This commit is contained in:
mlus-Asuka 2022-12-12 11:25:49 +08:00
parent 7dc5f0151b
commit 7b8d55f575
3 changed files with 6 additions and 5 deletions

View File

@ -3,3 +3,5 @@ This is a Minecraft forge mod using Mysql backend to make player data synchroniz
Such as equipment,inventory,effects,experience,food level.Any other mods support is also possible. Such as equipment,inventory,effects,experience,food level.Any other mods support is also possible.
Support version now: Support version now:
1.19 1.19
Current support Mod:
curios

View File

@ -97,6 +97,7 @@ public class VanillaSync {
//Mod support //Mod support
ModsSupport modsSupport = new ModsSupport(); ModsSupport modsSupport = new ModsSupport();
modsSupport.onPlayerJoin(serverPlayer); modsSupport.onPlayerJoin(serverPlayer);
serverPlayer.addTag("player_synced");
} }
resultSet.close(); resultSet.close();
} }
@ -110,10 +111,12 @@ public class VanillaSync {
public void OnPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { public void OnPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
String player_uuid = event.getEntity().getUUID().toString(); String player_uuid = event.getEntity().getUUID().toString();
JDBCsetUp.executeUpdate("UPDATE player_data SET online=false WHERE uuid='"+player_uuid+"'"); JDBCsetUp.executeUpdate("UPDATE player_data SET online=false WHERE uuid='"+player_uuid+"'");
if(!event.getEntity().getTags().contains("player_synced")) return;
Store(event.getEntity(),false,Dist.CLIENT.isDedicatedServer()); Store(event.getEntity(),false,Dist.CLIENT.isDedicatedServer());
//Mod support //Mod support
ModsSupport modsSupport = new ModsSupport(); ModsSupport modsSupport = new ModsSupport();
modsSupport.onPlayerLeave(event.getEntity()); modsSupport.onPlayerLeave(event.getEntity());
event.getEntity().removeTag("player_synced");
} }
public void Store(Player player, boolean init,boolean isServer) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { public void Store(Player player, boolean init,boolean isServer) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {

View File

@ -64,7 +64,3 @@ make multiserver players' data sync
versionRange="[1.19.2,1.20)" versionRange="[1.19.2,1.20)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.playersync]]
modId="mysql_jdbc"
mandatory=true
versionRange="[8.0.27,)"