Skip to content

Commit

Permalink
add 'canRunScripts' variable for script types
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 14, 2020
1 parent 571474f commit 3df3b53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Expand Up @@ -66,7 +66,15 @@ public ScriptContainer(YamlConfiguration configurationSection, String scriptCont
this.name = scriptContainerName.toUpperCase();
}

// The contents of the script container
/**
* Whether this script container type can run script logic.
* If this is false, this is a data-only script container.
*/
public boolean canRunScripts = true;

/**
* The contents of the script container
*/
YamlConfiguration contents;

/**
Expand Down Expand Up @@ -110,7 +118,9 @@ public <T extends ScriptContainer> T getAsContainerType(Class<T> type) {
//
// -->

// The name of the script container
/**
* The name of the script container
*/
private String name;

/**
Expand Down
Expand Up @@ -31,5 +31,6 @@ public class YamlDataScriptContainer extends ScriptContainer {

public YamlDataScriptContainer(YamlConfiguration configurationSection, String scriptContainerName) {
super(configurationSection, scriptContainerName);
canRunScripts = false;
}
}
Expand Up @@ -25,6 +25,10 @@ public class ScriptUtilities {
* @return the new queue.
*/
public static ScriptQueue createAndStartQueue(ScriptContainer container, String path, ScriptEntryData data, ContextSource context, Consumer<ScriptQueue> configure) {
if (!container.canRunScripts) {
Debug.echoError("The script container '" + container.getName() + "' is of type '" + container.getContainerType() + "' which cannot run scripts. Consider using a task script instead.");
return null;
}
if (data == null) {
data = DenizenCore.getImplementation().getEmptyScriptEntryData();
}
Expand Down

0 comments on commit 3df3b53

Please sign in to comment.