remove unused table
This commit is contained in:
parent
5666f79c88
commit
b9f4736f2c
|
|
@ -59,8 +59,6 @@ public class PlayerSync
|
|||
`last_server` int DEFAULT NULL,
|
||||
PRIMARY KEY (`uuid`)
|
||||
);""");
|
||||
JDBCsetUp.executeUpdate("CREATE TABLE IF NOT EXISTS chat (player CHAR(36) NOT NULL,message TEXT," +
|
||||
"timestamp BIGINT)");
|
||||
JDBCsetUp.executeUpdate("""
|
||||
CREATE TABLE IF NOT EXISTS server_info (
|
||||
`id` INT NOT NULL,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class ModsSupport {
|
|||
*/
|
||||
LazyOptional<IItemHandlerModifiable> itemHandler = top.theillusivec4.curios.api.CuriosApi.getCuriosHelper().getEquippedCurios(player);
|
||||
JDBCsetUp.QueryResult queryResult=JDBCsetUp.executeQuery("SELECT curios_item FROM curios WHERE uuid = '"+player.getUUID()+"'");
|
||||
ResultSet resultSet = queryResult.getResultSet();
|
||||
ResultSet resultSet = queryResult.resultSet();
|
||||
if(resultSet.next()) {
|
||||
String curios_data=resultSet.getString("curios_item");
|
||||
if(curios_data.length()>2) {
|
||||
|
|
@ -42,7 +42,7 @@ public class ModsSupport {
|
|||
});
|
||||
}
|
||||
resultSet.close();
|
||||
queryResult.getConnection().close();
|
||||
queryResult.connection().close();
|
||||
}else{
|
||||
StoreCurios(player,true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class VanillaSync {
|
|||
public static void doPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) throws SQLException, CommandSyntaxException, IOException {
|
||||
String player_uuid = event.getEntity().getUUID().toString();
|
||||
JDBCsetUp.QueryResult queryResult=JDBCsetUp.executeQuery("SELECT online, last_server FROM player_data WHERE uuid='"+player_uuid+"'");
|
||||
ResultSet resultSet=queryResult.getResultSet();
|
||||
ResultSet resultSet=queryResult.resultSet();
|
||||
ServerPlayer serverPlayer = (ServerPlayer) event.getEntity();
|
||||
if(!resultSet.next()){
|
||||
Store(event.getPlayer(),true,Dist.CLIENT.isDedicatedServer());
|
||||
|
|
@ -51,11 +51,11 @@ public class VanillaSync {
|
|||
boolean online = resultSet.getBoolean("online");
|
||||
int lastServer = resultSet.getInt("last_server");
|
||||
queryResult=JDBCsetUp.executeQuery("SELECT * FROM player_data WHERE uuid='"+player_uuid+"'");
|
||||
resultSet= queryResult.getResultSet();
|
||||
resultSet= queryResult.resultSet();
|
||||
if(online) {
|
||||
|
||||
queryResult=JDBCsetUp.executeQuery("SELECT last_update,enable FROM server_info WHERE id='"+lastServer+"'");
|
||||
ResultSet getServerInfo = queryResult.getResultSet();
|
||||
ResultSet getServerInfo = queryResult.resultSet();
|
||||
if(getServerInfo.next()){
|
||||
long last_update = getServerInfo.getLong("last_update");
|
||||
boolean enable = getServerInfo.getBoolean("enable");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package vip.fubuki.playersync.util;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
import vip.fubuki.playersync.config.JdbcConfig;
|
||||
|
||||
import java.sql.*;
|
||||
|
|
@ -13,7 +17,7 @@ public class JDBCsetUp {
|
|||
}
|
||||
|
||||
public static QueryResult executeQuery(String sql) throws SQLException{
|
||||
Connection connection = getConnection();
|
||||
Connection connection = getConnection();
|
||||
PreparedStatement useStatement = connection.prepareStatement("USE ?");
|
||||
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get());
|
||||
useStatement.executeUpdate();
|
||||
|
|
@ -23,7 +27,7 @@ public class JDBCsetUp {
|
|||
return new QueryResult(connection,resultSet);
|
||||
}
|
||||
|
||||
public static int executeUpdate(String sql) throws SQLException{
|
||||
public static void executeUpdate(String sql) throws SQLException{
|
||||
try (Connection connection = getConnection()) {
|
||||
|
||||
PreparedStatement useStatement = connection.prepareStatement("USE ?");
|
||||
|
|
@ -31,35 +35,34 @@ public class JDBCsetUp {
|
|||
useStatement.executeUpdate();
|
||||
|
||||
try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
|
||||
return updateStatement.executeUpdate();
|
||||
updateStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int executeUpdate(String sql,int i) throws SQLException{
|
||||
public static void Update(String sql, String... argument) throws SQLException{
|
||||
Connection connection = getConnection();
|
||||
|
||||
PreparedStatement useStatement = connection.prepareStatement("USE ?");
|
||||
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get());
|
||||
useStatement.executeUpdate();
|
||||
|
||||
PreparedStatement updateStatement = connection.prepareStatement(sql);
|
||||
for (int i = 1; i <= argument.length; i++) {
|
||||
updateStatement.setString(i,argument[i]);
|
||||
}
|
||||
updateStatement.executeUpdate();
|
||||
}
|
||||
|
||||
public static void executeUpdate(String sql, int i) throws SQLException{
|
||||
try (Connection connection = getConnection()) {
|
||||
|
||||
try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
|
||||
return updateStatement.executeUpdate();
|
||||
updateStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class QueryResult{
|
||||
private final Connection connection;
|
||||
private final ResultSet resultSet;
|
||||
|
||||
public QueryResult(Connection connection, ResultSet resultSet) {
|
||||
this.connection = connection;
|
||||
this.resultSet = resultSet;
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public ResultSet getResultSet() {
|
||||
return resultSet;
|
||||
}
|
||||
public record QueryResult(Connection connection, ResultSet resultSet) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user