Skip to content

Commit

Permalink
Restructure event package
Browse files Browse the repository at this point in the history
By separating event base classes from specific implementations, we'll be able to re-use abstract components in a modular fashion.

This change results in the following:
 * `io.luna.event` package that contains all event abstractions that are not tied to game logic.
 * `io.luna.game.events` package that contains specific implementations of those abstractions solely used for game logic.

 Contributes to luna-rs#180
  • Loading branch information
notjuanortiz committed Mar 27, 2020
1 parent f33dc1e commit c1d3c76
Show file tree
Hide file tree
Showing 129 changed files with 198 additions and 223 deletions.
2 changes: 1 addition & 1 deletion plugins/api/event/DuplicateMatchException.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api.event

import io.luna.game.event.Event
import io.luna.event.Event
import javax.script.ScriptException
import kotlin.reflect.KClass

Expand Down
2 changes: 1 addition & 1 deletion plugins/api/event/InterceptBy.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api.event

import api.predef.*
import io.luna.game.event.Event
import io.luna.event.Event
import javax.script.ScriptException
import kotlin.reflect.KClass

Expand Down
8 changes: 4 additions & 4 deletions plugins/api/event/InterceptFilter.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package api.event

import api.predef.*
import io.luna.game.event.Event
import io.luna.game.event.EventListener
import io.luna.event.Event
import io.luna.event.EventListener
import kotlin.reflect.KClass

/**
Expand All @@ -12,8 +12,8 @@ import kotlin.reflect.KClass
* @author lare96
*/
class InterceptFilter<E : Event>(private val eventType: KClass<E>,
private val condition: E.() -> Boolean,
private val testValue: Boolean) {
private val condition: E.() -> Boolean,
private val testValue: Boolean) {

/**
* Test condition, and run if satisfied!
Expand Down
2 changes: 1 addition & 1 deletion plugins/api/event/InterceptMatcher.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api.event

import io.luna.game.event.Event
import io.luna.event.Event
import kotlin.reflect.KClass

/**
Expand Down
4 changes: 2 additions & 2 deletions plugins/api/event/InterceptUseItem.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api.event

import io.luna.game.event.impl.ItemOnItemEvent
import io.luna.game.event.impl.ItemOnObjectEvent
import io.luna.game.events.ItemOnItemEvent
import io.luna.game.events.ItemOnObjectEvent

/**
* A model that intercepts [ItemOnItemEvent]s and [ItemOnObjectEvent]s.
Expand Down
26 changes: 13 additions & 13 deletions plugins/api/event/Matcher.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package api.event

import api.predef.*
import io.luna.game.event.Event
import io.luna.game.event.EventMatcher
import io.luna.game.event.EventMatcherListener
import io.luna.game.event.impl.ButtonClickEvent
import io.luna.game.event.impl.CommandEvent
import io.luna.game.event.impl.ItemClickEvent
import io.luna.game.event.impl.ItemClickEvent.*
import io.luna.game.event.impl.ItemOnItemEvent
import io.luna.game.event.impl.ItemOnObjectEvent
import io.luna.game.event.impl.NpcClickEvent
import io.luna.game.event.impl.NpcClickEvent.*
import io.luna.game.event.impl.ObjectClickEvent
import io.luna.game.event.impl.ObjectClickEvent.*
import io.luna.event.Event
import io.luna.event.EventMatcher
import io.luna.event.EventMatcherListener
import io.luna.game.events.ButtonClickEvent
import io.luna.game.events.CommandEvent
import io.luna.game.events.ItemClickEvent
import io.luna.game.events.ItemClickEvent.*
import io.luna.game.events.ItemOnItemEvent
import io.luna.game.events.ItemOnObjectEvent
import io.luna.game.events.NpcClickEvent
import io.luna.game.events.NpcClickEvent.*
import io.luna.game.events.ObjectClickEvent
import io.luna.game.events.ObjectClickEvent.*
import kotlin.reflect.KClass

/**
Expand Down
18 changes: 9 additions & 9 deletions plugins/api/predef/EventPredef.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package api.predef
import api.event.InterceptBy
import api.event.InterceptUseItem
import api.event.Matcher
import io.luna.game.event.Event
import io.luna.game.event.EventListener
import io.luna.game.event.impl.ButtonClickEvent
import io.luna.game.event.impl.CommandEvent
import io.luna.game.event.impl.ItemClickEvent.*
import io.luna.game.event.impl.ItemOnItemEvent
import io.luna.game.event.impl.ItemOnObjectEvent
import io.luna.game.event.impl.NpcClickEvent.*
import io.luna.game.event.impl.ObjectClickEvent.*
import io.luna.event.Event
import io.luna.event.EventListener
import io.luna.game.events.ButtonClickEvent
import io.luna.game.events.CommandEvent
import io.luna.game.events.ItemClickEvent.*
import io.luna.game.events.ItemOnItemEvent
import io.luna.game.events.ItemOnObjectEvent
import io.luna.game.events.NpcClickEvent.*
import io.luna.game.events.ObjectClickEvent.*
import io.luna.game.model.mob.PlayerRights
import java.util.*
import kotlin.reflect.KClass
Expand Down
4 changes: 2 additions & 2 deletions plugins/api/predef/PropertiesPredef.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api.predef

import io.luna.game.event.EventListener
import io.luna.game.event.EventMatcherListener
import io.luna.event.EventListener
import io.luna.event.EventMatcherListener
import io.luna.game.model.EntityType
import io.luna.game.model.item.Equipment
import io.luna.game.model.item.Item
Expand Down
2 changes: 1 addition & 1 deletion plugins/api/shop/OpenReceiver.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api.shop

import api.predef.*
import io.luna.game.event.impl.PlayerEvent
import io.luna.game.events.PlayerEvent
import io.luna.game.model.item.shop.Shop
import io.luna.game.model.item.shop.ShopInterface

Expand Down
1 change: 0 additions & 1 deletion plugins/world/areas/wilderness/registerWilderness.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.areas.wilderness

import api.predef.*
import io.luna.game.event.impl.ServerLaunchEvent

/**
* Register miscellaneous wilderness areas here.
Expand Down
1 change: 0 additions & 1 deletion plugins/world/npc/death/dropItems/dropNpcItems.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.npc.death.dropItems

import api.predef.*
import io.luna.game.event.impl.NpcDeathEvent

on(NpcDeathEvent::class) {
// TODO Npc Drops.
Expand Down
1 change: 0 additions & 1 deletion plugins/world/npc/makeOver/makeOver.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.npc.makeOver

import api.predef.*
import io.luna.game.event.impl.ServerLaunchEvent
import io.luna.game.model.mob.PlayerAppearance

/**
Expand Down
1 change: 0 additions & 1 deletion plugins/world/npc/shop/generalStore/generalStore.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.npc.shop.generalStore

import api.predef.*
import io.luna.game.event.impl.ServerLaunchEvent
import io.luna.game.model.item.shop.BuyPolicy
import io.luna.game.model.item.shop.Currency
import io.luna.game.model.item.shop.RestockPolicy
Expand Down
2 changes: 0 additions & 2 deletions plugins/world/player/advanceLevel/advanceLevel.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package world.player.advanceLevel

import api.predef.*
import io.luna.game.event.impl.SkillChangeEvent
import io.luna.game.model.mob.Graphic
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.Skill
import io.luna.game.model.mob.block.UpdateFlagSet.UpdateFlag
import io.luna.net.msg.out.SkillUpdateMessageWriter

/**
* Graphic played when a player advances a level.
Expand Down
1 change: 0 additions & 1 deletion plugins/world/player/announcements/announcements.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.player.announcements

import api.predef.*
import io.luna.game.event.impl.ServerLaunchEvent

/**
* Announcement broadcast interval.
Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/command/CommandHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package world.player.command

import api.event.Matcher
import api.predef.*
import io.luna.game.event.impl.CommandEvent
import io.luna.game.events.CommandEvent
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.PlayerRights

Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/command/generic/playerCmd.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import api.event.Matcher
import api.inter.QuestJournalInterface
import api.predef.*
import com.google.common.collect.HashMultimap
import io.luna.game.event.impl.CommandEvent
import io.luna.game.events.CommandEvent
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.PlayerRights
import io.luna.game.model.mob.inter.NameInputInterface
Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/command/punishment/punishmentCmd.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package world.player.command.punishment

import api.predef.*
import api.punishment.PunishmentHandler
import io.luna.game.event.impl.CommandEvent
import io.luna.game.events.CommandEvent
import world.player.command.cmd
import world.player.command.getPlayer
import java.time.LocalDateTime
Expand Down
3 changes: 1 addition & 2 deletions plugins/world/player/command/searchItem/findItemCmd.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package world.player.command.searchItem

import api.predef.*
import io.luna.game.event.impl.WidgetItemClickEvent
import io.luna.game.event.impl.WidgetItemClickEvent.*
import io.luna.game.events.WidgetItemClickEvent.*
import io.luna.game.model.item.Item
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.inter.AmountInputInterface
Expand Down
1 change: 0 additions & 1 deletion plugins/world/player/command/setSkill/setSkill.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.player.command.setSkill

import api.predef.*
import io.luna.game.event.impl.ButtonClickEvent
import io.luna.game.model.mob.inter.AbstractInterfaceSet
import world.player.command.cmd

Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/death/dropItems/dropPlayerItems.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.death.dropItems

import api.predef.*
import io.luna.game.event.impl.PlayerDeathEvent
import io.luna.game.events.PlayerDeathEvent
import io.luna.game.model.EntityType
import io.luna.game.model.item.Item
import io.luna.game.model.item.ItemContainer
Expand Down
1 change: 0 additions & 1 deletion plugins/world/player/emote/performEmote.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.player.emote

import api.predef.*
import io.luna.game.event.impl.ButtonClickEvent
import io.luna.game.model.mob.Animation
import io.luna.game.model.mob.Player

Expand Down
1 change: 0 additions & 1 deletion plugins/world/player/inter/clickOption/clickOption.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.player.inter.clickOption

import api.predef.*
import io.luna.game.event.impl.ButtonClickEvent
import io.luna.game.model.mob.dialogue.OptionDialogueInterface

/**
Expand Down
1 change: 0 additions & 1 deletion plugins/world/player/inter/makeItem/makeItem.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.player.inter.makeItem

import api.predef.*
import io.luna.game.event.impl.ButtonClickEvent
import io.luna.game.model.mob.dialogue.MakeItemDialogueInterface

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package world.player.item.banking.depositBox

import api.predef.*
import io.luna.game.event.impl.WidgetItemClickEvent
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.inter.AmountInputInterface

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.item.banking.depositBox

import api.predef.*
import io.luna.game.event.impl.ObjectClickEvent.ObjectFirstClickEvent
import io.luna.game.events.ObjectClickEvent.ObjectFirstClickEvent

/**
* A set of deposit boxes.
Expand Down
3 changes: 1 addition & 2 deletions plugins/world/player/item/banking/regularBank/bankInput.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package world.player.item.banking.regularBank

import api.predef.*
import io.luna.game.event.impl.WidgetItemClickEvent
import io.luna.game.event.impl.WidgetItemClickEvent.*
import io.luna.game.events.WidgetItemClickEvent.*
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.inter.AmountInputInterface

Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/item/banking/regularBank/openBank.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.item.banking.regularBank

import api.predef.*
import io.luna.game.event.impl.ObjectClickEvent.ObjectFirstClickEvent
import io.luna.game.events.ObjectClickEvent.ObjectFirstClickEvent

/**
* A set of banking objects.
Expand Down
3 changes: 1 addition & 2 deletions plugins/world/player/item/equipment/equipmentChange.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package world.player.item.equipment

import api.predef.*
import io.luna.game.event.impl.EquipItemEvent
import io.luna.game.event.impl.WidgetItemClickEvent.WidgetItemFirstClickEvent
import io.luna.game.events.WidgetItemClickEvent.WidgetItemFirstClickEvent
import io.luna.game.model.mob.Player

/**
Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/item/shops/itemValue.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.item.shops

import api.predef.*
import io.luna.game.event.impl.WidgetItemClickEvent.WidgetItemFirstClickEvent
import io.luna.game.events.WidgetItemClickEvent.WidgetItemFirstClickEvent
import io.luna.game.model.item.shop.Shop
import io.luna.game.model.item.shop.ShopInterface
import io.luna.game.model.mob.Player
Expand Down
4 changes: 2 additions & 2 deletions plugins/world/player/item/shops/shopChange.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package world.player.item.shops

import api.predef.*
import io.luna.game.event.impl.WidgetItemClickEvent
import io.luna.game.event.impl.WidgetItemClickEvent.*
import io.luna.game.events.WidgetItemClickEvent
import io.luna.game.events.WidgetItemClickEvent.*
import io.luna.game.model.item.shop.ShopInterface

/**
Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/item/trading/request/requestTrade.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.item.trading.request

import api.predef.*
import io.luna.game.event.impl.PlayerClickEvent.PlayerFourthClickEvent
import io.luna.game.events.PlayerClickEvent.PlayerFourthClickEvent
import io.luna.game.model.mob.Player

/**
Expand Down
3 changes: 1 addition & 2 deletions plugins/world/player/item/trading/tradeScreen/offerItem.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package world.player.item.trading.tradeScreen

import api.predef.*
import io.luna.game.event.impl.WidgetItemClickEvent
import io.luna.game.event.impl.WidgetItemClickEvent.*
import io.luna.game.events.WidgetItemClickEvent.*
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.inter.AmountInputInterface

Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/login/init/initPlayer.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package world.player.login.init
import api.predef.*
import api.punishment.PunishmentHandler
import io.luna.Luna
import io.luna.game.event.impl.LoginEvent
import io.luna.game.events.LoginEvent
import io.luna.game.model.mob.Player
import io.luna.net.msg.out.AssignmentMessageWriter
import io.luna.net.msg.out.SkillUpdateMessageWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.login.starterPackage

import api.predef.*
import io.luna.game.event.impl.LoginEvent
import io.luna.game.events.LoginEvent
import io.luna.game.model.item.Item
import io.luna.game.model.mob.Player
import io.luna.game.model.mob.PlayerAppearance.DesignPlayerInterface
Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/obj/resource/Resource.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.obj.resource

import api.predef.*
import io.luna.game.event.impl.ItemOnObjectEvent
import io.luna.game.events.ItemOnObjectEvent
import io.luna.game.model.def.ObjectDefinition
import io.luna.game.model.item.Item
import io.luna.game.model.mob.Player
Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/obj/restorePrayer/restorePrayer.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.obj.restorePrayer

import api.predef.*
import io.luna.game.event.impl.ObjectClickEvent.ObjectFirstClickEvent
import io.luna.game.events.ObjectClickEvent.ObjectFirstClickEvent
import io.luna.game.model.mob.Animation
import io.luna.game.model.mob.Player

Expand Down
2 changes: 1 addition & 1 deletion plugins/world/player/privateChat/chat.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package world.player.privateChat

import api.predef.*
import io.luna.game.event.impl.PrivateChatEvent
import io.luna.game.events.PrivateChatEvent
import io.luna.game.model.mob.Player
import io.luna.net.msg.out.PrivateChatMessageWriter

Expand Down
Loading

0 comments on commit c1d3c76

Please sign in to comment.