Skip to content

Commit

Permalink
Convert Groovy
Browse files Browse the repository at this point in the history
  • Loading branch information
JaciBrunning committed Mar 22, 2015
1 parent 1562e66 commit cdc3b48
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ apply plugin: 'GradleRIO' //Apply the GradleRIO
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'groovy'
apply plugin: BuildGradle
apply plugin: 'maven'

Expand Down
2 changes: 1 addition & 1 deletion build.settings
Original file line number Diff line number Diff line change
@@ -1 +1 @@
toast.version=0.2.0
toast.version=0.3.0

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package jaci.openrio.toast.core.command.cmd;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import jaci.openrio.toast.core.Toast;
import jaci.openrio.toast.core.command.FuzzyCommand;
import jaci.openrio.toast.core.shared.GlobalBlackboard;

public class CommandGroovyScript extends FuzzyCommand {
@Override
public boolean shouldInvoke(String message) {
return message.startsWith("script");
}

@Override
public void invokeCommand(String message) {
String groovy = message.replaceFirst("script", "");
Binding binding = new Binding();
binding.setVariable("_global", GlobalBlackboard.INSTANCE);
binding.setVariable("_toast", Toast.getToast());
GroovyShell shell = new GroovyShell(binding);
shell.evaluate(groovy);
}

}

0 comments on commit cdc3b48

Please sign in to comment.