Skip to content

Commit df39140

Browse files
authored
Script formats improvements & fixes (#117)
* Script formats improvements & fixes * Naming
1 parent af01b8c commit df39140

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

src/main/java/com/denizenscript/denizencore/scripts/ScriptFormattingContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
public record ScriptFormattingContext(Map<String, ParseableTag> formats, ParseableTag singleFormat) {
1919

2020
// <--[language]
21-
// @name Script Logging Format
21+
// @name Script Formats
2222
// @group Script Container System
2323
// @description
24-
// Script logging contexts provide the format certain commands will use for their texts. Most notably, this includes <@link command debug>.
24+
// Script formats provide the formats certain commands within that script will use for their texts. Most notably, this includes <@link command debug>.
2525
// See specific command's documentation for information on which formats they use (for example, the 'debug' command supports a 'debug' format and an 'error' format).
26-
// The formats are specified under a 'formats' key, and can be either a <@link language Format Script Containers> or a direct format with the same syntax as format scripts.
26+
// The formats are specified under a 'formats' key, and can be either <@link language Format Script Containers> or a direct format with the same syntax as format scripts.
2727
// When specifying a direct format, use the format name as the key; When specifying a format script, use '<format>_script' as the key (see example below).
2828
// <code>
2929
// my_project_task:

src/main/java/com/denizenscript/denizencore/scripts/commands/core/DebugCommand.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
public class DebugCommand extends AbstractCommand implements Holdable {
1717

18-
public static final String DEBUG_FORMAT = ScriptFormattingContext.registerFormatType("debug");
19-
public static final String ERROR_FORMAT = ScriptFormattingContext.registerFormatType("error");
18+
public static final String DEBUG_FORMAT_TYPE = ScriptFormattingContext.registerFormatType("debug");
19+
public static final String ERROR_FORMAT_TYPE = ScriptFormattingContext.registerFormatType("error");
2020

2121
public DebugCommand() {
2222
setName("debug");
@@ -39,7 +39,7 @@ public DebugCommand() {
3939
// @Description
4040
// Use to quickly output debug information to console.
4141
//
42-
// Outputs plain text debug to the console by default, supporting the 'debug' format type (see <@link language Script Logging Formats>).
42+
// Outputs plain text debug to the console by default, supporting the 'debug' format type (see <@link language Script Formats>).
4343
//
4444
// Alternatively, specify one of the following debug types:
4545
// DEBUG: standard hideable debug.
@@ -48,7 +48,7 @@ public DebugCommand() {
4848
// SPACER: a spacer line.
4949
// LOG: global output, non-hideable.
5050
// APPROVAL: "Okay!" output, non-hideable.
51-
// ERROR: "Error!" output, non-hideable. Supports the 'error' format type, see <@link language Script Logging Formats>.
51+
// ERROR: "Error!" output, non-hideable. Supports the 'error' format type, see <@link language Script Formats>.
5252
// REPORT: normally used to describe the arguments of a command, requires a name, hideable.
5353
// EXCEPTION: outputs a full java stacktrace.
5454
// RECORD: Use message 'start' to start recording, 'submit' to submit a recording, or 'cancel' to cancel a recording.
@@ -118,15 +118,15 @@ else if (scriptContainer != null) {
118118
scriptEntry.setFinished(true);
119119
}
120120
switch (dbType) {
121-
case OUTPUT -> Debug.echoDebug(null, formattingContext == null ? debug : formattingContext.format(DEBUG_FORMAT, debug, scriptEntry));
121+
case OUTPUT -> Debug.echoDebug(null, formattingContext == null ? debug : formattingContext.format(DEBUG_FORMAT_TYPE, debug, scriptEntry));
122122
case DEBUG -> Debug.echoDebug(scriptEntry, debug);
123123
case HEADER -> Debug.echoDebug(scriptEntry, Debug.DebugElement.Header, debug);
124124
case FOOTER -> Debug.echoDebug(scriptEntry, Debug.DebugElement.Footer, debug);
125125
case SPACER -> Debug.echoDebug(scriptEntry, Debug.DebugElement.Spacer, debug);
126126
case LOG -> Debug.log(name, debug);
127127
case APPROVAL -> Debug.echoApproval(debug);
128128
case ERROR -> {
129-
String formatted = formattingContext != null ? formattingContext.formatOrNull(ERROR_FORMAT, debug, scriptEntry) : null;
129+
String formatted = formattingContext != null ? formattingContext.formatOrNull(ERROR_FORMAT_TYPE, debug, scriptEntry) : null;
130130
if (formatted != null) {
131131
Debug.echoDebug(null, formatted);
132132
}

src/main/java/com/denizenscript/denizencore/scripts/containers/ScriptContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public ScriptContainer(YamlConfiguration configurationSection, String scriptCont
7575
configurationSection.forceLoweredRootKey("speed");
7676
configurationSection.forceLoweredRootKey("enabled");
7777
this.name = CoreUtilities.toUpperCase(scriptContainerName);
78-
this.formattingContext = ScriptFormattingContext.parseFromConfiguration(this);
7978
}
8079

8180
public <T extends ObjectTag> T tagObject(String text, Class<T> type) {
@@ -107,6 +106,7 @@ public boolean shouldEnable() {
107106
}
108107

109108
public void postCheck() {
109+
this.formattingContext = ScriptFormattingContext.parseFromConfiguration(this);
110110
}
111111

112112
public ScriptFormattingContext getFormattingContext() {

src/main/java/com/denizenscript/denizencore/scripts/containers/core/ProcedureScriptContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public ProcedureScriptContainer(YamlConfiguration configurationSection, String s
5858

5959
@Override
6060
public void postCheck() {
61+
super.postCheck();
6162
// Trigger load + cache
6263
if (shouldEnable() && contains("script")) {
6364
getBaseEntries(DenizenCore.implementation.getEmptyScriptEntryData());

src/main/java/com/denizenscript/denizencore/scripts/containers/core/TaskScriptContainer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public TaskScriptContainer(YamlConfiguration configurationSection, String script
4747

4848
@Override
4949
public void postCheck() {
50+
super.postCheck();
5051
// Trigger load + cache
5152
if (shouldEnable() && contains("script")) {
5253
getBaseEntries(DenizenCore.implementation.getEmptyScriptEntryData());

0 commit comments

Comments
 (0)