Fixed openContainer script to use Groovy instead of JavaScript

Removed class declaration in cmdTip script
This commit is contained in:
Waverunner
2017-05-11 02:04:08 -04:00
parent 2ca0caa3f0
commit 26907fc7eb
4 changed files with 33 additions and 34 deletions
+2 -4
View File
@@ -14,11 +14,9 @@ static def execute(GalacticManager galacticManager, Player player, SWGObject tar
if (args.length > 0) {
if (args.indexOf("imperial") > -1) {
intent = new FactionIntent(creature, PvpFaction.IMPERIAL)
}
else if (args.indexOf("rebel") > -1) {
} else if (args.indexOf("rebel") > -1) {
intent = new FactionIntent(creature, PvpFaction.REBEL)
}
else {
} else {
intent = new FactionIntent(creature, PvpFaction.NEUTRAL)
}
intent.broadcast()
+16 -23
View File
@@ -1,31 +1,24 @@
import resources.commands.ICmdCallback
import resources.objects.SWGObject
import resources.player.AccessLevel
import resources.player.Player
import services.galaxy.GalacticManager
import utilities.IntentFactory
class CmdTip implements ICmdCallback {
void execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
if (player.getAccessLevel() == AccessLevel.PLAYER) {
IntentFactory.sendSystemMessage(player, "Unable to access /tip command - currently reserved for admins")
return
}
def argSplit = args.split(" ")
if (argSplit.length < 2) {
IntentFactory.sendSystemMessage(player, "Invalid Arguments: " + args)
return
}
def creature = player.getCreatureObject()
if (argSplit[0] == "bank")
creature.setBankBalance(creature.getBankBalance() + Long.valueOf(argSplit[1]))
else if (argSplit[0] == "cash")
creature.setCashBalance(creature.getCashBalance() + Long.valueOf(argSplit[1]))
else
IntentFactory.sendSystemMessage(player, "Unknown Destination: " + argSplit[0])
}
}
static def execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
new CmdTip().execute(galacticManager, player, target, args)
if (player.getAccessLevel() == AccessLevel.PLAYER) {
IntentFactory.sendSystemMessage(player, "Unable to access /tip command - currently reserved for admins")
return
}
def argSplit = args.split(" ")
if (argSplit.length < 2) {
IntentFactory.sendSystemMessage(player, "Invalid Arguments: " + args)
return
}
def creature = player.getCreatureObject()
if (argSplit[0] == "bank")
creature.setBankBalance(creature.getBankBalance() + Long.valueOf(argSplit[1]))
else if (argSplit[0] == "cash")
creature.setCashBalance(creature.getCashBalance() + Long.valueOf(argSplit[1]))
else
IntentFactory.sendSystemMessage(player, "Unknown Destination: " + argSplit[0])
}
@@ -1,4 +1,8 @@
function executeCommand(galacticManager, player, target, args) {
var ClientOpenContainerMessage = Java.type("network.packets.swg.zone.ClientOpenContainerMessage");
player.sendPacket(new ClientOpenContainerMessage(target.getObjectId(), ""));
import network.packets.swg.zone.ClientOpenContainerMessage
import resources.objects.SWGObject
import resources.player.Player
import services.galaxy.GalacticManager
static def execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
player.sendPacket(new ClientOpenContainerMessage(target.getObjectId(), ""))
}
+8 -4
View File
@@ -57,7 +57,8 @@ public class Scripts {
* @param args to pass to the method.
* @return expected return type of the script. If the method doesn't have a return statement, this method returns {@code null}.
* If an exception occurs, {@code null} is returned.
* @throws java.io.FileNotFoundException if the script file wasn't found
* @throws ResourceException if script file does not exist
* @throws ScriptException if there is a problem executing the script and/or method within the script
*/
@SuppressWarnings("unchecked")
public static <T> T invoke(String scriptName, String method, Object... args) throws ResourceException, ScriptException {
@@ -66,8 +67,10 @@ public class Scripts {
}
/**
* Creates a binding from an array of variables. The name of the variable should lead the instance. An example would be:
* <br>&nbsp&nbsp{@code setupScriptVariables("variableNameOne", variableOne, "variableNameTwo", variableTwo);}
* Creates a binding from an array of variables. Bindings are a set of <i>global</i> variables that can be used by the script. As such,
* you should use a new set of bindings for each invocation of the script on different threads.
* <br><br>The name of the variable should lead the instance. An example would be:
* <br>&nbsp&nbsp{@code Binding bindings = createBindings("variableNameOne", variableOne, "variableNameTwo", variableTwo);}
* @param variables an array of variables. Variable names should lead the instance of the variable.
*/
public static Binding createBindings(Object... variables) {
@@ -94,7 +97,8 @@ public class Scripts {
}
/**
* Creates the Groovy Script and returns it. The method uses the {@link GroovyScriptEngine}'s createScript method.
* Creates the Groovy Script and returns it, with the global variables specified within the binding.
* The method uses the {@link GroovyScriptEngine}'s createScript method.
* @param scriptName name of the script to load
* @param binding the binding instance to use
* @return an instance of the obtained Groovy Script