Skip to content

Commit

Permalink
Debug error: grab last scriptEntry if input is null
Browse files Browse the repository at this point in the history
also createworld off-thread errors need entry attachment
  • Loading branch information
mcmonkey4eva committed Aug 28, 2022
1 parent 2aed6b0 commit 98bea06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -174,23 +174,24 @@ else if (!Settings.cache_createWorldWeirdPaths) {
scriptEntry.setFinished(true);
return;
}
if (copy_from != null && !Settings.cache_createWorldSymbols && forbiddenSymbols.containsAnyMatch(copy_from.asString())) {
Debug.echoError("Cannot use copy_from world names with non-alphanumeric symbols due to security settings in Denizen/config.yml.");
scriptEntry.setFinished(true);
return;
}
Supplier<Boolean> copyRunnable = () -> {
try {
if (!Settings.cache_createWorldSymbols && forbiddenSymbols.containsAnyMatch(copy_from.asString())) {
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(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.");
Debug.echoError(scriptEntry, "Cannot copy from that folder path due to security settings in Denizen/config.yml.");
return false;
}
if (!folder.exists() || !folder.isDirectory()) {
Debug.echoError(scriptEntry, "Invalid copy from world folder - does not exist!");
return false;
}
if (newFolder.exists()) {
Debug.echoError("Cannot copy to new world - that folder already exists.");
Debug.echoError(scriptEntry, "Cannot copy to new world - that folder already exists.");
return false;
}
CoreUtilities.copyDirectory(folder, newFolder, excludedExtensionsForCopyFrom);
Expand All @@ -205,7 +206,7 @@ else if (!Settings.cache_createWorldWeirdPaths) {
}
}
catch (Throwable ex) {
Debug.echoError(ex);
Debug.echoError(scriptEntry, ex);
return false;
}
return true;
Expand Down
Expand Up @@ -186,6 +186,9 @@ public static void echoError(ScriptEntry source, String addedContext, String mes
}
errorDuplicatePrevention = true;
ScriptQueue sourceQueue = CommandExecutor.currentQueue;
if (source == null && sourceQueue != null) {
source = sourceQueue.getLastEntryExecuted();
}
if (source != null && source.queue != null) {
sourceQueue = source.queue;
}
Expand Down

0 comments on commit 98bea06

Please sign in to comment.