mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
SQL Fixes
:)
This commit is contained in:
parent
2a87271642
commit
b03870c0aa
@ -1,11 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -228,11 +224,12 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||||
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||||
final Statement statement = connection.createStatement();
|
final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
|
||||||
statement.setQueryTimeout(30);
|
statement.setQueryTimeout(30);
|
||||||
|
|
||||||
// Obtain world ID from CoreProtect database
|
// Obtain world ID from CoreProtect database
|
||||||
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
|
statement.setString(1, world.getName());
|
||||||
|
ResultSet resultSet = statement.executeQuery();
|
||||||
String worldID = null;
|
String worldID = null;
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
@ -250,7 +247,10 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
// Iterate through each table and delete their data if the world ID matches
|
// Iterate through each table and delete their data if the world ID matches
|
||||||
for (String table : tables)
|
for (String table : tables)
|
||||||
{
|
{
|
||||||
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
|
final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
|
||||||
|
statement1.setString(1, table);
|
||||||
|
statement1.setString(2, worldID);
|
||||||
|
statement1.executeQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.close();
|
connection.close();
|
||||||
|
@ -139,7 +139,7 @@ public class WorldRestrictions extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.equals("coreprotect") || command.equals("core") || command.equals("co"))
|
if (command.equalsIgnoreCase("coreprotect") || command.equalsIgnoreCase("core") || command.equalsIgnoreCase("co"))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use CoreProtect here.");
|
player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use CoreProtect here.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user