-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Catching errors in /scriptit command * Added script builder to scripts library
- Loading branch information
Showing
3 changed files
with
69 additions
and
10 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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/ddoerr/scriptit/libraries/types/ScriptBuilderModel.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,43 @@ | ||
package com.ddoerr.scriptit.libraries.types; | ||
|
||
import com.ddoerr.scriptit.api.annotations.Callable; | ||
import com.ddoerr.scriptit.api.libraries.AnnotationBasedModel; | ||
import com.ddoerr.scriptit.api.scripts.LifeCycle; | ||
import com.ddoerr.scriptit.api.scripts.ScriptBuilder; | ||
|
||
public class ScriptBuilderModel extends AnnotationBasedModel { | ||
private ScriptBuilder scriptBuilder = new ScriptBuilder(); | ||
|
||
public ScriptBuilderModel() { | ||
scriptBuilder.lifeCycle(LifeCycle.Threaded); | ||
} | ||
|
||
@Callable | ||
public ScriptBuilderModel language(String language) { | ||
scriptBuilder.language(language); | ||
return this; | ||
} | ||
|
||
@Callable | ||
public ScriptBuilderModel script(String content) { | ||
scriptBuilder.fromString(content); | ||
return this; | ||
} | ||
|
||
@Callable | ||
public ScriptBuilderModel file(String path) { | ||
scriptBuilder.fromFile(path); | ||
return this; | ||
} | ||
|
||
@Callable | ||
public ScriptBuilderModel instant() { | ||
scriptBuilder.lifeCycle(LifeCycle.Instant); | ||
return this; | ||
} | ||
|
||
@Callable | ||
public String run() { | ||
return scriptBuilder.run(); | ||
} | ||
} |