1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 15:11:20 +01:00

Lets delete the columns from explore database when the world is not exist

This commit is contained in:
montlikadani 2020-04-27 19:33:51 +02:00
parent e7f7c7deb0
commit 74a97f5d34
2 changed files with 11 additions and 4 deletions

View File

@ -96,9 +96,7 @@ public class ExploreManager {
String names = res.getString(ExploreDataTableFields.playerNames.getCollumn()); String names = res.getString(ExploreDataTableFields.playerNames.getCollumn());
int id = res.getInt("id"); int id = res.getInt("id");
JobsWorld jobsWorld = null; JobsWorld jobsWorld = Util.getJobsWorld(worldName);
if (worldName != null)
jobsWorld = Util.getJobsWorld(worldName);
if (jobsWorld == null) if (jobsWorld == null)
jobsWorld = Util.getJobsWorld(worldId); jobsWorld = Util.getJobsWorld(worldId);

View File

@ -2463,8 +2463,17 @@ public abstract class JobsDAO {
prest = conn.prepareStatement("SELECT * FROM `" + DBTables.ExploreDataTable.getTableName() + "`;"); prest = conn.prepareStatement("SELECT * FROM `" + DBTables.ExploreDataTable.getTableName() + "`;");
res = prest.executeQuery(); res = prest.executeQuery();
while (res.next()) { while (res.next()) {
String worldName = res.getString(ExploreDataTableFields.worldname.getCollumn());
if (worldName == null || Bukkit.getWorld(worldName) == null) {
PreparedStatement prest2 = null;
prest2 = conn.prepareStatement("DELETE FROM `" + DBTables.ExploreDataTable.getTableName() + "` WHERE `" + ExploreDataTableFields.worldname.getCollumn() + "` = ?;");
prest2.setString(1, worldName);
prest2.execute();
close(prest2);
} else {
Jobs.getExplore().load(res); Jobs.getExplore().load(res);
} }
}
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {