Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9564f71
commit 998ba0e
Showing
7 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/denizenscript/denizencore/events/core/ScriptsLoadedScriptEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.denizenscript.denizencore.events.core; | ||
|
||
import com.denizenscript.denizencore.events.ScriptEvent; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
|
||
public class ScriptsLoadedScriptEvent extends ScriptEvent { | ||
|
||
// <--[event] | ||
// @Events | ||
// scripts loaded | ||
// | ||
// @Switch had_error:true/false to only process the event if there either was or was not an error message. | ||
// | ||
// @Group Core | ||
// | ||
// @Triggers when Denizen scripts are loaded, but on reloaded and on initial load. | ||
// | ||
// @Context | ||
// <context.had_error> returns an ElementTag(Boolean) whether there was an error. | ||
// | ||
// --> | ||
|
||
public static ScriptsLoadedScriptEvent instance; | ||
|
||
public ScriptsLoadedScriptEvent() { | ||
instance = this; | ||
registerCouldMatcher("scripts loaded"); | ||
registerSwitches("had_error"); | ||
} | ||
|
||
public boolean hadError = false; | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
switch (name) { | ||
case "had_error": | ||
return new ElementTag(hadError); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if (!path.checkSwitch("had_error", hadError ? "true" : "false")) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "ScriptsLoaded"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters