From f72638c14bdfa93ecce9f82575e8e7f4ce6c860c Mon Sep 17 00:00:00 2001 From: ProSavage Date: Mon, 6 Sep 2021 14:48:42 -0500 Subject: [PATCH] faction relation change event implementation. --- .../net/prosavage/factionsx/core/Faction.kt | 3 +++ .../event/FactionRelationChangeEvent.kt | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 FactionsX/src/main/kotlin/net/prosavage/factionsx/event/FactionRelationChangeEvent.kt diff --git a/FactionsX/src/main/kotlin/net/prosavage/factionsx/core/Faction.kt b/FactionsX/src/main/kotlin/net/prosavage/factionsx/core/Faction.kt index 64cbcf8..eb43635 100644 --- a/FactionsX/src/main/kotlin/net/prosavage/factionsx/core/Faction.kt +++ b/FactionsX/src/main/kotlin/net/prosavage/factionsx/core/Faction.kt @@ -3,6 +3,7 @@ package net.prosavage.factionsx.core import com.cryptomorin.xseries.XMaterial import net.prosavage.factionsx.event.FPlayerFactionLeaveEvent import net.prosavage.factionsx.event.FPlayerFactionPreLeaveEvent +import net.prosavage.factionsx.event.FactionRelationChangeEvent import net.prosavage.factionsx.manager.* import net.prosavage.factionsx.manager.FactionManager.forceRelation import net.prosavage.factionsx.persist.Message @@ -530,6 +531,8 @@ data class Faction(val id: Long, var tag: String, val factionRoles: FactionRoles this.message(Message.relationNotifOrigin, toFactionTag, relationPrefix, tagReplacement) faction.message(Message.relationNotif, this.tag, relationPrefix, tagReplacement) + + Bukkit.getPluginManager().callEvent(FactionRelationChangeEvent(this, faction, currentRelation, relation)) } internal fun sendRelationRequest(faction: Faction, relation: Relation): Relation? { diff --git a/FactionsX/src/main/kotlin/net/prosavage/factionsx/event/FactionRelationChangeEvent.kt b/FactionsX/src/main/kotlin/net/prosavage/factionsx/event/FactionRelationChangeEvent.kt new file mode 100644 index 0000000..783ed21 --- /dev/null +++ b/FactionsX/src/main/kotlin/net/prosavage/factionsx/event/FactionRelationChangeEvent.kt @@ -0,0 +1,21 @@ +package net.prosavage.factionsx.event + +import net.prosavage.factionsx.core.Faction +import net.prosavage.factionsx.util.Relation +import org.bukkit.event.Event +import org.bukkit.event.HandlerList + +class FactionRelationChangeEvent( + val faction: Faction, + val factionTo: Faction, + val oldRelation: Relation, + val newRelation: Relation +) : Event(false) { + + override fun getHandlers(): HandlerList = handlerList + + companion object { + @JvmStatic + val handlerList = HandlerList() + } +} \ No newline at end of file