Skip to content

Commit cdc3b48

Browse files
committed
Convert Groovy
1 parent 1562e66 commit cdc3b48

4 files changed

Lines changed: 27 additions & 24 deletions

File tree

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ apply plugin: 'GradleRIO' //Apply the GradleRIO
2020
apply plugin: 'java'
2121
apply plugin: 'idea'
2222
apply plugin: 'eclipse'
23+
apply plugin: 'groovy'
2324
apply plugin: BuildGradle
2425
apply plugin: 'maven'
2526

build.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
toast.version=0.2.0
1+
toast.version=0.3.0

src/main/java/jaci/openrio/toast/core/command/cmd/CommandGroovyScript.groovy

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package jaci.openrio.toast.core.command.cmd;
2+
3+
import groovy.lang.Binding;
4+
import groovy.lang.GroovyShell;
5+
import jaci.openrio.toast.core.Toast;
6+
import jaci.openrio.toast.core.command.FuzzyCommand;
7+
import jaci.openrio.toast.core.shared.GlobalBlackboard;
8+
9+
public class CommandGroovyScript extends FuzzyCommand {
10+
@Override
11+
public boolean shouldInvoke(String message) {
12+
return message.startsWith("script");
13+
}
14+
15+
@Override
16+
public void invokeCommand(String message) {
17+
String groovy = message.replaceFirst("script", "");
18+
Binding binding = new Binding();
19+
binding.setVariable("_global", GlobalBlackboard.INSTANCE);
20+
binding.setVariable("_toast", Toast.getToast());
21+
GroovyShell shell = new GroovyShell(binding);
22+
shell.evaluate(groovy);
23+
}
24+
25+
}

0 commit comments

Comments
 (0)