API overhaul, convert Toy Plugins to Listeners
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package rs09.game.system.command.oldsys
|
||||
|
||||
import api.ContentAPI
|
||||
import api.*
|
||||
import core.cache.Cache
|
||||
import core.game.container.access.InterfaceContainer
|
||||
import core.game.content.quest.tutorials.tutorialisland.CharacterDesign
|
||||
@@ -195,8 +195,8 @@ class VisualCommand : CommandPlugin() {
|
||||
return true
|
||||
}
|
||||
player!!.packetDispatch.sendSceneryAnimation(`object`, Animation(toInteger(args[args.size - 1]!!)))
|
||||
//ContentAPI.sendMessage(player, `object`.definition.modelIds.map { it.toString() }.toString())
|
||||
ContentAPI.sendMessage(player, `object`.definition.animationId.toString())
|
||||
//sendMessage(player, `object`.definition.modelIds.map { it.toString() }.toString())
|
||||
sendMessage(player, `object`.definition.animationId.toString())
|
||||
return true
|
||||
}
|
||||
"inter", "component", "interface" -> {
|
||||
@@ -227,7 +227,7 @@ class VisualCommand : CommandPlugin() {
|
||||
val value = (args!![1]!!.toString().toInt()) ?: 0
|
||||
val cfg_index = (args.getOrNull(2)?.toString()?.toInt() ?: -1)
|
||||
if(cfg_index == -1){
|
||||
ContentAPI.submitWorldPulse(object : Pulse(3, player){
|
||||
submitWorldPulse(object : Pulse(3, player){
|
||||
var pos = 32
|
||||
var shift = 0
|
||||
override fun pulse(): Boolean {
|
||||
@@ -243,7 +243,7 @@ class VisualCommand : CommandPlugin() {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
ContentAPI.submitWorldPulse(object : Pulse(3, player) {
|
||||
submitWorldPulse(object : Pulse(3, player) {
|
||||
var pos = 0
|
||||
override fun pulse(): Boolean {
|
||||
player?.configManager?.forceSet(cfg_index, value shl pos, false)
|
||||
@@ -276,10 +276,10 @@ class VisualCommand : CommandPlugin() {
|
||||
}
|
||||
"loop_anim_on_i" -> {
|
||||
var anim = toInteger(args!![1]!!)
|
||||
ContentAPI.submitWorldPulse(object : Pulse(3){
|
||||
submitWorldPulse(object : Pulse(3){
|
||||
override fun pulse(): Boolean {
|
||||
player!!.packetDispatch.sendAnimationInterface(anim++, 224, 7)
|
||||
ContentAPI.sendMessage(player, "${anim - 1}")
|
||||
sendMessage(player, "${anim - 1}")
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
package rs09.game.system.command.rottenpotato
|
||||
|
||||
import api.ContentAPI
|
||||
import api.*
|
||||
import api.InputType
|
||||
import core.game.content.dialogue.DialoguePlugin
|
||||
import core.game.node.entity.npc.NPC
|
||||
@@ -39,7 +39,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player)
|
||||
//Send Player Notification
|
||||
1 -> {
|
||||
end()
|
||||
ContentAPI.sendInputDialogue(player, InputType.STRING_LONG, "Enter the notification message:"){ value ->
|
||||
sendInputDialogue(player, InputType.STRING_LONG, "Enter the notification message:"){ value ->
|
||||
val message = value as String
|
||||
for (p in Repository.players) {
|
||||
p ?: continue
|
||||
@@ -62,7 +62,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player)
|
||||
//Force Area NPC Chat
|
||||
4 -> {
|
||||
end()
|
||||
ContentAPI.sendInputDialogue(player, InputType.STRING_LONG,"Enter the chat message:"){ value ->
|
||||
sendInputDialogue(player, InputType.STRING_LONG,"Enter the chat message:"){ value ->
|
||||
val msg = value as String
|
||||
RegionManager.getLocalNpcs(player).forEach {
|
||||
it.sendChat(msg)
|
||||
@@ -82,7 +82,7 @@ class RottenPotatoExtraDialogue(player: Player? = null) : DialoguePlugin(player)
|
||||
//AME Spawning
|
||||
100 -> {
|
||||
end()
|
||||
ContentAPI.sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value ->
|
||||
sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value ->
|
||||
val other = Repository.getPlayerByName(value.toString().toLowerCase().replace(" ", "_"))
|
||||
if (other == null) {
|
||||
player.sendMessage(colorize("%RInvalid player name."))
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package rs09.game.system.command.rottenpotato
|
||||
|
||||
import api.ContentAPI
|
||||
import api.*
|
||||
import api.InputType
|
||||
import core.game.content.dialogue.DialoguePlugin
|
||||
import core.game.node.entity.player.Player
|
||||
@@ -54,7 +54,7 @@ class RottenPotatoRSHDDialogue(player: Player? = null) : DialoguePlugin(player)
|
||||
//View Bank
|
||||
4 -> {
|
||||
end()
|
||||
ContentAPI.sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value ->
|
||||
sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value ->
|
||||
val other = Repository.getPlayerByName(value.toString().toLowerCase().replace(" ","_"))
|
||||
if(other == null){
|
||||
player.sendMessage(colorize("%RInvalid player name."))
|
||||
@@ -67,7 +67,7 @@ class RottenPotatoRSHDDialogue(player: Player? = null) : DialoguePlugin(player)
|
||||
//View Inventory
|
||||
5 -> {
|
||||
end()
|
||||
ContentAPI.sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value ->
|
||||
sendInputDialogue(player, InputType.STRING_SHORT, "Enter player name:"){ value ->
|
||||
val other = Repository.getPlayerByName(value.toString().toLowerCase().replace(" ","_"))
|
||||
if(other == null){
|
||||
player.sendMessage(colorize("%RInvalid player name."))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package rs09.game.system.command.sets
|
||||
|
||||
import api.ContentAPI
|
||||
import api.*
|
||||
import core.game.content.quest.tutorials.tutorialisland.CharacterDesign
|
||||
import core.game.node.entity.npc.NPC
|
||||
import core.game.node.entity.player.Player
|
||||
@@ -152,10 +152,10 @@ class FunCommandSet : CommandSet(Command.Privilege.ADMIN) {
|
||||
val inv = player.inventory.toArray().filterNotNull()
|
||||
SpadeDigListener.registerListener(player.location){p ->
|
||||
for(item in inv){
|
||||
ContentAPI.addItemOrDrop(p, item.id, item.amount)
|
||||
ContentAPI.sendMessage(p, "You dig and find ${if(item.amount > 1) "some" else "a"} ${item.name}")
|
||||
addItemOrDrop(p, item.id, item.amount)
|
||||
sendMessage(p, "You dig and find ${if(item.amount > 1) "some" else "a"} ${item.name}")
|
||||
}
|
||||
ContentAPI.sendNews("${player.username} has found the hidden treasure! Congratulations!!!")
|
||||
sendNews("${player.username} has found the hidden treasure! Congratulations!!!")
|
||||
SpadeDigListener.listeners.remove(loc)
|
||||
}
|
||||
player.inventory.clear()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package rs09.game.system.command.sets
|
||||
|
||||
import api.ContentAPI
|
||||
import api.*
|
||||
import api.InputType
|
||||
import core.cache.def.impl.ItemDefinition
|
||||
import core.cache.def.impl.NPCDefinition
|
||||
@@ -164,7 +164,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
||||
when(mode){
|
||||
"buying" -> showGeBuy(player)
|
||||
"selling" -> showGeSell(player)
|
||||
"search" -> ContentAPI.sendInputDialogue(player, InputType.STRING_LONG, "Enter search term:"){value ->
|
||||
"search" -> sendInputDialogue(player, InputType.STRING_LONG, "Enter search term:"){value ->
|
||||
showOffers(player, value as String)
|
||||
}
|
||||
else -> reject(player, "Invalid mode used. Available modes are: buying, selling, search")
|
||||
@@ -199,7 +199,7 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
||||
if (player.attributes.containsKey("replyTo")) {
|
||||
player.setAttribute("keepDialogueAlive", true)
|
||||
val replyTo = player.getAttribute("replyTo", "").replace("_".toRegex(), " ")
|
||||
ContentAPI.sendInputDialogue(player, InputType.MESSAGE ,StringUtils.formatDisplayName(replyTo)){ value ->
|
||||
sendInputDialogue(player, InputType.MESSAGE ,StringUtils.formatDisplayName(replyTo)){ value ->
|
||||
CommunicationInfo.sendMessage(player, replyTo.toLowerCase(), value as String)
|
||||
player.removeAttribute("keepDialogueAlive")
|
||||
}
|
||||
@@ -551,11 +551,11 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
||||
for(i in 0..299) {
|
||||
val offer = offerList.elementAtOrNull(i)
|
||||
if (offer != null)
|
||||
ContentAPI.setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
else
|
||||
ContentAPI.setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
}
|
||||
ContentAPI.openInterface(player, Components.QUESTJOURNAL_SCROLL_275)
|
||||
openInterface(player, Components.QUESTJOURNAL_SCROLL_275)
|
||||
}
|
||||
|
||||
fun showGeBuy(player: Player){
|
||||
@@ -571,35 +571,35 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
||||
offers[offerIDs.key] = totalOffered
|
||||
}
|
||||
}
|
||||
val offerList = offers.keys.map { "${ContentAPI.itemDefinition(it).name} - ${offers[it]}" }.sorted()
|
||||
val offerList = offers.keys.map { "${itemDefinition(it).name} - ${offers[it]}" }.sorted()
|
||||
|
||||
var lineId = 11
|
||||
setScrollTitle(player, "Active Buy Offers")
|
||||
for(i in 0..299) {
|
||||
val offer = offerList.elementAtOrNull(i)
|
||||
if (offer != null)
|
||||
ContentAPI.setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
setInterfaceText(player, offer, Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
else
|
||||
ContentAPI.setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
setInterfaceText(player, "", Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
}
|
||||
ContentAPI.openInterface(player, Components.QUESTJOURNAL_SCROLL_275)
|
||||
openInterface(player, Components.QUESTJOURNAL_SCROLL_275)
|
||||
}
|
||||
|
||||
fun showOffers(player: Player, searchTerm: String){
|
||||
val fakeOffers = ArrayList<FakeOffer>()
|
||||
|
||||
OfferManager.OFFERS_BY_ITEMID.forEach { (id, offers) ->
|
||||
if(searchTerm.toLowerCase().contains(ContentAPI.itemDefinition(id).name.toLowerCase()) || ContentAPI.itemDefinition(id).name.toLowerCase().contains(searchTerm.toLowerCase())){
|
||||
if(searchTerm.toLowerCase().contains(itemDefinition(id).name.toLowerCase()) || itemDefinition(id).name.toLowerCase().contains(searchTerm.toLowerCase())){
|
||||
offers.forEach {
|
||||
fakeOffers.add(FakeOffer(it.sell, ContentAPI.itemDefinition(id).name, it.amount))
|
||||
fakeOffers.add(FakeOffer(it.sell, itemDefinition(id).name, it.amount))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OfferManager.BOT_OFFERS.forEach{ (id, amount) ->
|
||||
val name = ContentAPI.getItemName(id)
|
||||
val name = getItemName(id)
|
||||
if(searchTerm.toLowerCase().contains(name) || name.toLowerCase().contains(searchTerm.toLowerCase()))
|
||||
fakeOffers.add(FakeOffer(true, ContentAPI.getItemName(id), amount))
|
||||
fakeOffers.add(FakeOffer(true, getItemName(id), amount))
|
||||
}
|
||||
|
||||
val buyingList = fakeOffers.filter { !it.sell }
|
||||
@@ -638,13 +638,13 @@ class MiscCommandSet : CommandSet(Command.Privilege.ADMIN){
|
||||
var lineId = 11
|
||||
for(i in 0..299) {
|
||||
val offer = if(i < buyList.size) buyList.getOrNull(i) else sellList.getOrNull(i - (buyList.size))
|
||||
ContentAPI.setInterfaceText(player, offer ?: "", Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
setInterfaceText(player, offer ?: "", Components.QUESTJOURNAL_SCROLL_275, lineId++)
|
||||
}
|
||||
ContentAPI.openInterface(player, Components.QUESTJOURNAL_SCROLL_275)
|
||||
openInterface(player, Components.QUESTJOURNAL_SCROLL_275)
|
||||
}
|
||||
|
||||
fun setScrollTitle(player: Player, text: String){
|
||||
ContentAPI.setInterfaceText(player, text, Components.QUESTJOURNAL_SCROLL_275, 2)
|
||||
setInterfaceText(player, text, Components.QUESTJOURNAL_SCROLL_275, 2)
|
||||
}
|
||||
|
||||
class FakeOffer(val sell: Boolean,val name: String,val amount: Int)
|
||||
|
||||
Reference in New Issue
Block a user