Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
public record ScriptFormattingContext(Map<String, ParseableTag> formats, ParseableTag singleFormat) {

// <--[language]
// @name Script Logging Format
// @name Script Formats
// @group Script Container System
// @description
// Script logging contexts provide the format certain commands will use for their texts. Most notably, this includes <@link command debug>.
// Script formats provide the formats certain commands within that script will use for their texts. Most notably, this includes <@link command debug>.
// 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).
// 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.
// 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.
// 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).
// <code>
// my_project_task:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

public class DebugCommand extends AbstractCommand implements Holdable {

public static final String DEBUG_FORMAT = ScriptFormattingContext.registerFormatType("debug");
public static final String ERROR_FORMAT = ScriptFormattingContext.registerFormatType("error");
public static final String DEBUG_FORMAT_TYPE = ScriptFormattingContext.registerFormatType("debug");
public static final String ERROR_FORMAT_TYPE = ScriptFormattingContext.registerFormatType("error");

public DebugCommand() {
setName("debug");
Expand All @@ -39,7 +39,7 @@ public DebugCommand() {
// @Description
// Use to quickly output debug information to console.
//
// Outputs plain text debug to the console by default, supporting the 'debug' format type (see <@link language Script Logging Formats>).
// Outputs plain text debug to the console by default, supporting the 'debug' format type (see <@link language Script Formats>).
//
// Alternatively, specify one of the following debug types:
// DEBUG: standard hideable debug.
Expand All @@ -48,7 +48,7 @@ public DebugCommand() {
// SPACER: a spacer line.
// LOG: global output, non-hideable.
// APPROVAL: "Okay!" output, non-hideable.
// ERROR: "Error!" output, non-hideable. Supports the 'error' format type, see <@link language Script Logging Formats>.
// ERROR: "Error!" output, non-hideable. Supports the 'error' format type, see <@link language Script Formats>.
// REPORT: normally used to describe the arguments of a command, requires a name, hideable.
// EXCEPTION: outputs a full java stacktrace.
// RECORD: Use message 'start' to start recording, 'submit' to submit a recording, or 'cancel' to cancel a recording.
Expand Down Expand Up @@ -118,15 +118,15 @@ else if (scriptContainer != null) {
scriptEntry.setFinished(true);
}
switch (dbType) {
case OUTPUT -> Debug.echoDebug(null, formattingContext == null ? debug : formattingContext.format(DEBUG_FORMAT, debug, scriptEntry));
case OUTPUT -> Debug.echoDebug(null, formattingContext == null ? debug : formattingContext.format(DEBUG_FORMAT_TYPE, debug, scriptEntry));
case DEBUG -> Debug.echoDebug(scriptEntry, debug);
case HEADER -> Debug.echoDebug(scriptEntry, Debug.DebugElement.Header, debug);
case FOOTER -> Debug.echoDebug(scriptEntry, Debug.DebugElement.Footer, debug);
case SPACER -> Debug.echoDebug(scriptEntry, Debug.DebugElement.Spacer, debug);
case LOG -> Debug.log(name, debug);
case APPROVAL -> Debug.echoApproval(debug);
case ERROR -> {
String formatted = formattingContext != null ? formattingContext.formatOrNull(ERROR_FORMAT, debug, scriptEntry) : null;
String formatted = formattingContext != null ? formattingContext.formatOrNull(ERROR_FORMAT_TYPE, debug, scriptEntry) : null;
if (formatted != null) {
Debug.echoDebug(null, formatted);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public ScriptContainer(YamlConfiguration configurationSection, String scriptCont
configurationSection.forceLoweredRootKey("speed");
configurationSection.forceLoweredRootKey("enabled");
this.name = CoreUtilities.toUpperCase(scriptContainerName);
this.formattingContext = ScriptFormattingContext.parseFromConfiguration(this);
}

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

public void postCheck() {
this.formattingContext = ScriptFormattingContext.parseFromConfiguration(this);
}

public ScriptFormattingContext getFormattingContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public ProcedureScriptContainer(YamlConfiguration configurationSection, String s

@Override
public void postCheck() {
super.postCheck();
// Trigger load + cache
if (shouldEnable() && contains("script")) {
getBaseEntries(DenizenCore.implementation.getEmptyScriptEntryData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public TaskScriptContainer(YamlConfiguration configurationSection, String script

@Override
public void postCheck() {
super.postCheck();
// Trigger load + cache
if (shouldEnable() && contains("script")) {
getBaseEntries(DenizenCore.implementation.getEmptyScriptEntryData());
Expand Down