9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-03 14:22:17 +00:00

Added efficient brewing

This commit is contained in:
Auxilor
2021-08-21 13:11:22 +01:00
parent 48a02ddf99
commit 73a3438896
6 changed files with 84 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.ecoskills.effects.effects.EffectBountifulHarvest;
import com.willfp.ecoskills.effects.effects.EffectCraftsmanship;
import com.willfp.ecoskills.effects.effects.EffectEfficientBrewing;
import com.willfp.ecoskills.effects.effects.EffectEyeOfTheDepths;
import com.willfp.ecoskills.effects.effects.EffectPotionmaster;
import com.willfp.ecoskills.effects.effects.EffectSeamlessMovement;
@@ -35,6 +36,7 @@ public class Effects {
public static final Effect SERRATED_STRIKES = new EffectSerratedStrikes();
public static final Effect SHAMANISM = new EffectShamanism();
public static final Effect VERSATILE_TOOLS = new EffectVersatileTools();
public static final Effect EFFICIENT_BREWING = new EffectEfficientBrewing();
@ApiStatus.Internal
public static void registerNewEffect(@NotNull final Effect effect) {

View File

@@ -0,0 +1,60 @@
package com.willfp.ecoskills.effects.effects
import com.willfp.eco.util.NumberUtils
import com.willfp.eco.util.StringUtils
import com.willfp.ecoskills.effects.Effect
import com.willfp.ecoskills.getEffectLevel
import com.willfp.ecoskills.util.PotionUtils
import org.bukkit.Bukkit
import org.bukkit.block.BrewingStand
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.entity.PotionSplashEvent
import org.bukkit.event.inventory.BrewEvent
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.event.player.PlayerItemConsumeEvent
import org.bukkit.inventory.meta.PotionMeta
import org.bukkit.persistence.PersistentDataType
import org.bukkit.potion.PotionData
import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import org.bukkit.potion.PotionType
class EffectEfficientBrewing : Effect(
"efficient_brewing"
) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
fun handle(event: InventoryClickEvent) {
val player = event.whoClicked
if (player !is Player) {
return
}
if (player.getEffectLevel(this) == 0) {
return
}
if (event.inventory.holder !is BrewingStand) {
return
}
val stand = event.inventory.holder as BrewingStand
this.plugin.scheduler.runLater({
if (stand.brewingTime == 400) {
val multiplier = ((player.getEffectLevel(this) * this.config.getDouble("percent-faster-per-level")) / 100) + 1
stand.brewingTime = (stand.brewingTime / multiplier).toInt()
this.plugin.runnableFactory.create { task ->
if (stand.brewingTime - 20 <= 0) {
stand.brewingTime = 1
task.cancel();
}
stand.brewingTime = stand.brewingTime - 20
}.runTaskTimer(0, 2)
}
}, 2)
}
}

View File

@@ -17,6 +17,7 @@ import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.enchantment.EnchantItemEvent
import org.bukkit.event.entity.EntityDamageByEntityEvent
import org.bukkit.event.inventory.BrewEvent
import org.bukkit.inventory.meta.PotionMeta
import java.util.*
class SkillAlchemy : Skill(
@@ -52,9 +53,17 @@ class SkillAlchemy : Skill(
return
}
var mult = 0;
for (i in 0..2) {
if (event.contents.getItem(i)?.itemMeta is PotionMeta) {
mult++
}
}
val type = event.contents.ingredient?.type ?: return
val toGive = rewards[type] ?: return
player.giveSkillExperience(this, toGive)
player.giveSkillExperience(this, toGive * mult)
}
}

View File

@@ -360,6 +360,9 @@ effects:
# This will follow a binomial distribution where the amount of trials is the durability check (30 by default, see above)
# Since this chance will be called many times, it would be best to have this be low.
chance-per-level: 0.1
efficient_brewing:
# The percent faster brewing time for each level
percent-faster-per-level: 4
damage-indicators:
# Requires HolographicDisplays to be installed

View File

@@ -91,3 +91,7 @@ effects:
name: "Second Chance"
color: "&6"
description: "Chance to instantly fix items on low durability"
efficient_brewing:
name: "Efficient Brewing"
color: "&6"
description: "Decrease the time taken to brew potions"

View File

@@ -9,6 +9,7 @@ gui-lore:
- "&f"
- "&fEffects:"
- "&8» &r&6Potionmaster %ecoskills_potionmaster_numeral%"
- "&8» &r&6Efficient Brewing %ecoskills_efficient_brewing_numeral%"
# The maximum obtainable level
max-level: 50
@@ -18,16 +19,19 @@ level-up-rewards:
- "crit_chance:2"
- "wisdom:1"
- "potionmaster:1"
- "efficient_brewing:1"
rewards-messages:
- " &8» &r&f+2 %ecoskills_crit_chance_name%"
- " &8» &r&f+1 %ecoskills_wisdom_name%"
- " &8» &r&6Potionmaster %ecoskills_potionmaster_numeral%"
- " &8» &r&6Efficient Brewing %ecoskills_efficient_brewing_numeral%"
rewards-gui-lore:
- " &8» &r&f+2 %ecoskills_crit_chance_name%"
- " &8» &r&f+1 %ecoskills_wisdom_name%"
- " &8» &r&6Potionmaster %ecoskills_potionmaster_numeral%"
- " &8» &r&6Efficient Brewing %ecoskills_efficient_brewing_numeral%"
# The experience to give for each brewing ingredient
xp-rewards:
@@ -46,5 +50,5 @@ xp-rewards:
- "golden_carrot:22"
- "blaze_powder:12"
- "ghast_tear:12"
- "turtle_shell:80"
- "turtle_helmet:80"
- "phantom_membrane:34"