mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-06 15:51:52 +00:00
Added dynamic mining effect
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.willfp.eco.core.config.updating.ConfigUpdater;
|
||||
import com.willfp.ecoskills.effects.effects.EffectAcceleratedEscape;
|
||||
import com.willfp.ecoskills.effects.effects.EffectBountifulHarvest;
|
||||
import com.willfp.ecoskills.effects.effects.EffectDynamicMining;
|
||||
import com.willfp.ecoskills.effects.effects.EffectEndangering;
|
||||
import com.willfp.ecoskills.effects.effects.EffectInfernalResistance;
|
||||
import com.willfp.ecoskills.effects.effects.EffectCraftsmanship;
|
||||
@@ -58,6 +59,7 @@ public class Effects {
|
||||
public static final Effect STRONG_IMPACT = new EffectStrongImpact();
|
||||
public static final Effect ENDANGERING = new EffectEndangering();
|
||||
public static final Effect SPELUNKING = new EffectSpelunking();
|
||||
public static final Effect DYNAMIC_MINING = new EffectDynamicMining();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void registerNewEffect(@NotNull final Effect effect) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.willfp.ecoskills.effects.effects
|
||||
|
||||
import com.willfp.eco.util.NumberUtils
|
||||
import com.willfp.ecoskills.effects.Effect
|
||||
import com.willfp.ecoskills.getEffectLevel
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.block.BlockBreakEvent
|
||||
import org.bukkit.potion.PotionEffect
|
||||
import org.bukkit.potion.PotionEffectType
|
||||
|
||||
class EffectDynamicMining : Effect(
|
||||
"dynamic_mining"
|
||||
) {
|
||||
override fun formatDescription(string: String, level: Int): String {
|
||||
return string.replace("%chance%", NumberUtils.format(config.getDouble("chance-per-level") * level))
|
||||
.replace(
|
||||
"%seconds%",
|
||||
NumberUtils.format(((config.getInt("ticks-per-level") * level) + config.getInt("base-ticks")) / 20.0)
|
||||
)
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
fun handle(event: BlockBreakEvent) {
|
||||
val player = event.player
|
||||
|
||||
val level = player.getEffectLevel(this)
|
||||
|
||||
if (NumberUtils.randFloat(0.0, 100.0) >= config.getDouble("chance-per-level") * level) {
|
||||
return
|
||||
}
|
||||
|
||||
val duration = (config.getInt("ticks-per-level") * level) + config.getInt("base-ticks")
|
||||
|
||||
player.addPotionEffect(PotionEffect(PotionEffectType.FAST_DIGGING, duration, config.getInt("level")))
|
||||
}
|
||||
}
|
||||
@@ -167,8 +167,18 @@ spelunking:
|
||||
- "diamond_ore"
|
||||
- "deepslate_diamond_ore"
|
||||
|
||||
|
||||
# Chance is as a percentage; if the chance for a player is over 100 then it will always be double drops
|
||||
# with a chance to get triple drops. Same goes if above 200, but then it will always be triple with a chance
|
||||
# for quadruple.
|
||||
chance-per-level: 4
|
||||
chance-per-level: 4
|
||||
dynamic_mining:
|
||||
description: "&a%chance%%&8 chance to get Haste III for &a%seconds%&8 when breaking blocks"
|
||||
|
||||
# The base ticks to give nausea for
|
||||
base-ticks: 18
|
||||
# The extra ticks to give nausea for per level
|
||||
ticks-per-level: 2
|
||||
# The chance to give nausea per level, as a percentage
|
||||
chance-per-level: 1.5
|
||||
# The level of haste to give
|
||||
level: 3
|
||||
@@ -17,6 +17,8 @@ gui:
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- "&8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
- "&8» &r&6Dynamic Mining %ecoskills_dynamic_mining_numeral%"
|
||||
- " %ecoskills_dynamic_mining_description%"
|
||||
|
||||
rewards:
|
||||
# The actual rewards to be given
|
||||
@@ -24,7 +26,8 @@ rewards:
|
||||
- "defense::2"
|
||||
- "ferocity::1:15:100"
|
||||
- "versatile_tools::1"
|
||||
- "spelunking::1"
|
||||
- "spelunking::1:10:100"
|
||||
- "dynamic_mining::1"
|
||||
|
||||
# The chat messages to send on level up
|
||||
chat-messages:
|
||||
@@ -34,6 +37,14 @@ rewards:
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- " &8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
10:
|
||||
- " &8» &r&f+2 %ecoskills_defense_name%"
|
||||
- " &8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%"
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- " &8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
- " &8» &r&6Dynamic Mining %ecoskills_dynamic_mining_numeral%"
|
||||
- " %ecoskills_dynamic_mining_description%"
|
||||
15:
|
||||
- " &8» &r&f+2 %ecoskills_defense_name%"
|
||||
- " &8» &r&f+1 %ecoskills_ferocity_name%"
|
||||
@@ -41,6 +52,8 @@ rewards:
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- " &8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
- " &8» &r&6Dynamic Mining %ecoskills_dynamic_mining_numeral%"
|
||||
- " %ecoskills_dynamic_mining_description%"
|
||||
|
||||
# The lore to show in the levels gui
|
||||
progression-lore:
|
||||
@@ -50,6 +63,14 @@ rewards:
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- " &8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
10:
|
||||
- " &8» &r&f+2 %ecoskills_defense_name%"
|
||||
- " &8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%"
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- " &8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
- " &8» &r&6Dynamic Mining %ecoskills_dynamic_mining_numeral%"
|
||||
- " %ecoskills_dynamic_mining_description%"
|
||||
15:
|
||||
- " &8» &r&f+2 %ecoskills_defense_name%"
|
||||
- " &8» &r&f+1 %ecoskills_ferocity_name%"
|
||||
@@ -57,6 +78,8 @@ rewards:
|
||||
- " %ecoskills_versatile_tools_description%"
|
||||
- " &8» &r&6Spelunking %ecoskills_spelunking_numeral%"
|
||||
- " %ecoskills_spelunking_description%"
|
||||
- " &8» &r&6Dynamic Mining %ecoskills_dynamic_mining_numeral%"
|
||||
- " %ecoskills_dynamic_mining_description%"
|
||||
|
||||
# The xp rewards for each block type
|
||||
# Specify with type:xp
|
||||
|
||||
Reference in New Issue
Block a user