Added support to fire off a discord alert to a webhook (set in server config as server.openrsc_integration_webhook) when Wormbrain's map piece is collected so that rsc plate pures are possible

This commit is contained in:
Ceikry
2023-03-02 12:53:12 +00:00
committed by Ryan
parent 35e1477c24
commit 97f4fa91ca
11 changed files with 531 additions and 354 deletions
+3
View File
@@ -260,6 +260,9 @@ class ServerConstants {
@JvmField
var DISCORD_MOD_WEBHOOK = ""
@JvmField
var DISCORD_OPENRSC_HOOK = ""
@JvmField
var PRELOAD_MAP = false
+1 -1
View File
@@ -32,7 +32,7 @@ data class InterfaceOpenEvent(val component: Component) : Event
data class InterfaceCloseEvent(val component: Component) : Event
data class AttributeSetEvent(val entity: Entity, val attribute: String, val value: Any) : Event
data class AttributeRemoveEvent(val entity: Entity, val attribute: String) : Event
data class SpellCastEvent(val spellBook: SpellBook, val spellId: Int) : Event
data class SpellCastEvent(val spellBook: SpellBook, val spellId: Int, val target: Node? = null) : Event
data class ItemAlchemizationEvent(val itemId: Int, val isHigh: Boolean) : Event
data class ItemEquipEvent(val itemId: Int, val slotId: Int) : Event
data class ItemUnequipEvent(val itemId: Int, val slotId: Int) : Event
@@ -198,7 +198,8 @@ public abstract class Entity extends Node {
{
hookList = new ArrayList<EventHook>();
}
hookList.add(hook);
if (!hookList.contains(hook))
hookList.add(hook);
hooks.put(event, hookList);
}
@@ -1,6 +1,7 @@
package core.game.node.entity.combat.spell;
import core.game.component.Component;
import core.game.event.SpellCastEvent;
import core.game.node.entity.skill.Skills;
import core.game.node.Node;
import core.game.node.entity.Entity;
@@ -131,6 +132,7 @@ public abstract class MagicSpell implements Plugin<SpellType> {
if (p.getAttribute("magic-delay", 0) <= GameWorld.getTicks()) {
p.setAttribute("magic-delay", GameWorld.getTicks() + spell.getDelay());
}
p.dispatch(new SpellCastEvent(book, spellId, target));
return true;
}
return false;
@@ -145,6 +145,7 @@ object ServerConfigParser {
ServerConstants.DISCORD_MOD_WEBHOOK = data.getString("server.moderation_webhook", "")
ServerConstants.NOAUTH_DEFAULT_ADMIN = data.getBoolean("server.noauth_default_admin", false)
ServerConstants.DRAGON_AXE_USE_OSRS_SPEC = data.getBoolean("world.dragon_axe_use_osrs_spec", false)
ServerConstants.DISCORD_OPENRSC_HOOK = data.getString("server.openrsc_integration_webhook", "")
ServerConstants.ENABLE_GLOBALCHAT = data.getBoolean("world.enable_globalchat", true)
val logLevel = data.getString("server.log_level", "VERBOSE").uppercase()
@@ -55,6 +55,18 @@ object Discord {
}
}
@JvmStatic fun sendToOpenRSC(player: String, type: String) {
if (ServerConstants.DISCORD_OPENRSC_HOOK.isEmpty()) return
GlobalScope.launch {
val alert = encodeUserAlert(type, player)
try {
sendJsonPost(ServerConstants.DISCORD_OPENRSC_HOOK, alert)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
private fun encodeUpdateJson(sale: Boolean, itemId: Int, value: Int, amtLeft: Int): String {
val obj = JSONObject()
val embeds = JSONArray()