9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-04 15:41:36 +00:00

Merge pull request #120 from 0ft3n/master

Added ability to specify libreforge conditions for non-custom effects
This commit is contained in:
Will FP
2022-10-09 14:50:41 +01:00
committed by GitHub
29 changed files with 163 additions and 1 deletions

View File

@@ -46,7 +46,7 @@ allprojects {
}
dependencies {
compileOnly 'com.willfp:eco:6.42.0'
compileOnly 'com.willfp:eco:6.43.6'
implementation 'com.willfp:libreforge:3.110.0'
implementation 'org.joml:joml:1.10.4'
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])

View File

@@ -9,7 +9,9 @@ import com.willfp.eco.util.StringUtils
import com.willfp.ecoskills.EcoSkillsPlugin
import com.willfp.ecoskills.SkillObject
import com.willfp.ecoskills.getEffectLevel
import com.willfp.libreforge.conditions.Conditions
import org.bukkit.NamespacedKey
import org.bukkit.entity.Player
import org.bukkit.event.Listener
import java.util.*
@@ -74,4 +76,9 @@ abstract class Effect(
"${id}_description"
) { player -> this.getDescription(player.getEffectLevel(this)) }.register()
}
protected fun checkConditions(player: Player): Boolean {
return this.config.getSubsections("conditions").map { Conditions.compile(it,
"Condition for effect: ${this.key.key}") }.all { it?.isMet(player)?: true }
}
}

View File

@@ -29,6 +29,10 @@ class EffectAcceleratedEscape: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
val modifier = AttributeModifier(

View File

@@ -30,6 +30,10 @@ class EffectBountifulHarvest : DropMultiplierEffect(
return
}
if (!this.checkConditions(event.player)) {
return
}
val mat = blockMap[event.block.location] ?: return
val state = event.blockState.blockData as? Ageable ?: return

View File

@@ -32,6 +32,10 @@ class EffectBravery: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (event.damager !is Boss && event.damager !is ElderGuardian
&& !event.damager.persistentDataContainer.has(NamespacedKeyUtils.create("ecobosses", "boss"), PersistentDataType.STRING)) {
return

View File

@@ -22,6 +22,10 @@ class EffectCraftsmanship : Effect(
val player = event.player
if (!this.checkConditions(player)) {
return
}
if (!event.item.type.toString().lowercase().contains("axe")) {
return
}

View File

@@ -30,6 +30,10 @@ class EffectDazzle : Effect(
val player = event.damager.tryAsPlayer() ?: return
val victim = if (event.entity is LivingEntity) event.entity as LivingEntity else return
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
if (NumberUtils.randFloat(0.0, 100.0) >= config.getDouble("chance-per-level") * level) {

View File

@@ -27,6 +27,10 @@ class EffectDodging: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (event.cause == EntityDamageEvent.DamageCause.FALL) {
return
}

View File

@@ -28,6 +28,10 @@ class EffectDynamicMining : Effect(
val player = event.player
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
if (NumberUtils.randFloat(0.0, 100.0) >= config.getDouble("chance-per-level") * level) {

View File

@@ -29,6 +29,10 @@ class EffectEfficientBrewing : Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (player.getEffectLevel(this) == 0) {
return
}

View File

@@ -26,6 +26,10 @@ class EffectEndangering : Effect(
val player = event.damager.tryAsPlayer() ?: return
val victim = if (event.entity is LivingEntity) event.entity as LivingEntity else return
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
if (NumberUtils.randFloat(0.0, 100.0) >= config.getDouble("chance-per-level") * level) {

View File

@@ -32,6 +32,10 @@ class EffectEyeOfTheDepths: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
val chance = config.getDouble("chance-per-level") * level

View File

@@ -26,6 +26,10 @@ class EffectGoldenYield: Effect(
val block = event.block
val player = event.player
if (!this.checkConditions(player)) {
return
}
val data = block.blockData
if (data !is Ageable) {

View File

@@ -27,6 +27,10 @@ class EffectInfernalResistance: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (event.cause != EntityDamageEvent.DamageCause.FIRE
&& event.cause != EntityDamageEvent.DamageCause.FIRE_TICK
&& event.cause != EntityDamageEvent.DamageCause.LAVA

View File

@@ -26,6 +26,10 @@ class EffectMagneticRod : Effect(
val player = event.player
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
if (level == 0) {

View File

@@ -34,6 +34,10 @@ class EffectMasterLumberjack : DropMultiplierEffect(
val player = event.player
if (!this.checkConditions(player)) {
return
}
val block = event.block
if (BlockUtils.isPlayerPlaced(block)) {

View File

@@ -28,6 +28,10 @@ class EffectMysticResilience : Effect(
return
}
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
if (NumberUtils.randFloat(0.0, 100.0) >= this.config.getDouble("chance-per-level") * level) {

View File

@@ -26,6 +26,10 @@ class EffectOvercompensation : Effect(
val player = event.enchanter
val cost = event.whichButton() + 1
if (!this.checkConditions(player)) {
return
}
val chance = config.getDouble("chance-per-level") * player.getEffectLevel(this)
if (NumberUtils.randFloat(0.0, 100.0) < chance) {

View File

@@ -34,6 +34,10 @@ class EffectPotionmaster : Effect(
val player = event.contents.viewers.filterIsInstance<Player>().firstOrNull() ?: return
if (!this.checkConditions(player)) {
return
}
if (player.getEffectLevel(this) == 0) {
return
}

View File

@@ -21,6 +21,9 @@ class EffectReimbursement : Effect(
}
val player = event.enchanter
if (!this.checkConditions(player)) {
return
}
val cost = event.whichButton()+1
val chance = config.getDouble("chance-per-level") * player.getEffectLevel(this)

View File

@@ -27,6 +27,10 @@ class EffectSatiation: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (event.foodLevel > player.foodLevel) {
return
}

View File

@@ -27,6 +27,10 @@ class EffectSeamlessMovement: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (event.cause != EntityDamageEvent.DamageCause.FALL) {
return
}

View File

@@ -25,6 +25,10 @@ class EffectSecondChance: Effect(
val item = event.item
val meta = item.itemMeta
if (!this.checkConditions(player)) {
return
}
if (meta !is Damageable) {
return
}

View File

@@ -32,6 +32,10 @@ class EffectSerratedStrikes : Effect(
return
}
if (!this.checkConditions(player)) {
return
}
if (!AntigriefManager.canInjure(player, victim)) {
return
}

View File

@@ -27,6 +27,10 @@ class EffectShamanism: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
var multiplier = config.getDouble("percent-faster-per-level") * level

View File

@@ -33,6 +33,10 @@ class EffectSpelunking : DropMultiplierEffect(
val player = event.player
if (!this.checkConditions(player)) {
return
}
val block = event.block
if (BlockUtils.isPlayerPlaced(block)) {

View File

@@ -24,6 +24,10 @@ class EffectStrongImpact : Effect(
val player = event.damager.tryAsPlayer() ?: return
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
if (NumberUtils.randFloat(0.0, 100.0) >= config.getDouble("chance-per-level") * level) {

View File

@@ -31,6 +31,10 @@ class EffectVersatileTools: Effect(
return
}
if (!this.checkConditions(player)) {
return
}
val level = player.getEffectLevel(this)
var multiplier = config.getDouble("percent-more-per-level") * level

View File

@@ -20,6 +20,8 @@ bountiful_harvest:
chance-per-level: 8
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
versatile_tools:
description: "&8Deal &a%percent_more%%&8 more damage with pickaxes"
@@ -27,6 +29,8 @@ versatile_tools:
percent-more-per-level: 4
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
eye_of_the_depths:
description: "&a%chance%%&8 chance to get rare drops from fishing"
@@ -52,6 +56,8 @@ eye_of_the_depths:
- ecoarmor:set_miner_leggings
- ecoarmor:set_miner_boots
- reforges:dynamic
# Conditions
conditions: [ ]
serrated_strikes:
description: "&a%chance%%&8 chance to make your opponent bleed"
@@ -65,6 +71,8 @@ serrated_strikes:
bleed-ticks: 4
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
seamless_movement:
description: "&a%chance%%&8 chance to ignore fall damage"
@@ -72,6 +80,8 @@ seamless_movement:
chance-per-level: 2
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
potionmaster:
description: "&8Brewed potions last &a%percent_more%%&8 longer"
@@ -86,6 +96,8 @@ potionmaster:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
shamanism:
description: "&8Heal &a%percent_faster%%&8 faster"
@@ -94,6 +106,8 @@ shamanism:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
craftsmanship:
description: "&8Axes take &a%percent_less%%&8 less durability damage"
@@ -102,6 +116,8 @@ craftsmanship:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
second_chance:
description: "&8Items have a &a%chance%%&8 chance to instantly repair below &a30&8 durability"
@@ -114,6 +130,8 @@ second_chance:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
efficient_brewing:
description: "&8Potions take &a%seconds_less%&8 less seconds to brew"
@@ -122,6 +140,8 @@ efficient_brewing:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
mystic_resilience:
description: "&a%chance%%&8 chance to ignore negative potion effects"
@@ -130,6 +150,8 @@ mystic_resilience:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
satiation:
description: "&8Lose &a%percent_less%%&8 less hunger"
@@ -138,6 +160,8 @@ satiation:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
golden_yield:
description: "&a%chance%%&8 chance to get &a5x&8 drops"
@@ -149,6 +173,8 @@ golden_yield:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
dodging:
description: "&a%chance%%&8 chance to ignore incoming damage"
@@ -157,6 +183,8 @@ dodging:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
accelerated_escape:
description: "&8Run &a%percent_faster%%&8 faster for &a1.5&8 seconds after taking damage"
@@ -168,6 +196,8 @@ accelerated_escape:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
infernal_resistance:
description: "&a%chance%%&8 chance to ignore fire damage"
@@ -176,6 +206,8 @@ infernal_resistance:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
bravery:
description: "&8Take &a%percent_less%%&8 less damage from bosses"
@@ -184,6 +216,8 @@ bravery:
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
dazzle:
description: "&a%chance%%&8 chance to give your opponent nausea for &a%seconds%&8 seconds"
@@ -195,6 +229,8 @@ dazzle:
chance-per-level: 1.5
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
strong_impact:
description: "&a%chance%%&8 chance to deal &a3x&8 damage"
@@ -204,6 +240,8 @@ strong_impact:
chance-per-level: 0.2
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
endangering:
description: "&a%chance%%&8 chance to remove your opponents invulnerability frame"
@@ -211,6 +249,8 @@ endangering:
chance-per-level: 3
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
spelunking:
description: "&a%chance%%&8 chance to get &a%multiplier%x&8 drops from ores"
@@ -240,6 +280,8 @@ spelunking:
chance-per-level: 8
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
dynamic_mining:
description: "&a%chance%%&8 chance to get Haste III for &a%seconds%&8 seconds when breaking blocks"
@@ -253,6 +295,8 @@ dynamic_mining:
level: 3
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
reimbursement:
description: "&a%chance%%&8 chance to get experience back after enchanting"
@@ -260,6 +304,8 @@ reimbursement:
chance-per-level: 0.5
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
overcompensation:
description: "&a%chance%%&8 chance to get lapis back after enchanting"
@@ -267,6 +313,8 @@ overcompensation:
chance-per-level: 0.75
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
master_lumberjack:
description: "&a%chance%%&8 chance to get &a%multiplier%x&8 drops from trees"
@@ -293,6 +341,8 @@ master_lumberjack:
chance-per-level: 6
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]
magnetic_rod:
description: "&8Increases fishing speed by &a%percentage%%"
@@ -300,3 +350,5 @@ magnetic_rod:
speed-per-level: 5
# Disabled worlds
disabled-in-worlds: [ ]
# Conditions
conditions: [ ]