Skip to content

Commit

Permalink
Merge pull request #148 from Exanthiax/master
Browse files Browse the repository at this point in the history
AxEnvoy & NuVotifier Integration
  • Loading branch information
WillFP authored Jul 3, 2024
2 parents 8c05ce0 + ec21341 commit 89a5bdc
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ dependencies {
compileOnly("com.willfp:eco:6.71.0")
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
compileOnly("net.kyori:adventure-text-minimessage:4.14.0")

compileOnly("com.github.Artillex-Studios:AxEnvoys:master")
compileOnly("com.github.NuVotifier:NuVotifier:2.7.2")
compileOnly("dev.aurelium:auraskills-api-bukkit:2.0.0")
compileOnly("com.github.Archy-X:AureliumSkills:Beta1.2.4")
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.1.202") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import com.willfp.libreforge.effects.arguments.custom.CustomEffectArguments
import com.willfp.libreforge.effects.impl.bossbar.BossBarProgressPlaceholder
import com.willfp.libreforge.integrations.auraskills.AuraSkillsIntegration
import com.willfp.libreforge.integrations.aureliumskills.AureliumSkillsIntegration
import com.willfp.libreforge.integrations.axenvoy.AxEnvoyIntegration
import com.willfp.libreforge.integrations.citizens.CitizensIntegration
import com.willfp.libreforge.integrations.votifier.VotifierIntegration
import com.willfp.libreforge.integrations.custombiomes.impl.CustomBiomesTerra
import com.willfp.libreforge.integrations.custombiomes.impl.CustomBiomesTerraformGenerator
import com.willfp.libreforge.integrations.jobs.JobsIntegration
Expand Down Expand Up @@ -184,6 +186,8 @@ class LibreforgeSpigotPlugin : EcoPlugin() {
IntegrationLoader("TAB") { TabIntegration.load(this) },
IntegrationLoader("Terra") { CustomBiomesTerra.load(this) },
IntegrationLoader("TerraformGenerator") { CustomBiomesTerraformGenerator.load(this) },
IntegrationLoader("AxEnvoy") { AxEnvoyIntegration.load(this) },
IntegrationLoader("Votifier") { VotifierIntegration.load(this)},
IntegrationLoader("ModelEngine") { ModelEngineIntegration.load(this) }
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.willfp.libreforge.integrations.axenvoy

import com.willfp.eco.core.EcoPlugin
import com.willfp.libreforge.filters.Filters
import com.willfp.libreforge.integrations.LoadableIntegration
import com.willfp.libreforge.integrations.axenvoy.impl.FilterEnvoyType
import com.willfp.libreforge.integrations.axenvoy.impl.TriggerCollectEnvoy
import com.willfp.libreforge.triggers.Triggers

object AxEnvoyIntegration : LoadableIntegration {
override fun load(plugin: EcoPlugin) {
Triggers.register(TriggerCollectEnvoy)
Filters.register(FilterEnvoyType)
}

override fun getPluginName(): String {
return "AxEnvoy"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.willfp.libreforge.integrations.axenvoy.impl

import com.artillexstudios.axenvoy.event.EnvoyCrateCollectEvent
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.libreforge.NoCompileData
import com.willfp.libreforge.filters.Filter
import com.willfp.libreforge.triggers.TriggerData

object FilterEnvoyType : Filter<NoCompileData, Collection<String>>("envoy_type") {
override fun getValue(config: Config, data: TriggerData?, key: String): Collection<String> {
return config.getStrings(key)
}

override fun isMet(data: TriggerData, value: Collection<String>, compileData: NoCompileData): Boolean {
val event = data.event as? EnvoyCrateCollectEvent ?: return true

val crateType = event.crate?.handle?.name ?: return true
return value.contains(crateType)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.willfp.libreforge.integrations.axenvoy.impl

import com.artillexstudios.axenvoy.event.EnvoyCrateCollectEvent
import com.willfp.libreforge.toDispatcher
import com.willfp.libreforge.triggers.Trigger
import com.willfp.libreforge.triggers.TriggerData
import com.willfp.libreforge.triggers.TriggerParameter
import org.bukkit.event.EventHandler

object TriggerCollectEnvoy : Trigger("collect_envoy") {
override val parameters = setOf(
TriggerParameter.PLAYER,
TriggerParameter.LOCATION,
TriggerParameter.EVENT,
TriggerParameter.TEXT
)

@EventHandler(ignoreCancelled = true)
fun handle(event: EnvoyCrateCollectEvent) {
val player = event.player ?: return
val crate = event.crate ?: return
val location = crate.finishLocation ?: return
val crateType = crate.handle?.name ?: return

this.dispatch(
player.toDispatcher(),
TriggerData(
player = player,
location = location,
event = event,
text = crateType
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.willfp.libreforge.integrations.votifier

import com.willfp.eco.core.EcoPlugin
import com.willfp.libreforge.filters.Filters
import com.willfp.libreforge.integrations.LoadableIntegration
import com.willfp.libreforge.integrations.votifier.impl.FilterVoteService
import com.willfp.libreforge.integrations.votifier.impl.TriggerRegisterVote
import com.willfp.libreforge.triggers.Triggers

object VotifierIntegration : LoadableIntegration {
override fun load(plugin: EcoPlugin) {
Triggers.register(TriggerRegisterVote)
Filters.register(FilterVoteService)
}

override fun getPluginName(): String {
return "Votifier"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.willfp.libreforge.integrations.votifier.impl

import com.vexsoftware.votifier.model.VotifierEvent
import com.willfp.eco.core.config.interfaces.Config
import com.willfp.libreforge.NoCompileData
import com.willfp.libreforge.filters.Filter
import com.willfp.libreforge.triggers.TriggerData

object FilterVoteService : Filter<NoCompileData, Collection<String>>("vote_service") {
override fun getValue(config: Config, data: TriggerData?, key: String): Collection<String> {
return config.getStrings(key)
}

override fun isMet(data: TriggerData, value: Collection<String>, compileData: NoCompileData): Boolean {
val event = data.event as? VotifierEvent ?: return true

val service = event.vote.serviceName ?: return true
return value.contains(service)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.willfp.libreforge.integrations.votifier.impl

import com.vexsoftware.votifier.model.VotifierEvent
import com.willfp.libreforge.toDispatcher
import com.willfp.libreforge.triggers.Trigger
import com.willfp.libreforge.triggers.TriggerData
import com.willfp.libreforge.triggers.TriggerParameter
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler

object TriggerRegisterVote : Trigger("register_vote") {
override val parameters = setOf(
TriggerParameter.PLAYER,
TriggerParameter.EVENT,
TriggerParameter.TEXT
)

@EventHandler(ignoreCancelled = true)
fun handle(event: VotifierEvent) {
val username = event.vote.username ?: return
val player = Bukkit.getPlayerExact(username) ?: return
val service = event.vote.serviceName ?: return

this.dispatch(
player.toDispatcher(),
TriggerData(
player = player,
event = event,
text = service
)
)
}
}
2 changes: 2 additions & 0 deletions core/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ softdepend:
- Terra
- TerraformGenerator
- ModelEngine
- AxEnvoy
- Votifier

commands:
lrcdb:
Expand Down

0 comments on commit 89a5bdc

Please sign in to comment.