Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	eco-api/src/main/kotlin/com/willfp/libreforge/effects/effects/EffectCritMultiplier.kt
  • Loading branch information
WillFP committed Nov 22, 2021
2 parents 35c1507 + 906a934 commit 7cb76f9
Show file tree
Hide file tree
Showing 61 changed files with 1,389 additions and 739 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ java.sourceCompatibility = JavaVersion.VERSION_16
compileJava.options.encoding = 'UTF-8'

build.dependsOn shadowJar
build.dependsOn publishToMavenLocal
2 changes: 1 addition & 1 deletion eco-api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies {
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'

compileOnly 'com.willfp:EcoSkills:1.4.0'
compileOnly 'com.willfp:EcoSkills:1.11.8'
compileOnly 'com.github.Archy-X:AureliumSkills:Beta1.2.4'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.willfp.libreforge

import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.libreforge.effects.Effect
import java.util.Objects
import java.util.*

abstract class ConfigurableProperty(
val id: String
Expand Down Expand Up @@ -49,4 +49,4 @@ abstract class ConfigurableProperty(
override fun hashCode(): Int {
return Objects.hash(this.id)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.willfp.libreforge.provider
package com.willfp.libreforge

import com.willfp.libreforge.conditions.ConfiguredCondition
import com.willfp.libreforge.effects.ConfiguredEffect

interface Holder {
val effects: Set<ConfiguredEffect>
val conditions: Set<ConfiguredCondition>
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.willfp.libreforge.provider
package com.willfp.libreforge

import org.bukkit.entity.Player

interface HolderProvider {
fun providerHolders(player: Player): Iterable<Holder>
}
}
43 changes: 33 additions & 10 deletions eco-api/src/main/kotlin/com/willfp/libreforge/LibReforge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.integrations.IntegrationLoader
import com.willfp.eco.util.ListUtils
import com.willfp.libreforge.conditions.Conditions
import com.willfp.libreforge.effects.Effects
import com.willfp.libreforge.integrations.aureliumskills.AureliumSkillsIntegration
import com.willfp.libreforge.integrations.ecoskills.EcoSkillsIntegration
import com.willfp.libreforge.provider.Holder
import com.willfp.libreforge.provider.HolderProvider
import com.willfp.libreforge.triggers.Triggers
import com.willfp.libreforge.triggers.triggers.WatcherTriggers
import org.apache.commons.lang.StringUtils
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import java.util.UUID
import java.util.WeakHashMap
import org.bukkit.event.Listener
import java.util.*

private val holderProviders = mutableSetOf<HolderProvider>()
private val previousStates: MutableMap<UUID, Iterable<Holder>> = WeakHashMap()
Expand All @@ -41,15 +40,36 @@ object LibReforge {

@JvmStatic
fun enable(plugin: EcoPlugin) {
plugin.eventManager.registerListener(WatcherTriggers(plugin))
plugin.eventManager.registerListener(TridentHolderDataAttacher(plugin))
for (condition in Conditions.values()) {
plugin.eventManager.registerListener(condition)
}
for (effect in Effects.values()) {
if (effect is Listener) {
plugin.eventManager.registerListener(effect)
}
}
for (trigger in Triggers.values()) {
plugin.eventManager.registerListener(trigger)
}
}

@JvmStatic
@Suppress("UNUSED_PARAMETER")
fun disable(plugin: EcoPlugin) {
for (player in Bukkit.getOnlinePlayers()) {
try {
for (holder in player.getHolders()) {
for ((effect) in holder.effects) {
effect.disableForPlayer(player)
}
}
} catch (e: Exception) {
Bukkit.getLogger().warning("Error disabling effects, not important - do not report this")
}
}
}

@JvmStatic
fun getIntegrationLoaders(): List<IntegrationLoader> {
return listOf(
Expand All @@ -63,10 +83,13 @@ object LibReforge {
holderProviders.add(provider)
}

fun logViolation(id: String, context: String, violation: com.willfp.libreforge.ConfigViolation) {
LibReforge.plugin.logger.warning("Invalid configuration for $id in context $context:")
LibReforge.plugin.logger.warning("(Cause) Argument ${violation.param}")
LibReforge.plugin.logger.warning("(Reason) ${violation.message}")
@JvmStatic
fun logViolation(id: String, context: String, violation: ConfigViolation) {
plugin.logger.warning("")
plugin.logger.warning("Invalid configuration for $id in context $context:")
plugin.logger.warning("(Cause) Argument '${violation.param}'")
plugin.logger.warning("(Reason) ${violation.message}")
plugin.logger.warning("")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.willfp.libreforge

import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.integrations.mcmmo.McmmoManager
import org.bukkit.entity.Player
import org.bukkit.entity.Trident
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.ProjectileLaunchEvent

class TridentHolderDataAttacher(
private val plugin: EcoPlugin
) : Listener {
@EventHandler(ignoreCancelled = true)
fun onProjectileLaunch(event: ProjectileLaunchEvent) {
if (McmmoManager.isFake(event)) {
return
}

val shooter = event.entity.shooter

if (shooter !is Player) {
return
}

val trident = event.entity

if (trident !is Trident) {
return
}

trident.setMetadata(
"${plugin.name.lowercase()}_trident_holders",
plugin.metadataValueFactory.create(
shooter.getHolders()
)
)
}
}

fun Trident.getAttachedHolders(): Iterable<Holder> {
@Suppress("UNCHECKED_CAST")
return this.getMetadata("${LibReforge.plugin.name.lowercase()}_trident_holders")
.firstOrNull() as? Iterable<Holder> ?: emptyList()
}
Loading

0 comments on commit 7cb76f9

Please sign in to comment.