Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faction relation change event implementation. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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? {
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}