diff --git a/scripts/commands/generic/cmdPVP.groovy b/scripts/commands/generic/cmdPVP.groovy index 2d4366953..36b908de2 100644 --- a/scripts/commands/generic/cmdPVP.groovy +++ b/scripts/commands/generic/cmdPVP.groovy @@ -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() diff --git a/scripts/commands/generic/cmdTip.groovy b/scripts/commands/generic/cmdTip.groovy index be0a4f1f8..4cf5f8911 100644 --- a/scripts/commands/generic/cmdTip.groovy +++ b/scripts/commands/generic/cmdTip.groovy @@ -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]) } \ No newline at end of file diff --git a/scripts/commands/generic/openContainer.groovy b/scripts/commands/generic/openContainer.groovy index 7376bb3cc..8ca3734c7 100644 --- a/scripts/commands/generic/openContainer.groovy +++ b/scripts/commands/generic/openContainer.groovy @@ -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(), "")) } \ No newline at end of file diff --git a/src/utilities/Scripts.java b/src/utilities/Scripts.java index 6fce85e2d..af9f5ab2b 100644 --- a/src/utilities/Scripts.java +++ b/src/utilities/Scripts.java @@ -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 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: - *
  {@code setupScriptVariables("variableNameOne", variableOne, "variableNameTwo", variableTwo);} + * Creates a binding from an array of variables. Bindings are a set of global 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. + *

The name of the variable should lead the instance. An example would be: + *
  {@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