Added: giveitem, removeitem, removeitemall to the command list

Minor correction in CommandSet.kt to print the message, not the string array
Removed most/all return@'s inside of each CommandSet
This commit is contained in:
Woah 2021-03-26 03:29:55 -04:00
parent 31cc74b336
commit ccf0e04d3e
12 changed files with 258 additions and 113 deletions

View file

@ -22,7 +22,6 @@ class AnimationCommandSet : CommandSet(Command.Privilege.ADMIN) {
define("anim"){ player, args ->
if (args.size < 2) {
reject(player, "Syntax error: ::anim <Animation ID>")
return@define
}
val animation = Animation(args[1].toInt())
player.animate(animation)
@ -34,12 +33,11 @@ class AnimationCommandSet : CommandSet(Command.Privilege.ADMIN) {
define("loopanim"){ player, args ->
if (args.size < 2) {
reject(player, "Syntax error: ::loopanim <Animation ID> <Loop Amount>")
return@define
}
val start = toInteger(args[1])
var end = toInteger((args[2]))
if (end > 25) {
player.sendMessage("Really...? $end times...? Looping 25 times instead.")
notify(player, "Really...? $end times...? Looping 25 times instead.")
end = 25
}
GameWorld.Pulser.submit(object : Pulse(3, player) {
@ -57,14 +55,12 @@ class AnimationCommandSet : CommandSet(Command.Privilege.ADMIN) {
define("ranim"){ player, args ->
if (args.size < 2) {
reject(player, "Syntax error: ::ranim <Render Animation ID>")
return@define
}
try {
player.appearance.setAnimations(Animation.create(args[1].toInt()))
player.appearance.sync()
} catch (e: NumberFormatException) {
reject(player, "Syntax error: ::ranim <Render Animation ID>")
return@define
}
}

View file

@ -50,16 +50,14 @@ class BottingCommandSet : CommandSet(Command.Privilege.STANDARD) {
}
if(args.size < 2){
reject(player,"Usage: ::script identifier")
return@define
}
val identifier = args[1]
val script = PlayerScripts.identifierMap[identifier]
if(script == null){
reject(player,"Invalid script identifier")
return@define
}
player.interfaceManager.close()
GeneralBotCreator(script.clazz.newInstance() as Script,player,true)
GeneralBotCreator(script!!.clazz.newInstance() as Script,player,true)
player.sendMessage(colorize("%RStarting script..."))
player.sendMessage(colorize("%RTo stop the script, do ::stopscript or log out."))

View file

@ -32,7 +32,7 @@ abstract class CommandSet(val defaultPrivilege: Command.Privilege) : Plugin<Any?
*/
fun reject(player: Player, vararg message: String){
for(msg in message) {
player.sendMessage(colorize("%R$message"))
player.sendMessage(colorize("%R$msg"))
}
throw IllegalStateException()
}

View file

@ -13,13 +13,12 @@ class ConfigCommandSet : CommandSet(Command.Privilege.ADMIN){
define("sconfigrange"){player, args ->
if (args.size < 3) {
reject(player, "usage: sconfigrange idlo idhi")
return@define
}
val idlo = args[1].toIntOrNull() ?: return@define
val idhi = args[2].toIntOrNull() ?: return@define
for (idsend in idlo until idhi) {
val idlo = args[1].toIntOrNull() ?: reject(player, "INCORRECT ID LOW")
val idhi = args[2].toIntOrNull() ?: reject(player, "INCORRECT ID HIGH")
for (idsend in (idlo as Int) until (idhi as Int)) {
player.configManager.set(idsend, Integer.MAX_VALUE)
player.packetDispatch.sendMessage("Config: $idsend value: " + Integer.MAX_VALUE)
notify(player,"Config: $idsend value: " + Integer.MAX_VALUE)
}
}
@ -29,13 +28,12 @@ class ConfigCommandSet : CommandSet(Command.Privilege.ADMIN){
define("sconfigrange0"){player, args ->
if (args.size < 3) {
reject(player, "usage: sconfigrange0 idlo idhi")
return@define
}
val idlo = args[1].toIntOrNull() ?: return@define
val idhi = args[2].toIntOrNull() ?: return@define
for (idsend in idlo until idhi) {
val idlo = args[1].toIntOrNull() ?: reject(player, "INCORRECT ID LOW")
val idhi = args[2].toIntOrNull() ?: reject(player, "INCORRECT ID HIGH")
for (idsend in (idlo as Int) until (idhi as Int)) {
player.configManager.set(idsend, 0)
player.packetDispatch.sendMessage("Config: $idsend value: 0")
notify(player,"Config: $idsend value: 0")
}
}
@ -47,8 +45,8 @@ class ConfigCommandSet : CommandSet(Command.Privilege.ADMIN){
reject(player, "usage: iface id")
return@define
}
val id = args[1].toIntOrNull() ?: return@define
player.interfaceManager.openComponent(id)
val id = args[1].toIntOrNull() ?: reject(player, "INVALID INTERFACE ID")
player.interfaceManager.openComponent(id as Int)
}
}
}

View file

@ -24,7 +24,6 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
define("npcareaanim") { player, args ->
if (args.size < 3) {
reject(player, "Syntax error: ::npcareaanim <Animation ID> <String>")
return@define
}
npcs = RegionManager.getLocalNpcs(player.location, 10)
for (n in npcs) {
@ -49,11 +48,10 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
val pnpc_id = args[1].toIntOrNull()
if(pnpc_id == null){
reject(player, "<npcid> must be a valid integer.")
return@define
}
player.appearance.transformNPC(pnpc_id)
player.sendMessage("Transformed into NPC $pnpc_id")
player.appearance.transformNPC(pnpc_id!!)
notify(player,"Transformed into NPC $pnpc_id")
}
@ -69,7 +67,7 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
*/
define("invis"){ player, _ ->
player.isInvisible = !player.isInvisible
player.sendMessage("You are now ${if (player.isInvisible) "invisible" else "visible"} to others.")
notify(player,"You are now ${if (player.isInvisible) "invisible" else "visible"} to others.")
}
@ -78,7 +76,7 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
*/
define("1hit"){ player, _ ->
player.setAttribute("1hko", !player.getAttribute("1hko", false))
player.sendMessage("1-hit KO mode " + if (player.getAttribute("1hko", false)) "on." else "off.")
notify(player,"1-hit KO mode " + if (player.getAttribute("1hko", false)) "on." else "off.")
}
@ -87,7 +85,7 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
*/
define("god"){ player, _ ->
player.setAttribute("godMode", !player.getAttribute("godMode", false))
player.sendMessage("God mode ${if (player.getAttribute("godMode", false)) "enabled." else "disabled."}")
notify(player,"God mode ${if (player.getAttribute("godMode", false)) "enabled." else "disabled."}")
}
@ -97,7 +95,7 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
define("mrboneswildride"){ player, _ ->
val boneMode = !player.getAttribute("boneMode",false)
player.setAttribute("boneMode", boneMode)
player.sendMessage("Bone Mode ${if (boneMode) "<col=00ff00>ENGAGED</col>." else "<col=ff0000>POWERING DOWN</col>."}")
notify(player,"Bone Mode ${if (boneMode) "<col=00ff00>ENGAGED</col>." else "<col=ff0000>POWERING DOWN</col>."}")
player.appearance.rideCart(boneMode)
if (player.appearance.isRidingMinecart) {
var i = 0
@ -118,6 +116,5 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
define("makeover", Command.Privilege.MODERATOR){ player, _ ->
CharacterDesign.open(player)
}
}
}

View file

@ -65,14 +65,14 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
* Tells the player to use loc
*/
define("pos", Command.Privilege.STANDARD){ player, _->
player.packetDispatch.sendMessage("Do you mean ::loc?")
notify(player, "Do you mean ::loc?")
}
/**
* Tells the player to use loc
*/
define("coords", Command.Privilege.STANDARD){ player, _->
player.packetDispatch.sendMessage("Do you mean ::loc?")
notify(player, "Do you mean ::loc?")
}
/**
@ -98,8 +98,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
define("players", Command.Privilege.STANDARD){ player, _ ->
val rights = player.rights.ordinal
if (player!!.interfaceManager.isOpened && player.interfaceManager.opened.id != Components.QUESTJOURNAL_SCROLL_275 || player.locks.isMovementLocked || player.locks.isTeleportLocked) {
player.sendMessage("Please finish what you're doing first.")
return@define
reject(player, "Please finish what you're doing first.")
}
player.interfaceManager.open(Component(Components.QUESTJOURNAL_SCROLL_275))
var i = 0
@ -202,8 +201,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
*/
define("reply", Command.Privilege.STANDARD){ player, _ ->
if(player.interfaceManager.isOpened){
player.sendMessage("<col=e74c3c>Please finish what you're doing first.")
return@define
reject(player, "<col=e74c3c>Please finish what you're doing first.")
}
if (player.attributes.containsKey("replyTo")) {
player.setAttribute("keepDialogueAlive", true)
@ -217,7 +215,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
})
player.dialogueInterpreter.sendMessageInput(StringUtils.formatDisplayName(replyTo))
} else {
player.packetDispatch.sendMessage("<col=3498db>You have not recieved any recent messages to which you can reply.")
reject(player, "<col=3498db>You have not recieved any recent messages to which you can reply.")
}
}
@ -255,17 +253,16 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
* Set a specific skill to a specific level
*/
define("setlevel"){player,args ->
if(args.size < 2) reject(player,"Usage: ::setlevel skillname level").also { return@define }
if(args.size < 2) reject(player,"Usage: ::setlevel skillname level")
val skillname = args[1]
val desiredLevel: Int? = args[2].toIntOrNull()
if(desiredLevel == null){
reject(player, "Level must be an integer.")
return@define
}
if(desiredLevel > 99) reject(player,"Level must be 99 or lower.").also { return@define }
if(desiredLevel!! > 99) reject(player,"Level must be 99 or lower.")
val skill = Skills.getSkillByName(skillname)
if(skill < 0) reject(player, "Must use a valid skill name!").also { return@define }
if(skill < 0) reject(player, "Must use a valid skill name!")
player.skills.setStaticLevel(skill,desiredLevel)
player.skills.setLevel(skill,desiredLevel)
@ -333,7 +330,6 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
define("setconfig"){player,args ->
if(args.size < 3){
reject(player,"Syntax: ::setconfig configID value")
return@define
}
val configID = args[1].toString().toInt()
val configValue = args[2].toString().toInt()
@ -343,37 +339,35 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
define("getobjectvarp"){player,args ->
if(args.size < 2){
reject(player,"Syntax: ::getobjectvarp objectid")
return@define
}
val objectID = args[1].toInt()
player.sendMessage("${VarbitDefinition.forObjectID(ObjectDefinition.forId(objectID).varbitID).configId}")
notify(player, "${VarbitDefinition.forObjectID(ObjectDefinition.forId(objectID).varbitID).configId}")
}
define("togglexp",Command.Privilege.STANDARD){ player, args ->
val enabled = player.varpManager.get(2501).getVarbit(0)?.value == 1
player.varpManager.get(2501).setVarbit(0,if(enabled) 0 else 1).send(player)
player.sendMessage("XP drops are now " + colorize("%R" + if(!enabled) "ON." else "OFF."))
notify(player, "XP drops are now " + colorize("%R" + if(!enabled) "ON." else "OFF."))
player.varpManager.flagSave(2501)
}
define("xpconfig",Command.Privilege.STANDARD){player,args ->
if(args.size < 3){
reject(player,"Usage: ::xpconfig track|mode type")
reject(player,"Track types: total|recent")
reject(player, "Mode types: instant|increment")
reject(player,"Defaults: track - total, mode - increment")
return@define
reject(player,"Usage: ::xpconfig track|mode type",
"Track types: total|recent",
"Mode types: instant|increment",
"Defaults: track - total, mode - increment")
}
when(args[1]){
"track" -> when(args[2]){
"total" -> {
player.varpManager.get(2501).setVarbit(2,0).send(player)
player.sendMessage("You are now tracking " + colorize("%RTOTAL") + " experience.")
notify(player,"You are now tracking " + colorize("%RTOTAL") + " experience.")
}
"recent" -> {
player.varpManager.get(2501).setVarbit(2,1).send(player)
player.sendMessage("You are now tracking the " + colorize("%RMOST RECENT") + " skill's experience.")
notify(player,"You are now tracking the " + colorize("%RMOST RECENT") + " skill's experience.")
}
else -> {
reject(player,"Usage: ::xpconfig track|mode type")
@ -387,11 +381,11 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
when(args[2]){
"instant" -> {
player.varpManager.get(2501).setVarbit(1,1).send(player)
player.sendMessage("Your xp tracker now updates " + colorize("%RINSTANTLY") + ".")
notify(player,"Your xp tracker now updates " + colorize("%RINSTANTLY") + ".")
}
"increment" -> {
player.varpManager.get(2501).setVarbit(1,0).send(player)
player.sendMessage("Your xp tracker now updates " + colorize("%RINCREMENTALLY") + ".")
notify(player,"Your xp tracker now updates " + colorize("%RINCREMENTALLY") + ".")
}
else -> {
reject(player,"Usage: ::xpconfig track|mode type")
@ -419,14 +413,13 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
} else {
player.varpManager.get(2502).save = false
}
player.sendMessage("Slayer task tracker is now " + (if(disabled) colorize("%RON") else colorize("%ROFF")) + ".")
notify(player,"Slayer task tracker is now " + (if(disabled) colorize("%RON") else colorize("%ROFF")) + ".")
}
define("setvarbit",Command.Privilege.ADMIN){
player,args ->
if(args.size < 4){
reject(player,"Usage: ::setvarbit index offset value")
return@define
}
val index = args[1].toIntOrNull()
val offset = args[2].toIntOrNull()
@ -434,10 +427,9 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
if(index == null || offset == null || value == null){
reject(player,"Usage ::setvarbit index offset value")
return@define
}
player.varpManager.get(index).setVarbit(offset,value).send(player)
player.varpManager.get(index!!).setVarbit(offset!!, value!!).send(player)
}
define("grow",Command.Privilege.ADMIN){player,_ ->

View file

@ -1,5 +1,6 @@
package rs09.game.system.command.sets
import core.game.node.entity.player.Player
import rs09.game.system.command.Command
import core.game.system.task.Pulse
import rs09.game.world.GameWorld
@ -18,6 +19,24 @@ class ModerationCommandSet : CommandSet(Command.Privilege.MODERATOR){
val MAX_JAIL_TIME = 1800 //Max jail time (in seconds)
/**
* Kick a player
* =============================================================================================================
*/
define("kick", Command.Privilege.ADMIN){ player, args ->
val playerToKick: Player? = Repository.getPlayerByName(args[1])
if (playerToKick != null) {
playerToKick.clear(true)
notify(player, "Player ${playerToKick.username} was kicked.")
} else {
reject(player, "ERROR REMOVING PLAYER.")
}
}
/**
* =============================================================================================================
*/
/**
* Jail a player
* =============================================================================================================
@ -25,25 +44,22 @@ class ModerationCommandSet : CommandSet(Command.Privilege.MODERATOR){
define("jail"){player,args ->
if(args.size < 3) {
reject(player,"Usage: ::jail <seconds> <player>")
return@define
}
val timeSeconds = args[1].toIntOrNull()
if(timeSeconds == null){
reject(player, "<seconds> Must be a valid integer!")
return@define
}
if(timeSeconds > MAX_JAIL_TIME){
if(timeSeconds!! > MAX_JAIL_TIME){
reject(player, "Maximum jail time is $MAX_JAIL_TIME seconds.")
return@define
}
val name = args.slice(2 until args.size).joinToString("_")
val otherPlayer = Repository.getPlayerByName(name)
if(otherPlayer == null){
reject(player, "Can not find $name in the player list!")
return@define
}
player.sendMessage("Jailing ${otherPlayer.username} for $timeSeconds seconds.")
notify(player, "Jailing ${otherPlayer!!.username} for $timeSeconds seconds.")
notify(otherPlayer, "${player.username} has jailed you for $timeSeconds seconds.")
GameWorld.Pulser.submit(object : Pulse(3){
val originalLoc = otherPlayer.location
val releaseTime = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeSeconds.toLong())
@ -62,7 +78,5 @@ class ModerationCommandSet : CommandSet(Command.Privilege.MODERATOR){
/**
* =============================================================================================================
*/
}
}

View file

@ -14,15 +14,13 @@ class MusicCommandSet : CommandSet(Command.Privilege.STANDARD){
define("playsong"){player,args ->
if(args.size < 2){
reject(player,"Usage: ::playsong songID")
return@define
}
val id = args[1].toIntOrNull()
if(id == null){
reject(player,"Please use a valid integer for the song id.")
return@define
}
player.musicPlayer.play(MusicEntry.forId(id))
player.sendMessage("Now playing song $id")
player.musicPlayer.play(MusicEntry.forId(id!!))
notify(player,"Now playing song $id")
}
/**

View file

@ -31,12 +31,11 @@ class QuestCommandSet : CommandSet(Command.Privilege.ADMIN){
define("setqueststage"){player,args ->
if (args.size < 2) {
reject(player,"You must specify the index# of a quest, and a stage number")
return@define
}
val quest = args[1].toIntOrNull() ?: return@define
val stage = args[2].toIntOrNull() ?: return@define
player.questRepository.setStage(player.questRepository.forIndex(quest), stage)
player.sendMessage("<col=209dff>Setting " + player.questRepository.forIndex(quest).name + " to stage $stage</col>")
val quest = args[1].toIntOrNull() ?: reject(player,"INVALID QUEST")
val stage = args[2].toIntOrNull() ?: reject(player,"INVALID STAGE")
player.questRepository.setStage(player.questRepository.forIndex(quest as Int), stage as Int)
notify(player, "<col=209dff>Setting " + player.questRepository.forIndex(quest).name + " to stage $stage</col>")
}
/**

View file

@ -11,7 +11,7 @@ class SlayerCommandSet : CommandSet(Command.Privilege.ADMIN){
* Finishes a player's slayer task (the correct way)
*/
define("finishtask"){player,_ ->
player.debug("Kill the npc that spawned to finish your task.")
notify(player, "Kill the npc that spawned to finish your task.")
player.slayer.amount = 1
val finisher = NPC(player.slayer.task.npcs[0], player.location)
finisher.isRespawn = false
@ -24,17 +24,15 @@ class SlayerCommandSet : CommandSet(Command.Privilege.ADMIN){
define("setslayerpoints"){player,args ->
if(args.size < 2){
reject(player,"Usage: ::setslayerpoints amount")
return@define
}
val amount = args[1].toIntOrNull()
if(amount == null){
reject(player,"Amount needs to be a valid integer!")
return@define
}
player.slayer.slayerPoints = amount
player.sendMessage("Set slayer points to $amount.")
player.slayer.slayerPoints = amount!!
notify(player, "Set slayer points to $amount.")
}
}
}

View file

@ -1,5 +1,8 @@
package rs09.game.system.command.sets
import core.cache.Cache
import core.cache.def.Definition
import core.cache.def.impl.ItemDefinition
import core.game.node.entity.player.info.login.Response
import core.game.node.entity.player.info.portal.PlayerSQLManager
import core.game.node.item.Item
@ -8,14 +11,16 @@ import core.game.system.SystemState
import core.plugin.Initializable
import org.rs09.consts.Items
import rs09.game.system.command.Command
import rs09.game.world.repository.Repository
import rs09.tools.getAmount
@Initializable
class SystemCommandSet : CommandSet(Command.Privilege.ADMIN){
class SystemCommandSet : CommandSet(Command.Privilege.ADMIN) {
override fun defineCommands() {
/**
* Start an update countdown
*/
define("update"){player,args ->
define("update") { player, args ->
if (args.size > 1) {
SystemManager.getUpdater().setCountdown(args[1].toInt())
}
@ -25,7 +30,7 @@ class SystemCommandSet : CommandSet(Command.Privilege.ADMIN){
/**
* Cancel an update countdown
*/
define("cancelupdate"){player,_ ->
define("cancelupdate") { player, _ ->
SystemManager.getUpdater().cancel()
}
@ -33,42 +38,199 @@ class SystemCommandSet : CommandSet(Command.Privilege.ADMIN){
/**
* Allows a player to reset their password
*/
define("resetpassword", Command.Privilege.STANDARD){ player, args ->
if(args.size != 3){
reject(player,"Usage: ::resetpassword current new")
reject(player,"WARNING: THIS IS PERMANENT.")
reject(player,"WARNING: PASSWORD CAN NOT CONTAIN SPACES.")
return@define
define("resetpassword", Command.Privilege.STANDARD) { player, args ->
if (args.size != 3) {
reject(player, "Usage: ::resetpassword current new", "WARNING: THIS IS PERMANENT.", "WARNING: PASSWORD CAN NOT CONTAIN SPACES.")
}
val oldPass = args[1]
var newPass = args[2]
if(PlayerSQLManager.getCredentialResponse(player.details.username,oldPass) != Response.SUCCESSFUL){
reject(player,"INVALID PASSWORD!")
return@define
if (PlayerSQLManager.getCredentialResponse(player.details.username, oldPass) != Response.SUCCESSFUL) {
reject(player, "INVALID PASSWORD!")
}
if(newPass.length < 5 || newPass.length > 20){
reject(player,"NEW PASSWORD MUST BE BETWEEN 5 AND 20 CHARACTERS")
return@define
if (newPass.length < 5 || newPass.length > 20) {
reject(player, "NEW PASSWORD MUST BE BETWEEN 5 AND 20 CHARACTERS")
}
if(newPass == player.username){
reject(player,"PASSWORD CAN NOT BE SAME AS USERNAME.")
return@define
if (newPass == player.username) {
reject(player, "PASSWORD CAN NOT BE SAME AS USERNAME.")
}
if(newPass == oldPass){
reject(player,"PASSWORDS CAN NOT BE THE SAME")
return@define
if (newPass == oldPass) {
reject(player, "PASSWORDS CAN NOT BE THE SAME")
}
newPass = SystemManager.getEncryption().hashPassword(newPass)
PlayerSQLManager.updatePassword(player.username.toLowerCase().replace(" ","_"),newPass)
reject(player,"Password updated successfully.")
PlayerSQLManager.updatePassword(player.username.toLowerCase().replace(" ", "_"), newPass)
notify(player, "Password updated successfully.")
}
define("potato"){player,_ ->
/**
* Allows an Administrator to reset a password
*/
define("setpasswordother", Command.Privilege.ADMIN) { player, args ->
if (args.size != 3) {
reject(player, "Usage: ::resetpasswordother user new", "WARNING: THIS IS PERMANENT.", "WARNING: PASSWORD CAN NOT CONTAIN SPACES.")
}
val otherUser = args[1]
var newPass = args[2]
if (PlayerSQLManager.hasSqlAccount(otherUser, "username")) {
if (newPass.length < 5 || newPass.length > 20) {
reject(player, "NEW PASSWORD MUST BE BETWEEN 5 AND 20 CHARACTERS")
}
if (newPass == otherUser) {
reject(player, "PASSWORD CAN NOT BE SAME AS USERNAME.")
}
newPass = SystemManager.getEncryption().hashPassword(newPass)
PlayerSQLManager.updatePassword(otherUser.toLowerCase().replace(" ","_"),newPass)
notify(player, "Password updated successfully.")
} else {
reject(player, "USER DOES NOT EXIST!")
}
}
define("giveitem", Command.Privilege.ADMIN) { player, args ->
if (args.size == 3 || args.size == 4) {
val victim = Repository.getPlayerByName(args[1])
val itemID = args[2].toIntOrNull()
val amount = args.getOrNull(3)?.toIntOrNull() ?: 1
if (victim == null) {
reject(player, "INVALID TARGET USERNAME.")
}
if (itemID == null || itemID <= 0 || itemID > ItemDefinition.getDefinitions().size) {
reject(player, "INVALID ITEM ID ENTERED.")
}
if (amount > Int.MAX_VALUE || amount <= 0) {
reject(player, "INVALID ITEM ID ENTERED.")
}
val item = Item(itemID!!, amount)
val invFull = victim!!.inventory.isFull
val syntax = if (amount > 1) "items" else "item"
if (invFull) {
victim.bank.add(item)
} else {
victim.inventory.add(item)
}
notify(player, "Successfully gave ${victim.username} $amount ${item.name}. ${if (invFull) "The $syntax were sent to their bank." else ""}")
notify(victim, "You received $amount ${item.name} from ${player.username}. ${if (invFull) "The $syntax were placed in your bank." else ""}")
} else {
reject(player, "WRONG USAGE. USE giveitem target itemID || giveitem target itemID amt")
}
}
define("removeitem", Command.Privilege.ADMIN) { player, args ->
if (args.size == 4 || args.size == 5) {
val itemLoc = args[1].toLowerCase()
val victim = Repository.getPlayerByName(args[2])
val itemID = args[3].toIntOrNull()
var amount = args.getOrNull(4)?.toIntOrNull() ?: 1
if (victim == null) {
reject(player, "INVALID TARGET USERNAME.")
}
if (itemID == null || itemID <= 0 || itemID > ItemDefinition.getDefinitions().size) {
reject(player, "INVALID ITEM ID ENTERED.")
}
if (amount > Int.MAX_VALUE || amount <= 0) {
reject(player, "INVALID ITEM AMOUNT ENTERED.")
}
val item = Item(itemID!!, amount)
var totalItemAmount = 0
when (itemLoc) {
"i", "inv", "inventory" -> {
totalItemAmount = victim!!.inventory.getItem(item).amount
victim.inventory.remove(item)
}
"b", "bk", "bank" -> {
totalItemAmount = victim!!.bank.getItem(item).amount
victim.bank.remove(item)
}
"e", "equip", "equipment" -> {
totalItemAmount = victim!!.equipment.getItem(item).amount
victim.equipment.remove(item)
}
else -> reject(player, "INVALID ITEM LOCATION ENTERED. USE: ", "i, inv, inventory | b, bk, bank | e, equip, equipment")
}
if (amount > totalItemAmount) {
amount = totalItemAmount
}
notify(player, "Successfully removed $amount ${item.name} from ${victim!!.username}.")
notify(victim, "${player.username} removed $amount ${item.name} from your inventory.")
} else {
reject(player, "WRONG USAGE. USE removeitem itemLoc target itemID || removeitem itemLoc target itemID amt",
"ItemLoc: inv = inventory | equip = equipment | bank |")
}
}
define("removeitemall", Command.Privilege.ADMIN) { player, args ->
if (args.size == 3) {
val victim = Repository.getPlayerByName(args[1])
val itemID = args[2].toIntOrNull()
if (victim == null) {
reject(player, "INVALID TARGET USERNAME.")
}
if (itemID == null || itemID <= 0 || itemID > ItemDefinition.getDefinitions().size) {
reject(player, "INVALID ITEM ID ENTERED.")
}
/* Handles removing the non noted version */
val itemInv = Item(itemID!!)
/* Handles removing the noted version */
val itemNote = Item(itemInv.noteChange)
val untotal = victim!!.inventory.getAmount(itemID) + victim.bank.getAmount(itemID) +
victim.equipment.getAmount(itemID)
val nototal = victim.inventory.getAmount(itemNote) + victim.bank.getAmount(itemNote) +
victim.equipment.getAmount(itemNote)
val eqtotal = victim.equipment.getAmount(itemID) + victim.equipment.getAmount(itemNote)
val total = untotal + nototal + eqtotal
if (total == 0) {
reject(player, "USER HAS NONE OF THOSE ITEMS.")
}
victim.inventory.remove(Item(itemID, victim.inventory.getAmount(itemID)))
victim.bank.remove(Item(itemID, victim.bank.getAmount(itemID)))
victim.equipment.remove(Item(itemID, victim.equipment.getAmount(itemID)))
victim.inventory.remove(Item(itemInv.noteChange, victim.inventory.getAmount(itemNote)))
victim.bank.remove(Item(itemInv.noteChange, victim.bank.getAmount(itemNote)))
victim.equipment.remove(Item(itemInv.noteChange, victim.equipment.getAmount(itemNote)))
notify(player, "Successfully removed $total ${itemInv.name} from ${victim.username}.")
notify(victim, "${player.username} removed $total ${itemInv.name} from your account.")
} else {
reject(player, "WRONG USAGE. USE removeitemall target itemID")
}
}
define("potato") { player, _ ->
player.inventory.add(Item(Items.ROTTEN_POTATO_5733))
}

View file

@ -47,7 +47,6 @@ class TeleportCommandSet : CommandSet(Command.Privilege.ADMIN){
}
if (args.size < 2) {
reject(player,"syntax error: x, y, (optional) z")
return@define
}
player.properties.teleportLocation = Location.create(args[1].toInt(), args[2].toInt(), if (args.size > 3) args[3].toInt() else 0)
}
@ -59,17 +58,14 @@ class TeleportCommandSet : CommandSet(Command.Privilege.ADMIN){
define("teleto"){player,args ->
if (args.size < 1) {
reject(player,"syntax error: name")
return@define
}
val n = args.slice(1 until args.size).joinToString("_")
val target = Repository.getPlayerByName(n)
if (target == null) {
reject(player,"syntax error: name")
return@define
}
if (target.getAttribute<Any?>("fc_wave") != null) {
if (target!!.getAttribute<Any?>("fc_wave") != null) {
reject(player,"You cannot teleport to a player who is in the Fight Caves.")
return@define
}
player.properties.teleportLocation = target.location
}
@ -81,17 +77,14 @@ class TeleportCommandSet : CommandSet(Command.Privilege.ADMIN){
define("teletome"){player,args ->
if (args.size < 1) {
reject(player,"syntax error: name")
return@define
}
val n = args.slice(1 until args.size).joinToString("_")
val target = Repository.getPlayerByName(n)
if (target == null) {
reject(player,"syntax error: name")
return@define
}
if (target.getAttribute<Any?>("fc_wave") != null) {
if (target!!.getAttribute<Any?>("fc_wave") != null) {
reject(player,"You cannot teleport to a player who is in the Fight Caves.")
return@define
}
target.properties.teleportLocation = player.location
}