Refactored Scripts to use Groovy instead of JavaScript

This commit is contained in:
Waverunner
2017-05-08 20:23:54 -04:00
parent b9e5cfb511
commit c0a80a175c
12 changed files with 184 additions and 118 deletions
+15
View File
@@ -0,0 +1,15 @@
import intents.chat.ChatAvatarRequestIntent
import resources.objects.SWGObject
import resources.player.Player
import services.galaxy.GalacticManager
static def execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
if (args == null)
return
def name = args.split(" ")[0].toLowerCase(Locale.ENGLISH)
if (name == null)
return
new ChatAvatarRequestIntent(player, name, ChatAvatarRequestIntent.RequestType.FRIEND_ADD_TARGET).broadcast()
}
+32
View File
@@ -0,0 +1,32 @@
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])
}
}
def execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
println("Hello World!")
new CmdTip().execute(galacticManager, player, target, args)
}