Fix SQL cooldown table generation (#177)

This commit is contained in:
TechnicallyCoded 2023-10-07 06:03:04 +02:00 committed by GitHub
parent c3602ee5e1
commit 9042fbf6d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -25,12 +25,25 @@ public class DatabaseCooldowns extends SQLite {
@Override
public List<String> getTables() {
List<String> list = new ArrayList<>();
if (BetterRTP.getInstance().getCooldowns().isEnabled())
// Ignore loaded world names if cooldowns are disabled
if (!BetterRTP.getInstance().getCooldowns().isEnabled())
return list;
for (World world : Bukkit.getWorlds()) {
if (!BetterRTP.getInstance().getRTP().getDisabledWorlds().contains(world.getName()))
list.add(world.getName());
// Get list of disabled worlds and ensure list isn't null
List<String> disabledWorlds = BetterRTP.getInstance().getRTP().getDisabledWorlds();
if (disabledWorlds == null) disabledWorlds = new ArrayList<>();
// If there are disabled worlds, iterate through the loaded worlds on the server and
// add the world name to the list of table names if they aren't marked as disabled
List<World> worlds = Bukkit.getWorlds();
if (!disabledWorlds.isEmpty()) {
for (World world : worlds) {
if (!disabledWorlds.contains(world.getName()))
list.add(world.getName());
}
}
return list;
}

View File

@ -57,10 +57,13 @@ public abstract class SQLite {
public void load() {
loaded = false;
tables = getTables();
if (tables.isEmpty()) { //Dont do anything is no colums to generate
// Don't do anything is no columns to generate
if (tables.isEmpty()) {
loaded = true;
return;
}
AsyncHandler.async(() -> {
Connection connection = getSQLConnection();
try {