diff --git a/README.md b/README.md index b21c659..5054305 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ This is a Minecraft forge mod using Mysql backend to make player data synchronization between different servers. Such as equipment,inventory,effects,experience,food level.Any other mods support is also possible. Support version now: +1.20.1 1.19-1.19.3 1.18.2 1.16.5 diff --git a/build.gradle b/build.gradle index ec8a33b..97d565e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'net.minecraftforge.gradle' version '5.1.+' } -version = '1.2.0' +version = mod_version group = 'vip.fubuki.playersync' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'playersync' diff --git a/gradle.properties b/gradle.properties index 878bf1f..14b8211 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,6 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false \ No newline at end of file +org.gradle.daemon=false + +mod_version=1.19.2-1.2.1 \ No newline at end of file diff --git a/src/main/java/vip/fubuki/playersync/PlayerSync.java b/src/main/java/vip/fubuki/playersync/PlayerSync.java index 5fc7769..669fa7a 100644 --- a/src/main/java/vip/fubuki/playersync/PlayerSync.java +++ b/src/main/java/vip/fubuki/playersync/PlayerSync.java @@ -41,7 +41,7 @@ public class PlayerSync @SubscribeEvent public void onServerStarting(ServerStartingEvent event) throws SQLException { - JDBCsetUp.executeUpdate("CREATE DATABASE IF NOT EXISTS "+JdbcConfig.DATABASE_NAME.get()); + JDBCsetUp.executeUpdate("CREATE DATABASE IF NOT EXISTS "+JdbcConfig.DATABASE_NAME.get(),1); JDBCsetUp.executeUpdate("CREATE TABLE IF NOT EXISTS player_data (uuid CHAR(36) NOT NULL," + "inventory MEDIUMBLOB,armor BLOB,advancements BLOB,enderchest MEDIUMBLOB,effects BLOB," + diff --git a/src/main/java/vip/fubuki/playersync/util/JDBCsetUp.java b/src/main/java/vip/fubuki/playersync/util/JDBCsetUp.java index 6ffa8b6..4626e7b 100644 --- a/src/main/java/vip/fubuki/playersync/util/JDBCsetUp.java +++ b/src/main/java/vip/fubuki/playersync/util/JDBCsetUp.java @@ -24,13 +24,16 @@ public class JDBCsetUp { } public static int executeUpdate(String sql) throws SQLException{ + return executeUpdate(sql,0); + } + + public static int executeUpdate(String sql,int init) throws SQLException{ try (Connection connection = getConnection()) { - try (PreparedStatement useStatement = connection.prepareStatement("USE " + JdbcConfig.DATABASE_NAME.get())) { - useStatement.executeUpdate(); + if(init==0){ + sql="USE " + JdbcConfig.DATABASE_NAME.get() +";" + sql; } - try (PreparedStatement updateStatement = connection.prepareStatement(sql)) { return updateStatement.executeUpdate(); } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 47935a6..8ca3942 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -16,10 +16,7 @@ license="GPL-3.0 license" [[mods]] #mandatory # The modid of the mod modId="playersync" #mandatory -# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata -# see the associated build.gradle script for how to populate this completely automatically during a build -version="1.2.0" #mandatory +version="${file.jarVersion}" #mandatory # A display name for the mod displayName="PlayerSync" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/