mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-02 16:49:03 +00:00
Plugins System (#510)
* Started Ripping Plugin System From Astraeus
*Currently only ClickingButtons Support
*Also Started Using The Logout Button Plugin From Astraeus
* NpcFirstClickEvent setup for plugins
also made Man & Women chat work through this
* Server: Add Google Collect Lib
* Server: NpcSecondClickEvent setup for plugins
also handle pickpocketing npc clicking through plugin
* Server: NpcThirdClickEvent setup for plugins
* Server: Remove conflicting action for Secondclicking npc id 3
* Server: ItemFirstClickEvent setup for plugins
Also Handle Yo-Yo First Click Through This
* Server: ItemOnItemEvent setup for plugins
Also Handle Black Candle Lighting With Tinderbox Through this
* Server: ItemOnNpcEvent setup for plugins
* Server: ItemOnObjectEvent setup for plugins
Also Handle Fillable Items Through This
* Server: ItemSecondClickEvent & ItemThirdClickEvent setup for plugins
Also Handle Yo-Yo Actions Through This
* Server: ObjectFirstClickEvent setup for plugins
Also Handle FirstClick Mining Actions Through This
* Server: ObjectSecondClickEvent setup for plugins
Also Handle Stall Thieving Actions Through This
* Server: ObjectThirdClickEvent setup for plugins
* Server: ObjectFourthClickEvent setup for plugins
Also Handle Fourth Click Farming Object Actions Through This
* Server: MagicOnItemEvent setup for plugins
Also Handle SuperHeat Through This
* More mage training arena (#509)
* Fixup points display
* Only allow players to deposit up to 12k at one time
* Apple damage and play animation
* Update order or prices
* Update Telekinetic.java
(cherry picked from commit ab3b1e9731)
Co-authored-by: RedSparr0w <RedSparr0w@users.noreply.github.com>
Co-authored-by: Danial <admin@redsparr0w.com>
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
package plugin.buttons
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.impl.ButtonActionEvent
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
|
||||
abstract class ButtonClick : EventSubscriber<ButtonActionEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ButtonActionEvent) {
|
||||
execute(player, event)
|
||||
}
|
||||
|
||||
abstract fun execute(player : Player, event : ButtonActionEvent);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package plugin.buttons.gameframe
|
||||
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ButtonActionEvent
|
||||
|
||||
import com.rs2.game.players.Player
|
||||
import plugin.buttons.ButtonClick
|
||||
|
||||
@SubscribesTo(ButtonActionEvent::class)
|
||||
class LogoutButton : ButtonClick() {
|
||||
|
||||
override fun execute(player: Player, event: ButtonActionEvent) {
|
||||
player.logout()
|
||||
}
|
||||
|
||||
override fun test(event: ButtonActionEvent): Boolean {
|
||||
return event.button == 9154;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"name": "Logout Button",
|
||||
"description": "The button for logging a player out.",
|
||||
"group": "button",
|
||||
"base": "plugin.buttons.gameframe.LogoutButton",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,28 @@
|
||||
package plugin.click.item
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemFirstClickEvent
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
|
||||
@SubscribesTo(ItemFirstClickEvent::class)
|
||||
class ItemFirstClick : EventSubscriber<ItemFirstClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ItemFirstClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[ItemClick#1] - Item: ${event.item}")
|
||||
}
|
||||
|
||||
when(event.item) {
|
||||
|
||||
4079 -> player.startAnimation(1457) // yo-yo
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package plugin.click.item
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemOnItemEvent
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemOnItemEvent::class)
|
||||
class ItemOnItem : EventSubscriber<ItemOnItemEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ItemOnItemEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[ItemOnItem] - used: ${event.used} with: ${event.usedWith}")
|
||||
}
|
||||
|
||||
if (event.used == 38 && event.usedWith == 590) {
|
||||
player.itemAssistant.addItem(32, 1)
|
||||
player.itemAssistant.deleteItem(38, 1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package plugin.click.item
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemOnNpcEvent
|
||||
import com.rs2.game.npcs.NpcHandler
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemOnNpcEvent::class)
|
||||
class ItemOnNpc : EventSubscriber<ItemOnNpcEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ItemOnNpcEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[ItemOnNpc] - itemId: ${event.item} npcId: ${event.npc}")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package plugin.click.item
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemOnObjectEvent
|
||||
import com.rs2.game.items.impl.Fillables
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
|
||||
@SubscribesTo(ItemOnObjectEvent::class)
|
||||
class ItemOnObject : EventSubscriber<ItemOnObjectEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ItemOnObjectEvent) {
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[ItemOnObject] - itemId: ${event.item} objectId: ${event.gameObject} Location: x: ${player.objectX}, x: ${player.objectY}")
|
||||
}
|
||||
|
||||
if (Fillables.canFill(event.item, event.gameObject) && player.itemAssistant.playerHasItem(event.item)) {
|
||||
//val amount = player.itemAssistant.getItemAmount(event.item)
|
||||
player.itemAssistant.deleteItem(event.item, 1)
|
||||
player.itemAssistant.addItem(Fillables.counterpart(event.item), 1)
|
||||
player.packetSender.sendMessage(Fillables.fillMessage(event.item, event.gameObject))
|
||||
player.startAnimation(832)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package plugin.click.item
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemSecondClickEvent
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemSecondClickEvent::class)
|
||||
class ItemSecondClick : EventSubscriber<ItemSecondClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ItemSecondClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[ItemClick#2] - ItemId: ${event.id}")
|
||||
}
|
||||
|
||||
when(event.id) {
|
||||
|
||||
4079 -> player.startAnimation(1459) //yo-yo
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package plugin.click.item
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ItemThirdClickEvent
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ItemThirdClickEvent::class)
|
||||
class ItemThirdClick : EventSubscriber<ItemThirdClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ItemThirdClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[ItemClick#3] - ItemId: ${event.id}")
|
||||
}
|
||||
|
||||
when(event.id) {
|
||||
|
||||
4079 -> player.startAnimation(1460) //yo-yo
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
[
|
||||
{
|
||||
"name": "Item First Click",
|
||||
"description": "The plugin for handling the first option of an item.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.item.ItemFirstClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Item Second Click",
|
||||
"description": "The plugin for handling the second option of an item.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.item.ItemSecondClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Item Third Click",
|
||||
"description": "The plugin for handling the third option of an item.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.item.ItemThirdClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Item On Item",
|
||||
"description": "The plugin for handling using an item on another item.",
|
||||
"group": "item",
|
||||
"base": "plugin.click.item.ItemOnItem",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Item On Npc",
|
||||
"description": "The plugin for handling using an item on an npc.",
|
||||
"group": "item",
|
||||
"base": "plugin.click.item.ItemOnNpc",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Item On Object",
|
||||
"description": "The plugin for handling using an item on a game object.",
|
||||
"group": "item",
|
||||
"base": "plugin.click.item.ItemOnObject",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
package plugin.click.magic
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.MagicOnItemEvent
|
||||
import com.rs2.game.content.skills.smithing.Superheat
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(MagicOnItemEvent::class)
|
||||
class MagicOnItem : EventSubscriber<MagicOnItemEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: MagicOnItemEvent) {
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[MagicOnItem] - ItemId: ${event.itemId} Slot: ${event.slot} SpellId: ${event.spellId}");
|
||||
}
|
||||
|
||||
when(event.spellId) {
|
||||
1173 -> if (!Superheat.superHeatItem(player, event.itemId)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
[
|
||||
{
|
||||
"name": "Magic On Item",
|
||||
"description": "The plugin for handling using spells on items.",
|
||||
"group": "magic",
|
||||
"base": "plugin.click.magic.MagicOnItem",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,35 @@
|
||||
package plugin.click.npc
|
||||
|
||||
import com.rs2.GameConstants
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.NpcFirstClickEvent
|
||||
import com.rs2.game.npcs.Npc
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.util.Misc
|
||||
|
||||
|
||||
@SubscribesTo(NpcFirstClickEvent::class)
|
||||
class NpcFirstClick : EventSubscriber<NpcFirstClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= npc], [type = first], [id= ${event.npc}], [Type= ${event.npc}]");
|
||||
}
|
||||
|
||||
when(event.npc) {
|
||||
|
||||
1,2,3,4,5,6 -> if (Misc.random(10) <= 5) {
|
||||
player.dialogueHandler.sendDialogues(3869, player.npcType)
|
||||
} else {
|
||||
player.dialogueHandler.sendDialogues(3872, player.npcType)
|
||||
}
|
||||
|
||||
//else ->
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package plugin.click.npc
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.NpcSecondClickEvent
|
||||
import com.rs2.game.content.skills.thieving.Pickpocket
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(NpcSecondClickEvent::class)
|
||||
class NpcSecondClick : EventSubscriber<NpcSecondClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: NpcSecondClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= npc], [type = second], [id= ${event.npc}], [Type= ${event.npc}]");
|
||||
}
|
||||
|
||||
if (Pickpocket.isNPC(player, player.npcType)) {
|
||||
Pickpocket.attemptPickpocket(player, player.npcType)
|
||||
return
|
||||
}
|
||||
|
||||
when(event.npc) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package plugin.click.npc
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.NpcThirdClickEvent
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(NpcThirdClickEvent::class)
|
||||
class NpcThirdClick : EventSubscriber<NpcThirdClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: NpcThirdClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= npc], [type = third], [id= ${event.npc}], [Type= ${event.npc}]");
|
||||
}
|
||||
|
||||
when(event.npc) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
[
|
||||
{
|
||||
"name": "Npc First Click",
|
||||
"description": "The plugin for handling the first option of an npc.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.npc.NpcFirstClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Npc Second Click",
|
||||
"description": "The plugin for handling the second option of an npc.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.npc.NpcSecondClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Npc Third Click",
|
||||
"description": "The plugin for handling the third option of an npc.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.npc.NpcThirdClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,31 @@
|
||||
package plugin.click.obj
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectFirstClickEvent
|
||||
import com.rs2.game.content.skills.core.Mining
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ObjectFirstClickEvent::class)
|
||||
class ObjectFirstClick : EventSubscriber<ObjectFirstClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ObjectFirstClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= object], [type= first], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ]")
|
||||
}
|
||||
|
||||
// if its a rock we can mine, mine it
|
||||
if (Mining.rockExists(event.gameObject)) {
|
||||
player.mining.startMining(player, event.gameObject, player.objectX, player.objectY, player.clickObjectType)
|
||||
return
|
||||
}
|
||||
|
||||
when (event.gameObject) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package plugin.click.obj
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectFourthClickEvent
|
||||
import com.rs2.game.content.skills.farming.Farming
|
||||
import com.rs2.game.players.Player
|
||||
import com.rs2.world.clip.Region
|
||||
|
||||
@SubscribesTo(ObjectFourthClickEvent::class)
|
||||
class ObjectFourthClick : EventSubscriber<ObjectFourthClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ObjectFourthClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= object], [type= fourth], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ], [PLUGIN]");
|
||||
}
|
||||
|
||||
if (!Region.objectExists(player.objectId, player.objectX, player.objectY, player.heightLevel)) {
|
||||
return
|
||||
}
|
||||
|
||||
Farming.guide(player, player.objectX, player.objectY)
|
||||
|
||||
when (event.gameObject) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package plugin.click.obj
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectSecondClickEvent
|
||||
import com.rs2.game.content.skills.thieving.Stalls
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ObjectSecondClickEvent::class)
|
||||
class ObjectSecondClick : EventSubscriber<ObjectSecondClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ObjectSecondClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= object], [type= second], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ]");
|
||||
}
|
||||
|
||||
if (Stalls.isObject(event.gameObject)) {
|
||||
Stalls.attemptStall(player, event.gameObject, player.objectX, player.objectY)
|
||||
return
|
||||
}
|
||||
|
||||
when (event.gameObject) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package plugin.click.obj
|
||||
|
||||
import com.rs2.event.EventContext
|
||||
import com.rs2.event.EventSubscriber
|
||||
import com.rs2.event.SubscribesTo
|
||||
import com.rs2.event.impl.ObjectThirdClickEvent
|
||||
import com.rs2.game.content.skills.thieving.Stalls
|
||||
import com.rs2.game.players.Player
|
||||
|
||||
@SubscribesTo(ObjectThirdClickEvent::class)
|
||||
class ObjectThirdClick : EventSubscriber<ObjectThirdClickEvent> {
|
||||
|
||||
override fun subscribe(context: EventContext, player: Player, event: ObjectThirdClickEvent) {
|
||||
|
||||
if (player.playerRights >= 3) {
|
||||
player.packetSender.sendMessage("[click= object], [type= third], [id= ${player.objectId}], [location= x:${player.objectX} y:${player.objectY} ], [PLUGIN]");
|
||||
}
|
||||
|
||||
if (Stalls.isObject(event.gameObject)) {
|
||||
Stalls.attemptStall(player, event.gameObject, player.objectX, player.objectY)
|
||||
return
|
||||
}
|
||||
|
||||
when (event.gameObject) {
|
||||
10177 -> player.playerAssistant.movePlayer(1798, 4407, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
[
|
||||
{
|
||||
"name": "Object First Click",
|
||||
"description": "The plugin for handling the first option of an object.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.obj.ObjectFirstClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Object Second Click",
|
||||
"description": "The plugin for handling the second option of an object.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.obj.ObjectSecondClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Object Third Click",
|
||||
"description": "The plugin for handling the third option of an object.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.obj.ObjectThirdClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
},
|
||||
{
|
||||
"name": "Object Fourth Click",
|
||||
"description": "The plugin for handling the fourth option of an object.",
|
||||
"group": "click",
|
||||
"base": "plugin.click.obj.ObjectFourthClick",
|
||||
"authors": [
|
||||
"Vult-R"
|
||||
],
|
||||
"version": 1.0
|
||||
}
|
||||
]
|
||||
@@ -145,6 +145,11 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/everythingrs-api.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.collections</groupId>
|
||||
<artifactId>google-collections</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -201,6 +201,11 @@ public class GameEngine {
|
||||
startMinutesCounter();
|
||||
setMinutesCounter(minutesCounter);
|
||||
|
||||
/**
|
||||
* Load Plugins
|
||||
*/
|
||||
Player.getPluginService().load();
|
||||
|
||||
/**
|
||||
* Server Successfully Loaded
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.rs2.event;
|
||||
|
||||
/**
|
||||
* Something that happens; an occurrence.
|
||||
*
|
||||
* <p>
|
||||
* An event is characterized by having a type and relative information about
|
||||
* each occurrence of the event.
|
||||
* </p>
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public interface Event {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.rs2.event;
|
||||
|
||||
/**
|
||||
* Represents the context of an {@link Event}
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public interface EventContext {
|
||||
|
||||
/**
|
||||
* Breaks the chain of subscribers.
|
||||
*/
|
||||
void breakSubscriberChain();
|
||||
|
||||
/**
|
||||
* Repairs the chain of subscribers.
|
||||
*/
|
||||
void repairSubscriberChain();
|
||||
|
||||
/**
|
||||
* Checks whether or not the subscriber chain is broken.
|
||||
*
|
||||
* @return {@code true} if and only if the chain is broken, otherwise
|
||||
* {@code false}.
|
||||
*/
|
||||
boolean isChainBroken();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.rs2.event;
|
||||
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
/**
|
||||
* An event provider provides support for dynamic {@link Event} posting,
|
||||
* depriving and providing {@link EventSubscriber}s
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public interface EventProvider {
|
||||
|
||||
/**
|
||||
* Provides an {@link EventSubscriber} for the specified event.
|
||||
*
|
||||
* @param subscriber The subscriber to provide.
|
||||
*/
|
||||
void provideSubscriber(EventSubscriber<?> subscriber);
|
||||
|
||||
/**
|
||||
* Deprives an {@link EventSubscriber} for the specified event.
|
||||
*
|
||||
* @param subscriber The subscriber to deprive.
|
||||
*/
|
||||
void depriveSubscriber(EventSubscriber<?> subscriber);
|
||||
|
||||
/**
|
||||
* Posts an {@link Event}, notifying all provided subscribers.
|
||||
*
|
||||
* @param <E> The event type reference.
|
||||
* @param player The player to post the event for.
|
||||
* @param event The event to post.
|
||||
*/
|
||||
<E extends Event> void post(Player player, E event);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.rs2.event;
|
||||
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Represents a single subscriber for some {@link Event}.
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*
|
||||
* @param <E> The type of event to the subscriber.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface EventSubscriber<E extends Event> extends Predicate<E> {
|
||||
|
||||
/**
|
||||
* A handler method which executes event specific logic if and only if
|
||||
* {@link #test(Event)} returns {@code true}.
|
||||
*
|
||||
* @param context The context of the event.
|
||||
* @param player The player to subscribe the event for.
|
||||
* @param event The event to subscribe.
|
||||
*/
|
||||
void subscribe(EventContext context, Player player, E event);
|
||||
|
||||
@Override
|
||||
default boolean test(E event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.rs2.event;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Indicates that types annotated are an {@link EventSubscriber} and subscribe
|
||||
* to one specific {@link Event}. {@link #value()} enforces that the specified
|
||||
* event value is indeed an event. All event subscribers MUST be annotated
|
||||
* otherwise {@link EventProvider}s will be unable to provide and deprive
|
||||
* subscribers.
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Target(TYPE)
|
||||
public @interface SubscribesTo {
|
||||
|
||||
/**
|
||||
* Returns the event class that the annotated {@link EventSubscriber}
|
||||
* subscribes to.
|
||||
*/
|
||||
Class<? extends Event> value();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.rs2.event;
|
||||
|
||||
/**
|
||||
* An universal implementation of an {@link EventContext}.
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public final class UniversalEventContext implements EventContext {
|
||||
|
||||
/**
|
||||
* A flag denoting whether or not the subscriber chain is broken.
|
||||
*/
|
||||
private boolean chainBroken;
|
||||
|
||||
@Override
|
||||
public void breakSubscriberChain() {
|
||||
chainBroken = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void repairSubscriberChain() {
|
||||
chainBroken = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChainBroken() {
|
||||
return chainBroken;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.rs2.event;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.util.ClassUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* A universal event provider which posts, provides and deprives subscribers.
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public final class UniversalEventProvider implements EventProvider {
|
||||
|
||||
/**
|
||||
* A {@link Multimap} of {@link Event} classes to subscribers.
|
||||
*/
|
||||
private final Multimap<Class<? extends Event>, EventSubscriber<? super Event>> events = ArrayListMultimap.create();
|
||||
|
||||
/**
|
||||
* The universal context of this event provider.
|
||||
*/
|
||||
private final EventContext context = new UniversalEventContext();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void provideSubscriber(EventSubscriber<?> subscriber) {
|
||||
checkSubscriber(subscriber, annotation -> events.put(annotation.value(), (EventSubscriber<? super Event>) subscriber));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void depriveSubscriber(EventSubscriber<?> subscriber) {
|
||||
checkSubscriber(subscriber, annotation -> events.remove(annotation.value(), (EventSubscriber<? super Event>) subscriber));
|
||||
}
|
||||
|
||||
private void checkSubscriber(EventSubscriber<?> subscriber, Consumer<SubscribesTo> consumer) {
|
||||
Optional<SubscribesTo> optional = ClassUtils.getAnnotation(subscriber.getClass(), SubscribesTo.class);
|
||||
Preconditions.checkArgument(optional.isPresent(), String.format("%s is not annotated with @SubscribesTo", subscriber.getClass()));
|
||||
consumer.accept(optional.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends Event> void post(Player player, E event) {
|
||||
Collection<EventSubscriber<? super Event>> subscribers = events.get(event.getClass());
|
||||
|
||||
for (EventSubscriber<? super Event> subscriber : subscribers) {
|
||||
/* Check to be sure we can subscribe to the event. */
|
||||
if (subscriber.test(event)) {
|
||||
subscriber.subscribe(context, player, event);
|
||||
|
||||
/* If the chain is broken, don't continue parsing subscribers. */
|
||||
if (context.isChainBroken()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.repairSubscriberChain();
|
||||
}
|
||||
|
||||
public Multimap<Class<? extends Event>, EventSubscriber<? super Event>> getEvents() {
|
||||
return events;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
/**
|
||||
* An event which manages button actions.
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public final class ButtonActionEvent implements Event {
|
||||
|
||||
/**
|
||||
* The id of the button.
|
||||
*/
|
||||
private final int button;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link ButtonActionEvent} with the specified button id.
|
||||
*
|
||||
* @param button The buttons id.
|
||||
*/
|
||||
public ButtonActionEvent(int button) {
|
||||
this.button = button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the buttons id.
|
||||
*/
|
||||
public int getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
/**
|
||||
* Represents a command event.
|
||||
*
|
||||
* @author Vult-R
|
||||
*/
|
||||
public final class CommandEvent implements Event {
|
||||
|
||||
/**
|
||||
* The name for this command.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The input for this command.
|
||||
*/
|
||||
private final String input;
|
||||
|
||||
/**
|
||||
* Creates the command.
|
||||
*/
|
||||
public CommandEvent(String name, String input) {
|
||||
this.name = name;
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of this command.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input for this command.
|
||||
*/
|
||||
public String getInput() {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public class DialogueEvent implements Event {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class DoorEvent implements Event {
|
||||
|
||||
private GameObject door;
|
||||
|
||||
public DoorEvent(GameObject door) {
|
||||
this.door = door;
|
||||
}
|
||||
|
||||
public GameObject getDoor() {
|
||||
return door;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.items.Item;
|
||||
|
||||
public final class ItemFirstClickEvent implements Event {
|
||||
|
||||
private final int item;
|
||||
|
||||
public ItemFirstClickEvent(int item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public int getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.items.Item;
|
||||
import com.rs2.game.players.Position;
|
||||
|
||||
public final class ItemOnGroundItemEvent implements Event {
|
||||
|
||||
private final Item used;
|
||||
|
||||
private final Item groundItem;
|
||||
|
||||
private final Position position;
|
||||
|
||||
public ItemOnGroundItemEvent(Item used, Item groundItem, Position position) {
|
||||
this.used = used;
|
||||
this.groundItem = groundItem;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public Item getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public Item getGroundItem() {
|
||||
return groundItem;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.items.Item;
|
||||
|
||||
public final class ItemOnItemEvent implements Event {
|
||||
|
||||
private final int used;
|
||||
|
||||
private final int with;
|
||||
|
||||
public ItemOnItemEvent(int used, int with) {
|
||||
this.used = used;
|
||||
this.with = with;
|
||||
}
|
||||
|
||||
public int getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public int getUsedWith() {
|
||||
return with;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.items.Item;
|
||||
import com.rs2.game.npcs.Npc;
|
||||
|
||||
public final class ItemOnNpcEvent implements Event {
|
||||
|
||||
private final int item;
|
||||
|
||||
private final int npc;
|
||||
|
||||
private final int clicked;
|
||||
|
||||
public ItemOnNpcEvent(int item, int npc, int clicked) {
|
||||
this.item = item;
|
||||
this.npc = npc;
|
||||
this.clicked = clicked;
|
||||
}
|
||||
|
||||
public int getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getNpc() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public int getNpcClicked() {
|
||||
return clicked;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.items.Item;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class ItemOnObjectEvent implements Event {
|
||||
|
||||
private final int item;
|
||||
|
||||
private final int gameObject;
|
||||
|
||||
public ItemOnObjectEvent(int item, int gameObject) {
|
||||
this.item = item;
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
public int getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getGameObject() {
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.items.Item;
|
||||
import com.rs2.game.players.Player;
|
||||
|
||||
public final class ItemOnPlayerEvent implements Event {
|
||||
|
||||
private final Item used;
|
||||
|
||||
private final Player usedWith;
|
||||
|
||||
public ItemOnPlayerEvent(Item used, Player usedWith) {
|
||||
this.used = used;
|
||||
this.usedWith = usedWith;
|
||||
}
|
||||
|
||||
public Item getUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public Player getUsedWith() {
|
||||
return usedWith;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class ItemSecondClickEvent implements Event {
|
||||
|
||||
|
||||
private final int id;
|
||||
|
||||
public ItemSecondClickEvent(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class ItemThirdClickEvent implements Event {
|
||||
|
||||
private final int id;
|
||||
|
||||
public ItemThirdClickEvent(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class MagicOnItemEvent implements Event {
|
||||
|
||||
private final int itemId;
|
||||
|
||||
private final int slot;
|
||||
|
||||
|
||||
private final int spellId;
|
||||
|
||||
public MagicOnItemEvent(int itemId, int slot, int spellId) {
|
||||
this.itemId = itemId;
|
||||
this.slot = slot;
|
||||
this.spellId = spellId;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public int getSpellId() {
|
||||
return spellId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class NpcFirstClickEvent implements Event {
|
||||
private final int npc;
|
||||
|
||||
public NpcFirstClickEvent(int npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public int getNpc() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.npcs.Npc;
|
||||
|
||||
public final class NpcSecondClickEvent implements Event {
|
||||
|
||||
private final int npc;
|
||||
|
||||
public NpcSecondClickEvent(int npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public int getNpc() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.game.npcs.Npc;
|
||||
|
||||
public final class NpcThirdClickEvent implements Event {
|
||||
|
||||
private final int npc;
|
||||
|
||||
public NpcThirdClickEvent(int npc) {
|
||||
this.npc = npc;
|
||||
}
|
||||
|
||||
public int getNpc() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class ObjectFifthClickEvent implements Event {
|
||||
|
||||
private final GameObject gameObject;
|
||||
|
||||
public ObjectFifthClickEvent(GameObject gameObject) {
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
public GameObject getGameObject() {
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class ObjectFirstClickEvent implements Event {
|
||||
|
||||
private final int gameObject;
|
||||
|
||||
public ObjectFirstClickEvent(int gameObject) {
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
public int getGameObject() {
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class ObjectFourthClickEvent implements Event {
|
||||
|
||||
private final int gameObject;
|
||||
|
||||
public ObjectFourthClickEvent(int gameObject) {
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
public int getGameObject() {
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class ObjectSecondClickEvent implements Event {
|
||||
|
||||
private final int gameObject;
|
||||
|
||||
public ObjectSecondClickEvent(int gameObject) {
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
public int getGameObject() {
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
import com.rs2.world.GameObject;
|
||||
|
||||
public final class ObjectThirdClickEvent implements Event {
|
||||
|
||||
private final int gameObject;
|
||||
|
||||
public ObjectThirdClickEvent(int gameObject) {
|
||||
this.gameObject = gameObject;
|
||||
}
|
||||
|
||||
public int getGameObject() {
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class WidgetContainerFirstOptionEvent implements Event {
|
||||
|
||||
private final int widgetId;
|
||||
|
||||
private final int itemSlot;
|
||||
|
||||
private final int itemId;
|
||||
|
||||
public WidgetContainerFirstOptionEvent(int widgetId, int itemId, int itemSlot) {
|
||||
this.widgetId = widgetId;
|
||||
this.itemId = itemId;
|
||||
this.itemSlot = itemSlot;
|
||||
}
|
||||
|
||||
public int getWidgetId() {
|
||||
return widgetId;
|
||||
}
|
||||
|
||||
public int getItemSlot() {
|
||||
return itemSlot;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class WidgetContainerFourthOptionEvent implements Event {
|
||||
|
||||
private final int widgetId;
|
||||
|
||||
private final int itemSlot;
|
||||
|
||||
private final int itemId;
|
||||
|
||||
public WidgetContainerFourthOptionEvent(int widgetId, int itemId, int itemSlot) {
|
||||
this.widgetId = widgetId;
|
||||
this.itemId = itemId;
|
||||
this.itemSlot = itemSlot;
|
||||
}
|
||||
|
||||
public int getWidgetId() {
|
||||
return widgetId;
|
||||
}
|
||||
|
||||
public int getItemSlot() {
|
||||
return itemSlot;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class WidgetContainerSecondOptionEvent implements Event {
|
||||
|
||||
private final int widgetId;
|
||||
|
||||
private final int itemSlot;
|
||||
|
||||
private final int itemId;
|
||||
|
||||
public WidgetContainerSecondOptionEvent(int widgetId, int itemId, int itemSlot) {
|
||||
this.widgetId = widgetId;
|
||||
this.itemId = itemId;
|
||||
this.itemSlot = itemSlot;
|
||||
}
|
||||
|
||||
public int getWidgetId() {
|
||||
return widgetId;
|
||||
}
|
||||
|
||||
public int getItemSlot() {
|
||||
return itemSlot;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.rs2.event.impl;
|
||||
|
||||
import com.rs2.event.Event;
|
||||
|
||||
public final class WidgetContainerThirdOptionEvent implements Event {
|
||||
|
||||
private final int widgetId;
|
||||
|
||||
private final int itemSlot;
|
||||
|
||||
private final int itemId;
|
||||
|
||||
public WidgetContainerThirdOptionEvent(int widgetId, int itemId, int itemSlot) {
|
||||
this.widgetId = widgetId;
|
||||
this.itemId = itemId;
|
||||
this.itemSlot = itemSlot;
|
||||
}
|
||||
|
||||
public int getWidgetId() {
|
||||
return widgetId;
|
||||
}
|
||||
|
||||
public int getItemSlot() {
|
||||
return itemSlot;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.game.items;
|
||||
|
||||
import com.rs2.event.impl.ItemOnItemEvent;
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.game.content.skills.cooking.Cooking;
|
||||
import com.rs2.game.content.skills.crafting.BattleStaffs;
|
||||
@@ -121,6 +122,8 @@ public class UseItem {
|
||||
}
|
||||
|
||||
public static void itemOnItem(Player player, int itemUsed, int useWith) {
|
||||
player.post(new ItemOnItemEvent(itemUsed, useWith));
|
||||
player.post(new ItemOnItemEvent(useWith, itemUsed));
|
||||
LogCuttingInterface.handleItemOnItem(player, itemUsed, useWith);
|
||||
ArrowMaking.makeArrow(player, itemUsed, useWith);
|
||||
Stringing.StringBow(player, itemUsed, useWith);
|
||||
@@ -218,11 +221,11 @@ public class UseItem {
|
||||
player.getItemAssistant().deleteItem(327, 1);
|
||||
player.getItemAssistant().addItem(1552, 1);
|
||||
}
|
||||
if (itemUsed == 38 && useWith == 590 || useWith == 38
|
||||
/*f (itemUsed == 38 && useWith == 590 || useWith == 38
|
||||
&& itemUsed == 590) {//
|
||||
player.getItemAssistant().addItem(32, 1);
|
||||
player.getItemAssistant().deleteItem(38, 1);
|
||||
}
|
||||
}*/
|
||||
if (itemUsed == 36 && useWith == 590 || useWith == 36
|
||||
&& itemUsed == 590) {
|
||||
player.getItemAssistant().addItem(33, 1);
|
||||
|
||||
@@ -40,20 +40,6 @@ public class NpcActions {
|
||||
}
|
||||
}
|
||||
switch (npcType) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6: //1-3 Man, 4-6 Woman - We are playing random dialogues here
|
||||
if (Misc.random(10) <= 5)
|
||||
{
|
||||
player.getDialogueHandler().sendDialogues(3869, npcType);
|
||||
}
|
||||
else {
|
||||
player.getDialogueHandler().sendDialogues(3872, npcType);
|
||||
}
|
||||
break;
|
||||
case 389 : //thormac
|
||||
player.getDialogueHandler().sendDialogues(3574, npcType);
|
||||
break;
|
||||
@@ -1064,10 +1050,6 @@ public class NpcActions {
|
||||
player.rememberNpcIndex = player.npcClickIndex;
|
||||
player.npcClickIndex = 0;
|
||||
Shops.openShop(player, npcType);
|
||||
if (Pickpocket.isNPC(player, npcType)) {
|
||||
Pickpocket.attemptPickpocket(player, npcType);
|
||||
return;
|
||||
}
|
||||
if (Fishing.fishingNPC(player, npcType)) {
|
||||
Fishing.fishingNPC(player, 2, npcType);
|
||||
}
|
||||
@@ -1083,13 +1065,9 @@ public class NpcActions {
|
||||
player.getFarmingTools().loadInterfaces();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
player.getDialogueHandler().sendDialogues(5, npcType);
|
||||
break;
|
||||
|
||||
case 209:
|
||||
/*case 209:
|
||||
player.getShopAssistant().openShop(144);
|
||||
break;
|
||||
break;*/
|
||||
|
||||
|
||||
case 2437:
|
||||
|
||||
@@ -115,10 +115,7 @@ public class ObjectsActions {
|
||||
PassDoor.processDoor(player, objectType);
|
||||
AbyssalHandler.handleAbyssalTeleport(player, objectType);
|
||||
OpenObject.interactObject(player, objectType);
|
||||
// if its a rock we can mine, mine it
|
||||
if (Mining.rockExists(objectType))
|
||||
player.getMining().startMining(player, objectType, player.objectX, player.objectY, player.clickObjectType);
|
||||
if (Stalls.isObject(objectType)) {
|
||||
if (Stalls.isObject(objectType)) {
|
||||
Stalls.attemptStall(player, objectType, objectX, objectY);
|
||||
return;
|
||||
}
|
||||
@@ -2775,10 +2772,6 @@ public class ObjectsActions {
|
||||
if (!Region.objectExists(objectType, obX, obY, player.heightLevel)) {
|
||||
return;
|
||||
}
|
||||
if (Stalls.isObject(objectType)) {
|
||||
Stalls.attemptStall(player, objectType, obX, obY);
|
||||
return;
|
||||
}
|
||||
if (Farming.inspectObject(player, obX, obY)) {
|
||||
return;
|
||||
}
|
||||
@@ -3052,10 +3045,6 @@ public class ObjectsActions {
|
||||
if (!Region.objectExists(objectType, obX, obY, player.heightLevel)) {
|
||||
return;
|
||||
}
|
||||
if (Stalls.isObject(objectType)) {
|
||||
Stalls.attemptStall(player, objectType, obX, obY);
|
||||
return;
|
||||
}
|
||||
OpenObject.interactObject(player, objectType);
|
||||
switch (objectType) {
|
||||
case 6:
|
||||
@@ -3073,9 +3062,6 @@ public class ObjectsActions {
|
||||
Climbing.climbDown(player);
|
||||
}
|
||||
break;
|
||||
case 10177:
|
||||
player.getPlayerAssistant().movePlayer(1798, 4407, 3);
|
||||
break;
|
||||
case 11890:
|
||||
Climbing.handleClimbing(player);
|
||||
break;
|
||||
@@ -3098,6 +3084,5 @@ public class ObjectsActions {
|
||||
if (!Region.objectExists(objectType, obX, obY, player.heightLevel)) {
|
||||
return;
|
||||
}
|
||||
Farming.guide(player, obX, obY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,11 @@ import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
import com.everythingrs.hiscores.Hiscores;
|
||||
import com.rs2.event.*;
|
||||
import com.rs2.plugin.PluginService;
|
||||
import org.apache.mina.common.IoSession;
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.GameEngine;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.game.content.BankPin;
|
||||
import com.rs2.game.content.EmoteHandler;
|
||||
import com.rs2.game.content.combat.CombatAssistant;
|
||||
@@ -742,6 +741,68 @@ public abstract class Player {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This worlds event provider.
|
||||
*/
|
||||
private static final UniversalEventProvider eventProvider = new UniversalEventProvider();
|
||||
|
||||
/**
|
||||
* The service for plugins.
|
||||
*/
|
||||
private static final PluginService pluginService = new PluginService();
|
||||
|
||||
/**
|
||||
* Posts an event to this worlds event provider.
|
||||
*
|
||||
* @param player
|
||||
* The player to post the event for.
|
||||
* @param event
|
||||
* The event to post.
|
||||
*/
|
||||
public <E extends Event> void post(Player player, E event) {
|
||||
eventProvider.post(player, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Posts an event to this world's event provider.
|
||||
*
|
||||
* @param event
|
||||
* The event to post.
|
||||
*/
|
||||
public <E extends Event> void post(E event) {
|
||||
post(this, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an event subscriber to this worlds event provider.
|
||||
*
|
||||
* @param subscriber
|
||||
* The event subscriber.
|
||||
*/
|
||||
public static <E extends Event> void provideSubscriber(EventSubscriber<E> subscriber) {
|
||||
eventProvider.provideSubscriber(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprives an event subscriber to this worlds event provider.
|
||||
*
|
||||
* @param subscriber
|
||||
* The event subscriber.
|
||||
*/
|
||||
public <E extends Event> void depriveSubscriber(EventSubscriber<E> subscriber) {
|
||||
eventProvider.depriveSubscriber(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service for plugins.
|
||||
*/
|
||||
public static PluginService getPluginService() {
|
||||
return pluginService;
|
||||
}
|
||||
|
||||
public UniversalEventProvider getSubscribers() {
|
||||
return eventProvider;
|
||||
}
|
||||
|
||||
public int packetSize = 0, packetType = -1;
|
||||
public boolean wildernessWarning;
|
||||
|
||||
@@ -1227,12 +1227,6 @@ public class PlayerAssistant {
|
||||
}
|
||||
break;
|
||||
|
||||
case 1173:
|
||||
if (!Superheat.superHeatItem(player, itemId)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1155: // Lvl-1 enchant sapphire
|
||||
case 1165: // Lvl-2 enchant emerald
|
||||
case 1176: // Lvl-3 enchant ruby
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.GameEngine;
|
||||
import com.rs2.event.impl.ItemFirstClickEvent;
|
||||
import com.rs2.game.content.consumables.Beverages;
|
||||
import com.rs2.game.content.consumables.Kebabs;
|
||||
import com.rs2.game.content.consumables.Beverages.beverageData;
|
||||
@@ -37,6 +38,7 @@ public class ClickItem implements PacketType {
|
||||
if(!player.getItemAssistant().playerHasItem(itemId, 1)) {
|
||||
return;
|
||||
}
|
||||
player.post(new ItemFirstClickEvent(itemId));
|
||||
GodBooks.sendPreachOptions(player, itemId);
|
||||
if (itemId == 6) {
|
||||
player.getCannon().placeCannon();
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.rs2.net.packets.impl;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.event.impl.NpcFirstClickEvent;
|
||||
import com.rs2.event.impl.NpcSecondClickEvent;
|
||||
import com.rs2.event.impl.NpcThirdClickEvent;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.content.combat.magic.MagicData;
|
||||
import com.rs2.game.content.combat.range.RangeData;
|
||||
@@ -229,6 +232,7 @@ public class ClickNPC implements PacketType {
|
||||
case FIRST_CLICK:
|
||||
player.npcClickIndex = player.inStream.readSignedWordBigEndian();
|
||||
player.npcType = NpcHandler.npcs[player.npcClickIndex].npcType;
|
||||
|
||||
if (player.goodDistance(NpcHandler.npcs[player.npcClickIndex].getX(),
|
||||
NpcHandler.npcs[player.npcClickIndex].getY(), player.getX(),
|
||||
player.getY(), 2)) {
|
||||
@@ -236,6 +240,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player.playerId);
|
||||
player.getNpcs().firstClickNpc(player.npcType);
|
||||
player.post(new NpcFirstClickEvent(player.npcType));
|
||||
} else {
|
||||
player.clickNpcType = 1;
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@@ -252,6 +257,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex]
|
||||
.facePlayer(player.playerId);
|
||||
player.getNpcs().firstClickNpc(player.npcType);
|
||||
player.post(new NpcFirstClickEvent(player.npcType));
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
@@ -277,6 +283,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player.playerId);
|
||||
player.getNpcs().secondClickNpc(player.npcType);
|
||||
player.post(new NpcSecondClickEvent(player.npcType));
|
||||
} else {
|
||||
player.clickNpcType = 2;
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@@ -293,6 +300,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex]
|
||||
.facePlayer(player.playerId);
|
||||
player.getNpcs().secondClickNpc(player.npcType);
|
||||
player.post(new NpcSecondClickEvent(player.npcType));
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
@@ -319,6 +327,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex].getY());
|
||||
NpcHandler.npcs[player.npcClickIndex].facePlayer(player.playerId);
|
||||
player.getNpcs().thirdClickNpc(player.npcType);
|
||||
player.post(new NpcThirdClickEvent(player.npcType));
|
||||
} else {
|
||||
player.clickNpcType = 3;
|
||||
CycleEventHandler.getSingleton().addEvent(player, new CycleEvent() {
|
||||
@@ -335,6 +344,7 @@ public class ClickNPC implements PacketType {
|
||||
NpcHandler.npcs[player.npcClickIndex]
|
||||
.facePlayer(player.playerId);
|
||||
player.getNpcs().thirdClickNpc(player.npcType);
|
||||
player.post(new NpcThirdClickEvent(player.npcType));
|
||||
container.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import com.rs2.GameEngine;
|
||||
import com.rs2.event.CycleEvent;
|
||||
import com.rs2.event.CycleEventContainer;
|
||||
import com.rs2.event.CycleEventHandler;
|
||||
import com.rs2.event.impl.ObjectFirstClickEvent;
|
||||
import com.rs2.event.impl.ObjectFourthClickEvent;
|
||||
import com.rs2.event.impl.ObjectSecondClickEvent;
|
||||
import com.rs2.event.impl.ObjectThirdClickEvent;
|
||||
import com.rs2.game.content.minigames.castlewars.CastleWarObjects;
|
||||
import com.rs2.game.content.minigames.castlewars.CastleWars;
|
||||
import com.rs2.game.content.skills.woodcutting.Woodcutting;
|
||||
@@ -410,6 +414,7 @@ public class ClickObject implements PacketType {
|
||||
break;
|
||||
}
|
||||
player.getObjects().firstClickObject(player.objectId, player.objectX, player.objectY);
|
||||
player.post(new ObjectFirstClickEvent(player.objectId));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -417,6 +422,7 @@ public class ClickObject implements PacketType {
|
||||
player.getPacketSender().sendMessage("ObjectId: " + player.objectId + " ObjectX: " + player.objectX + " ObjectY: " + player.objectY + " Objectclick = 2, Xoff: " + (player.getX() - player.objectX) + " Yoff: " + (player.getY() - player.objectY));
|
||||
}
|
||||
player.getObjects().secondClickObject(player.objectId, player.objectX, player.objectY);
|
||||
player.post(new ObjectSecondClickEvent(player.objectId));
|
||||
break;
|
||||
|
||||
case 3: // 'F'
|
||||
@@ -425,6 +431,7 @@ public class ClickObject implements PacketType {
|
||||
}
|
||||
|
||||
player.getObjects().thirdClickObject(player.objectId, player.objectX, player.objectY);
|
||||
player.post(new ObjectThirdClickEvent(player.objectId));
|
||||
break;
|
||||
|
||||
|
||||
@@ -434,6 +441,7 @@ public class ClickObject implements PacketType {
|
||||
}
|
||||
|
||||
player.getObjects().fourthClickObject(player.objectId, player.objectX, player.objectY);
|
||||
player.post(new ObjectFourthClickEvent(player.objectId));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.event.impl.ButtonActionEvent;
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.game.content.combat.CombatConstants;
|
||||
import com.rs2.game.content.combat.Specials;
|
||||
@@ -81,6 +82,8 @@ public class ClickingButtons implements PacketType {
|
||||
if (player.isAutoButton(actionButtonId)) {
|
||||
player.assignAutocast(actionButtonId);
|
||||
}
|
||||
player.post(new ButtonActionEvent(actionButtonId));
|
||||
|
||||
switch (actionButtonId) {
|
||||
case 23132:
|
||||
player.getPlayerAssistant().unMorphPlayer();
|
||||
@@ -1193,10 +1196,6 @@ public class ClickingButtons implements PacketType {
|
||||
player.getPacketSender().sendConfig(173, 0);
|
||||
break;
|
||||
|
||||
case 9154:
|
||||
player.logout();
|
||||
break;
|
||||
|
||||
case 21010:
|
||||
if (player.isBanking) {
|
||||
player.takeAsNote = true;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.event.impl.ItemSecondClickEvent;
|
||||
import com.rs2.game.items.impl.HandleEmpty;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.net.packets.PacketType;
|
||||
@@ -20,16 +21,10 @@ public class ItemClick2 implements PacketType {
|
||||
}
|
||||
|
||||
player.endCurrentTask();
|
||||
player.post(new ItemSecondClickEvent(itemId));
|
||||
|
||||
if (HandleEmpty.canEmpty(player, itemId)) {
|
||||
HandleEmpty.handleEmptyItem(player, itemId, HandleEmpty.filledToEmpty(player, itemId));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (itemId) {
|
||||
case 4079:
|
||||
player.startAnimation(1459);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.event.impl.ItemThirdClickEvent;
|
||||
import com.rs2.game.content.skills.runecrafting.Runecrafting;
|
||||
import com.rs2.game.items.impl.HandleEmpty;
|
||||
import com.rs2.game.items.impl.Teles;
|
||||
@@ -23,6 +24,7 @@ public class ItemClick3 implements PacketType {
|
||||
if (!player.getItemAssistant().playerHasItem(itemId, 1)) {
|
||||
return;
|
||||
}
|
||||
player.post(new ItemThirdClickEvent(itemId));
|
||||
if (HandleEmpty.canEmpty(player, itemId)) {
|
||||
HandleEmpty.handleEmptyItem(player, itemId, HandleEmpty.filledToEmpty(player, itemId));
|
||||
return;
|
||||
@@ -52,9 +54,6 @@ public class ItemClick3 implements PacketType {
|
||||
case 1448:// Mind Talisman
|
||||
Runecrafting.locate(player, 2982, 3514);
|
||||
break;
|
||||
case 4079:
|
||||
player.startAnimation(1460);
|
||||
break;
|
||||
|
||||
case 2552:
|
||||
case 2554:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.event.impl.ItemOnNpcEvent;
|
||||
import com.rs2.game.content.skills.SkillHandler;
|
||||
import com.rs2.game.items.UseItem;
|
||||
import com.rs2.game.npcs.NpcHandler;
|
||||
@@ -27,6 +28,7 @@ public class ItemOnNpc implements PacketType {
|
||||
return;
|
||||
}
|
||||
player.faceNpc(i);
|
||||
player.post(new ItemOnNpcEvent(itemId,npcId, i));
|
||||
switch(npcId) {
|
||||
case 3021:
|
||||
if (player.getFarmingTools().noteItem(itemId)) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.event.impl.ItemOnObjectEvent;
|
||||
import com.rs2.GameConstants;
|
||||
import com.rs2.game.content.combat.range.DwarfCannon;
|
||||
import com.rs2.game.content.skills.cooking.Cooking;
|
||||
@@ -49,6 +50,7 @@ public class ItemOnObject implements PacketType {
|
||||
"Object Id:" + objectId + " ObjectX: " + objectX
|
||||
+ " ObjectY: " + objectY + ".");
|
||||
}
|
||||
player.post(new ItemOnObjectEvent(itemId, objectId));
|
||||
switch (objectId) {
|
||||
case 3044:
|
||||
if (itemId == 438 || itemId == 436) {
|
||||
@@ -213,15 +215,6 @@ public class ItemOnObject implements PacketType {
|
||||
player.getPlayerAssistant().movePlayer(2510, 3096, 0);
|
||||
}
|
||||
|
||||
if (Fillables.canFill(itemId, objectId) && player.getItemAssistant().playerHasItem(itemId)) {
|
||||
int amount = player.getItemAssistant().getItemAmount(itemId);
|
||||
player.getItemAssistant().deleteItem(itemId, amount);
|
||||
player.getItemAssistant().addItem(Fillables.counterpart(itemId), amount);
|
||||
player.getPacketSender().sendMessage(Fillables.fillMessage(itemId, objectId));
|
||||
player.startAnimation(832);
|
||||
return;
|
||||
}
|
||||
|
||||
UseItem.itemOnObject(player, objectId, objectX, objectY, itemId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.rs2.net.packets.impl;
|
||||
|
||||
import com.rs2.event.impl.MagicOnItemEvent;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.net.packets.PacketType;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class MagicOnItems implements PacketType {
|
||||
}
|
||||
player.usingMagic = true;
|
||||
player.getPlayerAssistant().magicOnItems(slot, itemId, spellId);
|
||||
player.post(new MagicOnItemEvent(itemId, slot, spellId));
|
||||
player.usingMagic = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.rs2.plugin;
|
||||
|
||||
public final class PluginMetaData {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String description;
|
||||
|
||||
private final String group;
|
||||
|
||||
private final String base;
|
||||
|
||||
private final String[] authors;
|
||||
|
||||
private final double version;
|
||||
|
||||
public PluginMetaData(String name, String description, String group, String base, String[] authors, double version) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.group = group;
|
||||
this.base = base;
|
||||
this.authors = authors;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String[] getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public String getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public double getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.rs2.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.rs2.event.EventSubscriber;
|
||||
import com.rs2.game.players.Player;
|
||||
import com.rs2.util.LoggerUtils;
|
||||
|
||||
/**
|
||||
* The service that services plugins.
|
||||
*
|
||||
* @author Vult-R
|
||||
*/
|
||||
public final class PluginService {
|
||||
|
||||
/**
|
||||
* The single logger for this class.
|
||||
*/
|
||||
private static final Logger logger = LoggerUtils.getLogger(PluginService.class);
|
||||
|
||||
/**
|
||||
* The list of subscribers registered to the server.
|
||||
*/
|
||||
private static final List<EventSubscriber<?>> subscribers = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* The single instance of gson to deserialize the plugin meta data.
|
||||
*/
|
||||
private static final Gson gson = new GsonBuilder().create();
|
||||
|
||||
/**
|
||||
* Loads the plugins.
|
||||
*/
|
||||
public void load() {
|
||||
try {
|
||||
Collection<PluginMetaData[]> plugins = findPlugins();
|
||||
|
||||
plugins.stream().forEach($it -> register($it));
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.SEVERE, "A problem was encountered while trying to load plugins.", e);
|
||||
}
|
||||
logger.info("Loaded: " + subscribers.size() + " plugins.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds plugins in a given directory.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private Collection<PluginMetaData[]> findPlugins() throws IOException {
|
||||
return findPlugins(new File("./plugins/"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds plugins in a specified directory.
|
||||
*
|
||||
* @param dir
|
||||
* The directory to check for plugins.
|
||||
*
|
||||
* @throws IOException
|
||||
*
|
||||
* @return The collection of plugin data.
|
||||
*/
|
||||
private Collection<PluginMetaData[]> findPlugins(File dir) throws IOException {
|
||||
Collection<PluginMetaData[]> plugins = new ArrayList<>();
|
||||
for(File file : dir.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
|
||||
File json = new File(file, "plugins.json");
|
||||
|
||||
if (json.exists()) {
|
||||
PluginMetaData[] meta = gson.fromJson(new FileReader(json), PluginMetaData[].class);
|
||||
|
||||
plugins.add(meta);
|
||||
} else {
|
||||
plugins.addAll(findPlugins(file));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableCollection(plugins);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns a plugin to a subscriber
|
||||
*
|
||||
* @param metas
|
||||
* The meta deta for each plugin.
|
||||
*/
|
||||
private void register(PluginMetaData[] metas) {
|
||||
for(PluginMetaData meta : metas) {
|
||||
String base = meta.getBase();
|
||||
|
||||
Class<?> clazz;
|
||||
|
||||
try {
|
||||
|
||||
clazz = Class.forName(base);
|
||||
|
||||
} catch (Exception ex) {
|
||||
logger.warning(base + " could not be found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (EventSubscriber.class.isAssignableFrom(clazz)) {
|
||||
try {
|
||||
final EventSubscriber<?> subscriber = (EventSubscriber<?>) clazz.newInstance();
|
||||
|
||||
Player.provideSubscriber(subscriber);
|
||||
|
||||
subscribers.add(subscriber);
|
||||
} catch (Exception ex) {
|
||||
logger.warning(base + " could not be created.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads plugins.
|
||||
*/
|
||||
public void reload() {
|
||||
throw new UnsupportedOperationException("This is currently not supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of subscriber registered to the server.
|
||||
*/
|
||||
public List<EventSubscriber<?>> getSubscribers() {
|
||||
return subscribers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.rs2.util;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A static-utility class containing extension or helper methods for
|
||||
* {@link Class}es or generic objects.
|
||||
*
|
||||
* @author Ryley Kimmel <ryley.kimmel@live.com>
|
||||
*/
|
||||
public final class ClassUtils {
|
||||
|
||||
/**
|
||||
* Returns the specified {@link T annotation} for the potentially annotated
|
||||
* {@link Class class} if it exists.
|
||||
*
|
||||
* @param clazz The class to test contains the specified {@code annotation}.
|
||||
* @param annotation The annotation to check the specified {@code class}
|
||||
* for.
|
||||
* @return The {@code annotation} if and only if it exists otherwise
|
||||
* {@link Optional#empty()}.
|
||||
*/
|
||||
public static <T extends Annotation> Optional<T> getAnnotation(Class<?> clazz, Class<T> annotation) {
|
||||
return Optional.ofNullable(clazz.getAnnotation(annotation));
|
||||
}
|
||||
|
||||
/**
|
||||
* Suppresses the default-public constructor preventing this class from
|
||||
* being instantiated by other classes, instantiating this class from within
|
||||
* itself will throw an {@link UnsupportedOperationException}.
|
||||
*
|
||||
* @throws UnsupportedOperationException If this class is instantiated from
|
||||
* within itself.
|
||||
*/
|
||||
private ClassUtils() {
|
||||
throw new UnsupportedOperationException("static-utility classes may not be instantiated.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.rs2.util;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class LoggerUtils {
|
||||
|
||||
public static Logger getLogger(Class<?> clazz) {
|
||||
return Logger.getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user