From 70bb5949569e86d6760fe9cbc24dcc2815e87553 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:07:34 +0100 Subject: [PATCH 1/3] AxEnvoy Integration --- core/build.gradle.kts | 2 +- .../libreforge/LibreforgeSpigotPlugin.kt | 2 ++ .../axenvoy/AxEnvoyIntegration.kt | 19 ++++++++++ .../axenvoy/impl/FilterEnvoyType.kt | 20 +++++++++++ .../axenvoy/impl/TriggerCollectEnvoy.kt | 35 +++++++++++++++++++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/AxEnvoyIntegration.kt create mode 100644 core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/FilterEnvoyType.kt create mode 100644 core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/TriggerCollectEnvoy.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 9abcda2c..620fc330 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -7,7 +7,7 @@ dependencies { compileOnly("com.willfp:eco:6.69.0") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("net.kyori:adventure-text-minimessage:4.14.0") - + compileOnly("com.github.Artillex-Studios:AxEnvoys:master") 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") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt index 2c226150..252b9d20 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt @@ -13,6 +13,7 @@ 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.custombiomes.impl.CustomBiomesTerra import com.willfp.libreforge.integrations.custombiomes.impl.CustomBiomesTerraformGenerator @@ -178,6 +179,7 @@ class LibreforgeSpigotPlugin : EcoPlugin() { IntegrationLoader("TAB") { TabIntegration.load(this) }, IntegrationLoader("Terra") { CustomBiomesTerra.load(this) }, IntegrationLoader("TerraformGenerator") { CustomBiomesTerraformGenerator.load(this) }, + IntegrationLoader("AxEnvoy") { AxEnvoyIntegration.load(this) }, IntegrationLoader("ModelEngine") { ModelEngineIntegration.load(this) } ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/AxEnvoyIntegration.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/AxEnvoyIntegration.kt new file mode 100644 index 00000000..3a64d834 --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/AxEnvoyIntegration.kt @@ -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" + } +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/FilterEnvoyType.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/FilterEnvoyType.kt new file mode 100644 index 00000000..d916535e --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/FilterEnvoyType.kt @@ -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>("envoy_type") { + override fun getValue(config: Config, data: TriggerData?, key: String): Collection { + return config.getStrings(key) + } + + override fun isMet(data: TriggerData, value: Collection, compileData: NoCompileData): Boolean { + val event = data.event as? EnvoyCrateCollectEvent ?: return true + + val crateType = event.crate?.handle?.name ?: return true + return value.contains(crateType) + } +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/TriggerCollectEnvoy.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/TriggerCollectEnvoy.kt new file mode 100644 index 00000000..a5ede44e --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/axenvoy/impl/TriggerCollectEnvoy.kt @@ -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 + ) + ) + } +} \ No newline at end of file From a4fedb824c4b54abd922b33f4a93269f9735d06b Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:56:10 +0100 Subject: [PATCH 2/3] Update plugin.yml --- core/src/main/resources/plugin.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index a241eda4..ce30028f 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -26,6 +26,7 @@ softdepend: - Terra - TerraformGenerator - ModelEngine + - AxEnvoy commands: lrcdb: From ec2134171b8907ac8f347a2f93846bf1c9454fd8 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Wed, 1 May 2024 01:04:23 +0100 Subject: [PATCH 3/3] Votifier (NuVotifier) Integration --- core/build.gradle.kts | 1 + .../libreforge/LibreforgeSpigotPlugin.kt | 2 ++ .../votifier/VotifierIntegration.kt | 19 +++++++++++ .../votifier/impl/FilterVoteService.kt | 20 +++++++++++ .../votifier/impl/TriggerRegisterVote.kt | 33 +++++++++++++++++++ core/src/main/resources/plugin.yml | 1 + 6 files changed, 76 insertions(+) create mode 100644 core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/VotifierIntegration.kt create mode 100644 core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/FilterVoteService.kt create mode 100644 core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/TriggerRegisterVote.kt diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 620fc330..dde5d4cc 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -8,6 +8,7 @@ dependencies { compileOnly("io.papermc.paper:paper-api:1.20.1-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") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt index 252b9d20..cb02c116 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt @@ -15,6 +15,7 @@ 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 @@ -180,6 +181,7 @@ class LibreforgeSpigotPlugin : EcoPlugin() { 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) } ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/VotifierIntegration.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/VotifierIntegration.kt new file mode 100644 index 00000000..b4dbd8e2 --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/VotifierIntegration.kt @@ -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" + } +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/FilterVoteService.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/FilterVoteService.kt new file mode 100644 index 00000000..71cc4d4e --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/FilterVoteService.kt @@ -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>("vote_service") { + override fun getValue(config: Config, data: TriggerData?, key: String): Collection { + return config.getStrings(key) + } + + override fun isMet(data: TriggerData, value: Collection, compileData: NoCompileData): Boolean { + val event = data.event as? VotifierEvent ?: return true + + val service = event.vote.serviceName ?: return true + return value.contains(service) + } +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/TriggerRegisterVote.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/TriggerRegisterVote.kt new file mode 100644 index 00000000..8118b92d --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/votifier/impl/TriggerRegisterVote.kt @@ -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 + ) + ) + } +} diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index ce30028f..2225c536 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -27,6 +27,7 @@ softdepend: - TerraformGenerator - ModelEngine - AxEnvoy + - Votifier commands: lrcdb: