Skip to content

Commit

Permalink
Fix unloaded checker, check for level.dat existence to validate that …
Browse files Browse the repository at this point in the history
…it is a world folder.
  • Loading branch information
creatorfromhell committed Dec 3, 2023
1 parent 04e511f commit 1e8e6f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/main/java/me/lokka30/phantomworlds/PhantomWorlds.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@

import me.lokka30.microlib.files.YamlConfigFile;
import me.lokka30.microlib.maths.QuickTimer;
import me.lokka30.microlib.messaging.MultiMessage;
import me.lokka30.microlib.other.UpdateChecker;
import me.lokka30.phantomworlds.commands.phantomworlds.PWCommand;
import me.lokka30.phantomworlds.commands.phantomworlds.PhantomWorldsCommand;
import me.lokka30.phantomworlds.commands.phantomworlds.parameters.resolvers.WorldFolderResolver;
import me.lokka30.phantomworlds.commands.phantomworlds.parameters.suggestion.WorldFolderSuggestion;
import me.lokka30.phantomworlds.commands.phantomworlds.utils.WorldFolder;
import me.lokka30.phantomworlds.listeners.player.PlayerChangeWorldListener;
import me.lokka30.phantomworlds.listeners.player.PlayerDeathListener;
import me.lokka30.phantomworlds.listeners.player.PlayerJoinListener;
import me.lokka30.phantomworlds.listeners.player.PlayerPortalListener;
import me.lokka30.phantomworlds.listeners.world.WorldInitListener;
import me.lokka30.phantomworlds.managers.FileManager;
import me.lokka30.phantomworlds.managers.WorldManager;
import me.lokka30.phantomworlds.misc.CompatibilityChecker;
import me.lokka30.phantomworlds.misc.UpdateCheckerResult;
import me.lokka30.phantomworlds.misc.Utils;
import me.lokka30.phantomworlds.scheduler.BackupScheduler;
import org.bstats.bukkit.Metrics;
import org.bukkit.ChatColor;
Expand All @@ -27,7 +23,6 @@
import revxrsal.commands.bukkit.BukkitCommandHandler;

import java.io.File;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

Expand All @@ -40,7 +35,7 @@
public class PhantomWorlds extends JavaPlugin {

/*
TODO:
*TODO:
* - Translate backslash character in world names as a space so world names with a space can be used in the plugin
* - Vanish compatibility
* - don't send 'by' messages unless the sender is not a player / target can see the (player) sender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public static void onCommand(final BukkitCommandActor actor) {

for(File file : directory.listFiles()) {
if(file.isDirectory() && !loaded.contains(file.getName())) {
unloaded.add(file.getName());
final File levelDat = new File(file, "level.dat");
if(levelDat.exists()) {
unloaded.add(file.getName());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public WorldLoadResponse loadWorld(final String worldName) {
}

final File worldFolder = new File(Bukkit.getWorldContainer(), worldName);
if(!worldFolder.exists()) {
final File levelDat = new File(worldFolder, "level.dat");
if(!worldFolder.exists() || !levelDat.exists()) {

// The world was deleted/moved by the user so it must be re-imported. PW should no longer attempt to load that world.
PhantomWorlds.logger().info("Discarding world '" + worldName + "' from PhantomWorlds' "
Expand Down

0 comments on commit 1e8e6f4

Please sign in to comment.