Skip to content

Commit

Permalink
fix createworld and worldtag.destroy for nonstandard folder paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 29, 2021
1 parent f96ea12 commit 80f65d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Expand Up @@ -26,7 +26,6 @@
import org.bukkit.entity.Player;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class WorldTag implements ObjectTag, Adjustable, FlaggableObject {
Expand Down Expand Up @@ -900,7 +899,7 @@ public void adjust(Mechanism mechanism) {
Debug.echoError("Unable to delete due to config.");
return;
}
File folder = new File(getWorld().getName());
File folder = getWorld().getWorldFolder();
Bukkit.getServer().unloadWorld(getWorld(), false);
try {
CoreUtilities.deleteDirectory(folder);
Expand Down
Expand Up @@ -171,7 +171,7 @@ public void execute(ScriptEntry scriptEntry) {
scriptEntry.setFinished(true);
return;
}
final File newFolder = new File(worldName.asString());
final File newFolder = new File(Bukkit.getWorldContainer(), worldName.asString());
if (!Utilities.canWriteToFile(newFolder)) {
Debug.echoError("Cannot copy to that new folder path due to security settings in Denizen/config.yml.");
scriptEntry.setFinished(true);
Expand All @@ -183,7 +183,7 @@ public void execute(ScriptEntry scriptEntry) {
Debug.echoError("Cannot use copy_from world names with non-alphanumeric symbols due to security settings in Denizen/config.yml.");
return false;
}
File folder = new File(copy_from.asString().replace("w@", ""));
File folder = new File(Bukkit.getWorldContainer(), copy_from.asString().replace("w@", ""));
if (!Utilities.canReadFile(folder)) {
Debug.echoError("Cannot copy from that folder path due to security settings in Denizen/config.yml.");
return false;
Expand All @@ -198,11 +198,11 @@ public void execute(ScriptEntry scriptEntry) {
}
CoreUtilities.copyDirectory(folder, newFolder, excludedExtensionsForCopyFrom);
Debug.echoDebug(scriptEntry, "Copied " + folder.getName() + " to " + newFolder.getName());
File file = new File(worldName.asString() + "/uid.dat");
File file = new File(Bukkit.getWorldContainer(), worldName.asString() + "/uid.dat");
if (file.exists()) {
file.delete();
}
File file2 = new File(worldName.asString() + "/session.lock");
File file2 = new File(Bukkit.getWorldContainer(), worldName.asString() + "/session.lock");
if (file2.exists()) {
file2.delete();
}
Expand Down

0 comments on commit 80f65d3

Please sign in to comment.