Merged listener types into just InteractionListener.kt

This commit is contained in:
Ceikry 2021-03-12 23:32:32 -06:00
parent 866962ff2b
commit 159bd80e90
21 changed files with 63 additions and 86 deletions

View file

@ -8,7 +8,7 @@ import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld
private val VALID_LOGS = intArrayOf(Items.LOGS_1511, Items.OAK_LOGS_1521,Items.WILLOW_LOGS_1519,Items.MAPLE_LOGS_1517,Items.YEW_LOGS_1515,Items.MAGIC_LOGS_1513)
@ -19,7 +19,7 @@ private val LIGHT_ANIM = Animation(7307)
* Handles interactions for beacons
* @author Ceikry
*/
class AFUBeaconListeners : OptionListener(){
class AFUBeaconListeners : InteractionListener(){
override fun defineListeners() {
on(OBJECT,"add-logs","light"){player,node ->

View file

@ -9,14 +9,14 @@ import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import java.util.*
/**
* Handles repairing and climbing of the 3 beacon shortcuts needed to access them
* @author Ceikry
*/
class AFURepairClimbHandler : OptionListener() {
class AFURepairClimbHandler : InteractionListener() {
val repairIDs = intArrayOf(38480,38470,38494)
val climbIDs = intArrayOf(38469,38471,38486,38481,38469)

View file

@ -12,7 +12,7 @@ import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import core.plugin.Initializable
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import rs09.game.node.entity.player.info.stats.FISHING_TRAWLER_LEAKS_PATCHED
import rs09.game.node.entity.player.info.stats.STATS_BASE
import rs09.tools.stringtools.colorize
@ -22,7 +22,7 @@ import kotlin.math.ceil
* Option handler for fishing trawler
* @author Ceikry
*/
class FishingTrawlerOptionHandler : OptionListener() {
class FishingTrawlerInteractionHandler : InteractionListener() {
val ENTRANCE_PLANK = 2178
val EXIT_PLANK = 2179
val HOLE = 2167

View file

@ -10,7 +10,7 @@ import core.game.system.task.Pulse
import core.game.world.map.zone.ZoneBorders
import core.plugin.Plugin
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import rs09.game.system.config.ItemConfigParser
import rs09.game.world.GameWorld
@ -19,7 +19,7 @@ import rs09.game.world.GameWorld
* @author Ceikry
* @author Woah
*/
class EquipHandler : OptionListener() {
class EquipHandler : InteractionListener() {
override fun defineListeners() {

View file

@ -7,13 +7,13 @@ import core.game.node.entity.player.Player
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.item.Item
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* Handles the work-for actions for the NPCs
* @author Ceikry
*/
class WorkForOptionListener : OptionListener() {
class WorkForInteractionListener : InteractionListener() {
val possibleWeaponLooks = arrayListOf(
Items.BRONZE_SCIMITAR_1321,
Items.STEEL_SCIMITAR_1325,

View file

@ -7,7 +7,7 @@ import core.game.system.task.Pulse
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld.Pulser
private const val LOADER = 11162
@ -20,7 +20,7 @@ private val FILL_ANIM = Animation(1649)
private val WIND_ANIM = Animation(1648)
private val SCOOP_ANIM = Animation(1650)
class BoneGrinderListener : OptionListener() {
class BoneGrinderListener : InteractionListener() {
override fun defineListeners() {

View file

@ -3,7 +3,7 @@ package rs09.game.interaction
import core.game.node.Node
import core.game.node.entity.player.Player
abstract class OptionListener : Listener{
abstract class InteractionListener : Listener{
val ITEM = 0
val OBJECT = 1
val NPC = 2
@ -19,4 +19,10 @@ abstract class OptionListener : Listener{
fun on(type: Int, vararg option: String, handler: (Player, Node) -> Boolean){
Listeners.add(option,type,handler)
}
fun on(used: Int, with: Int, type: Int, handler: (Player, Node, Node) -> Boolean){
Listeners.add(used,with,type,handler)
}
fun on(type: Int,used: Int,vararg with: Int, handler: (Player, Node, Node) -> Boolean){
Listeners.add(type,used,with,handler)
}
}

View file

@ -1,16 +0,0 @@
package rs09.game.interaction
import core.game.node.Node
import core.game.node.entity.player.Player
abstract class UseWithListener : Listener {
val ITEM = 0
val OBJECT = 1
val NPC = 2
fun on(used: Int, with: Int, type: Int, handler: (Player, Node, Node) -> Boolean){
Listeners.add(used,with,type,handler)
}
fun on(type: Int,used: Int,vararg with: Int, handler: (Player, Node, Node) -> Boolean){
Listeners.add(type,used,with,handler)
}
}

View file

@ -1,7 +1,7 @@
package rs09.game.interaction.city
import core.game.world.map.Location
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* File to be used for anything Isafdar related.
@ -9,7 +9,7 @@ import rs09.game.interaction.OptionListener
* @author Sir Kermit
*/
class IsafdarListeners : OptionListener() {
class IsafdarListeners : InteractionListener() {
val CAVE_ENTRANCE = 4006
val CAVE_EXIT = 4007

View file

@ -4,7 +4,7 @@ import core.game.node.entity.impl.ForceMovement
import core.game.world.map.Direction
import core.game.world.map.Location
import core.game.world.update.flag.context.Animation
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* File to be used for anything Morytania related.
@ -12,7 +12,7 @@ import rs09.game.interaction.OptionListener
* @author Sir Kermit
*/
class MorytaniaListeners : OptionListener() {
class MorytaniaListeners : InteractionListener() {
val GROTTO_ENTRANCE = 3516
val GROTTO_EXIT = 3526

View file

@ -1,12 +1,12 @@
package rs09.game.interaction.item
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* Handles the bracelet of clay operate option.
* @author Ceikry
*/
class BraceletOfClayPlugin : OptionListener() {
class BraceletOfClayPlugin : InteractionListener() {
val BRACELET = 11074

View file

@ -2,14 +2,14 @@ package rs09.game.interaction.item
import core.game.content.global.EnchantedJewellery
import rs09.game.content.global.EnchantedJewelleryDialogueFile
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import java.util.*
/**
* Listener for enchanted jewellery options
* @author Ceikry
*/
class EnchantedJewelleryListener : OptionListener() {
class EnchantedJewelleryListener : InteractionListener() {
val IDs: IntArray
init {

View file

@ -4,18 +4,19 @@ import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.item.Item
import core.game.world.map.zone.ZoneBorders
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.UseWithListener
import rs09.game.interaction.InteractionListener
import java.util.*
/**
* Handles coal truck interactions
* @author ceik
*/
class CoalTrucksHandler : OptionListener() {
class CoalTruckInteractionListeners : InteractionListener() {
val SEERS_VILLAGE_COAL_TRUCK_2114 = 2114
val seersVillageTrucks = ZoneBorders(2690,3502,2699,3508)
val COAL_TRUCK_2114 = 2114
val COAL = Items.COAL_453
override fun defineListeners() {
on(SEERS_VILLAGE_COAL_TRUCK_2114, OBJECT, "remove-coal") { player, node ->
@ -52,38 +53,28 @@ class CoalTrucksHandler : OptionListener() {
player.dialogueInterpreter.sendDialogue("There is currently $coalInTruck coal in the truck.", "The truck has space for " + (120 - coalInTruck) + " more coal.")
return@on true
}
}
//TODO:
class CoalTruckListener : UseWithListener() {
val COAL_TRUCK_2114 = 2114
val COAL = Items.COAL_453
on(COAL,COAL_TRUCK_2114,OBJECT){player,_,_ ->
var coalInTruck = player.getAttribute("coal-truck-inventory", 0)
override fun defineListeners() {
var coalInInventory = player.inventory.getAmount(Items.COAL_453)
on(COAL,COAL_TRUCK_2114,OBJECT){player,_,_ ->
var coalInTruck = player.getAttribute("coal-truck-inventory", 0)
if(coalInInventory + coalInTruck >= 120){
coalInInventory = 120 - coalInTruck
player.packetDispatch.sendMessage("You have filled up the coal truck.")
var coalInInventory = player.inventory.getAmount(Items.COAL_453)
if(coalInInventory + coalInTruck >= 120){
coalInInventory = 120 - coalInTruck
player.packetDispatch.sendMessage("You have filled up the coal truck.")
//handle coal truck task for seer's village
if (!player.achievementDiaryManager.getDiary(DiaryType.SEERS_VILLAGE).isComplete(1, 2)
&& player.viewport.region.id == 10294) { // region 10294 is at coal truck mine, region 10806 is in seers village
player.setAttribute("/save:diary:seers:coal-truck-full", true)
}
//handle coal truck task for seer's village
if (!player.achievementDiaryManager.getDiary(DiaryType.SEERS_VILLAGE).isComplete(1, 2)
&& player.viewport.region.id == 10294) { // region 10294 is at coal truck mine, region 10806 is in seers village
player.setAttribute("/save:diary:seers:coal-truck-full", true)
}
player.inventory.remove(Item(Items.COAL_453,coalInInventory))
coalInTruck += coalInInventory
player.setAttribute("/save:coal-truck-inventory",coalInTruck)
return@on true
}
player.inventory.remove(Item(Items.COAL_453,coalInInventory))
coalInTruck += coalInInventory
player.setAttribute("/save:coal-truck-inventory",coalInTruck)
return@on true
}
}
}

View file

@ -3,14 +3,14 @@ package rs09.game.interaction.`object`
import core.game.node.entity.player.link.diary.DiaryType
import core.game.node.entity.player.link.emote.Emotes
import core.game.world.map.RegionManager
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* Handles taunting of the demon in the wizard's tower
* @author afaroutdude / Ceikry
*/
private const val BARS = 37668
class DemonTauntHandler : OptionListener(){
class DemonTauntHandler : InteractionListener(){
override fun defineListeners() {
on(BARS,OBJECT,"taunt-through"){player,_ ->

View file

@ -4,7 +4,7 @@ import core.game.component.Component
import core.game.node.entity.player.Player
import core.game.node.entity.player.link.TeleportManager.TeleportType
import core.game.world.map.Location
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* Handles interactions with fairy rings
@ -15,7 +15,7 @@ private val RINGS = intArrayOf(12003, 12094, 12095, 14058, 14061, 14064, 14067,
private const val MAIN_RING = 12128
class FairyRingPlugin : OptionListener() {
class FairyRingPlugin : InteractionListener() {
override fun defineListeners() {

View file

@ -9,12 +9,12 @@ import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld
import java.util.concurrent.TimeUnit
private const val CHEST = 2827
class GutanothChestOptionHandler : OptionListener(){
class GutanothChestInteractionHandler : InteractionListener(){
override fun defineListeners() {

View file

@ -7,14 +7,14 @@ import core.game.node.item.Item
import core.game.system.task.Pulse
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
import rs09.game.world.GameWorld
/**
* Handles the chopping down of dense jungle, mainly to grant access to the Kharazi Jungle.
* @author Ceikry
*/
class JungleBushHandler : OptionListener(){
class JungleBushHandler : InteractionListener(){
val chopped_bush = 2895
val chop_a = Animation(910)
val chop_b = Animation(2382)

View file

@ -6,13 +6,13 @@ import core.game.node.item.GroundItemManager
import core.game.node.item.Item
import core.game.world.update.flag.context.Animation
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* Handles the muddy chest
* @author Ceikry
*/
class MuddyChestHandler : OptionListener() {
class MuddyChestHandler : InteractionListener() {
private val CHEST = 170

View file

@ -4,7 +4,7 @@ import core.game.node.`object`.ObjectBuilder
import core.game.node.item.Item
import core.tools.RandomFunction
import org.rs09.consts.Items
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
/**
* @author Woah, with love
@ -15,7 +15,7 @@ import rs09.game.interaction.OptionListener
* Option(s):
* "Take-from"
*/
class TarBarrelListener : OptionListener() {
class TarBarrelListener : InteractionListener() {
val FULL_TAR_BARREL_16860 = 16860
val EMPTY_TAR_BARREL_16688 = 16688

View file

@ -1,9 +1,9 @@
package rs09.game.node.entity.skill.fishing.barbfishing
import core.game.node.item.Item
import rs09.game.interaction.OptionListener
import rs09.game.interaction.InteractionListener
class BarbFishOptionListeners : OptionListener() {
class BarbFishInteractionListeners : InteractionListener() {
override fun defineListeners() {
on(25268,OBJECT,"search"){player,_ ->

View file

@ -11,8 +11,7 @@ import core.plugin.PluginManifest
import core.plugin.PluginType
import io.github.classgraph.ClassGraph
import io.github.classgraph.ClassInfo
import rs09.game.interaction.OptionListener
import rs09.game.interaction.UseWithListener
import rs09.game.interaction.InteractionListener
import rs09.game.system.SystemLogger
import rs09.game.system.command.Command
import java.util.*
@ -73,11 +72,8 @@ object PluginManager {
definePlugin(it.loadClass().newInstance() as Plugin<Command>).also { System.out.println("Initializing $it") }
} catch (e: Exception) {e.printStackTrace()}
}
result.getSubclasses("rs09.game.interaction.OptionListener").forEach {
(it.loadClass().newInstance() as OptionListener).defineListeners()
}
result.getSubclasses("rs09.game.interaction.UseWithListener").forEach {
(it.loadClass().newInstance() as UseWithListener).defineListeners()
result.getSubclasses("rs09.game.interaction.InteractionListener").forEach {
(it.loadClass().newInstance() as InteractionListener).defineListeners()
}
}