Skip to content

Commit

Permalink
give a more useful error when accessing WTDefinitions too early
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari023 committed May 27, 2024
1 parent aac5385 commit a7dfc36
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/de/mari_023/ae2wtlib/wut/AddTerminalEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public static synchronized void run() {
HANDLERS = null;
}

public static synchronized boolean hasRun() {
return HANDLERS == null;
}

/**
* Creates a builder to register a new terminal.
*
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/de/mari_023/ae2wtlib/wut/WTDefinitions.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ public class WTDefinitions {
private WTDefinitions() {
}

static {
if (!AddTerminalEvent.hasRun())
throw new IllegalStateException("Calling WTDefinitions before terminal registration happened");
}

public static WTDefinition CRAFTING = WTDefinition.of("crafting");
public static WTDefinition PATTERN_ENCODING = WTDefinition.of("pattern_encoding");
public static WTDefinition PATTERN_ACCESS = WTDefinition.of("pattern_access");
Expand Down

0 comments on commit a7dfc36

Please sign in to comment.