diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigManager.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigManager.java index 5f370431..489c47aa 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigManager.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigManager.java @@ -9,6 +9,7 @@ import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings; import net.momirealms.customfishing.api.BukkitCustomFishingPlugin; import net.momirealms.customfishing.api.mechanic.config.function.*; import net.momirealms.customfishing.api.mechanic.context.Context; +import net.momirealms.customfishing.api.mechanic.effect.Effect; import net.momirealms.customfishing.api.mechanic.effect.EffectModifier; import net.momirealms.customfishing.api.mechanic.effect.LootBaseEffect; import net.momirealms.customfishing.api.mechanic.entity.EntityConfig; @@ -22,6 +23,7 @@ import net.momirealms.customfishing.common.config.node.Node; import net.momirealms.customfishing.common.item.Item; import net.momirealms.customfishing.common.plugin.feature.Reloadable; import net.momirealms.customfishing.common.util.Pair; +import net.momirealms.customfishing.common.util.TriConsumer; import org.bukkit.entity.Player; import org.bukkit.event.EventPriority; import org.bukkit.inventory.ItemStack; @@ -71,7 +73,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable { protected EventPriority eventPriority; protected Requirement[] mechanicRequirements; protected boolean enableBag; - + protected List, Integer>> globalEffects; protected ConfigManager(BukkitCustomFishingPlugin plugin) { this.plugin = plugin; @@ -186,6 +188,10 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable { return instance.mechanicRequirements; } + public static List, Integer>> globalEffects() { + return instance.globalEffects; + } + public void registerHookParser(Function> function, String... nodes) { registerNodeFunction(nodes, new HookParserFunction(function)); } diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigType.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigType.java index a1622d74..41306848 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigType.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigType.java @@ -101,7 +101,16 @@ public class ConfigType { } ); - private static final ConfigType[] values = new ConfigType[] {ITEM, ENTITY, BLOCK, HOOK, ROD, BAIT, UTIL, TOTEM}; + public static final ConfigType ENCHANT = of( + "enchant", + (id, section, functions) -> { + EnchantConfigParser config = new EnchantConfigParser(id, section, functions); + BukkitCustomFishingPlugin.getInstance().getEffectManager().registerEffectModifier(config.getEffectModifier(), MechanicType.ENCHANT); + BukkitCustomFishingPlugin.getInstance().getEventManager().registerEventCarrier(config.getEventCarrier()); + } + ); + + private static final ConfigType[] values = new ConfigType[] {ITEM, ENTITY, BLOCK, HOOK, ROD, BAIT, UTIL, TOTEM, ENCHANT}; public static ConfigType[] values() { return values; diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/EnchantConfigParser.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/EnchantConfigParser.java new file mode 100644 index 00000000..a8ba5850 --- /dev/null +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/EnchantConfigParser.java @@ -0,0 +1,77 @@ +package net.momirealms.customfishing.api.mechanic.config; + +import dev.dejvokep.boostedyaml.block.implementation.Section; +import net.momirealms.customfishing.api.mechanic.config.function.ConfigParserFunction; +import net.momirealms.customfishing.api.mechanic.config.function.EffectModifierParserFunction; +import net.momirealms.customfishing.api.mechanic.config.function.EventParserFunction; +import net.momirealms.customfishing.api.mechanic.config.function.TotemParserFunction; +import net.momirealms.customfishing.api.mechanic.effect.EffectModifier; +import net.momirealms.customfishing.api.mechanic.event.EventCarrier; +import net.momirealms.customfishing.api.mechanic.item.MechanicType; +import net.momirealms.customfishing.api.mechanic.totem.TotemConfig; +import net.momirealms.customfishing.common.config.node.Node; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +public class EnchantConfigParser { + + private final String id; + private final List> eventBuilderConsumers = new ArrayList<>(); + private final List> effectBuilderConsumers = new ArrayList<>(); + + public EnchantConfigParser(String id, Section section, Map> functionMap) { + this.id = id; + analyze(section, functionMap); + } + + private void analyze(Section section, Map> functionMap) { + Map dataMap = section.getStringRouteMappedValues(false); + for (Map.Entry entry : dataMap.entrySet()) { + String key = entry.getKey(); + Node node = functionMap.get(key); + if (node == null) continue; + ConfigParserFunction function = node.nodeValue(); + if (function != null) { + switch (function.type()) { + case EVENT -> { + EventParserFunction eventParserFunction = (EventParserFunction) function; + Consumer consumer = eventParserFunction.accept(entry.getValue()); + eventBuilderConsumers.add(consumer); + } + case EFFECT_MODIFIER -> { + EffectModifierParserFunction effectModifierParserFunction = (EffectModifierParserFunction) function; + Consumer consumer = effectModifierParserFunction.accept(entry.getValue()); + effectBuilderConsumers.add(consumer); + } + } + continue; + } + if (entry.getValue() instanceof Section innerSection) { + analyze(innerSection, node.getChildTree()); + } + } + } + + public EventCarrier getEventCarrier() { + EventCarrier.Builder builder = EventCarrier.builder() + .id(id) + .type(MechanicType.TOTEM); + for (Consumer consumer : eventBuilderConsumers) { + consumer.accept(builder); + } + return builder.build(); + } + + public EffectModifier getEffectModifier() { + EffectModifier.Builder builder = EffectModifier.builder() + .id(id) + .type(MechanicType.TOTEM); + for (Consumer consumer : effectBuilderConsumers) { + consumer.accept(builder); + } + return builder.build(); + } +} diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/TotemConfigParser.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/TotemConfigParser.java index 252cbd79..68703199 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/TotemConfigParser.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/config/TotemConfigParser.java @@ -25,7 +25,6 @@ public class TotemConfigParser { public TotemConfigParser(String id, Section section, Map> functionMap) { this.id = id; - if (!section.contains("tag")) section.set("tag", true); analyze(section, functionMap); } diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/EffectImpl.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/EffectImpl.java index d9e2cac1..be5ea5c8 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/EffectImpl.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/EffectImpl.java @@ -204,8 +204,8 @@ public class EffectImpl implements Effect { this.difficultyAdder += another.difficultyAdder(); this.gameTimeMultiplier += (another.gameTimeMultiplier() - 1); this.gameTimeAdder += another.gameTimeAdder(); - this.waitTimeAdder += (another.waitTimeAdder() -1); this.waitTimeMultiplier += (another.waitTimeMultiplier() -1); + this.waitTimeAdder += (another.waitTimeAdder()); this.multipleLootChance += another.multipleLootChance(); this.weightOperations.addAll(another.weightOperations()); this.weightOperationsIgnored.addAll(another.weightOperationsIgnored()); diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java index 4dd1db4d..6226a179 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/FishingGears.java @@ -6,9 +6,9 @@ import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.context.ContextKeys; import net.momirealms.customfishing.api.mechanic.effect.EffectModifier; import net.momirealms.customfishing.api.mechanic.item.MechanicType; -import net.momirealms.customfishing.api.mechanic.requirement.Requirement; import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager; import net.momirealms.customfishing.api.storage.user.UserData; +import net.momirealms.customfishing.common.util.Pair; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -102,6 +102,13 @@ public class FishingGears { context.arg(ContextKeys.ROD, rodID); BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(rodID, MechanicType.ROD).ifPresent(fishingGears.modifiers::add); + // set enchantments + List> enchants = BukkitCustomFishingPlugin.getInstance().getIntegrationManager().getEnchantments(rodOnMainHand ? mainHandItem : offHandItem); + for (Pair enchantment : enchants) { + String effectID = enchantment.left() + ":" + enchantment.right(); + BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(effectID, MechanicType.ENCHANT).ifPresent(fishingGears.modifiers::add); + } + // set bait if it is boolean hasBait = false; String anotherItemID = BukkitCustomFishingPlugin.getInstance().getItemManager().getItemID(rodOnMainHand ? offHandItem : mainHandItem); @@ -158,6 +165,14 @@ public class FishingGears { for (String id : totemIDs) { BukkitCustomFishingPlugin.getInstance().getEffectManager().getEffectModifier(id, MechanicType.TOTEM).ifPresent(fishingGears.modifiers::add); } + + // add global effects + fishingGears.modifiers.add( + EffectModifier.builder() + .id("__GLOBAL__") + .modifiers(ConfigManager.globalEffects()) + .build() + ); }; } diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/LavaFishingMechanic.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/LavaFishingMechanic.java index bb04e714..6282fa75 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/LavaFishingMechanic.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/LavaFishingMechanic.java @@ -1,17 +1,39 @@ package net.momirealms.customfishing.api.mechanic.fishing.hook; +import io.papermc.paper.block.fluid.FluidData; +import net.momirealms.customfishing.api.BukkitCustomFishingPlugin; +import net.momirealms.customfishing.api.mechanic.config.ConfigManager; import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.context.ContextKeys; import net.momirealms.customfishing.api.mechanic.effect.Effect; import net.momirealms.customfishing.api.mechanic.effect.EffectProperties; +import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask; +import net.momirealms.customfishing.common.util.RandomUtils; +import org.bukkit.*; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.util.Vector; + +import java.util.Objects; +import java.util.concurrent.ThreadLocalRandom; public class LavaFishingMechanic implements HookMechanic { private final FishHook hook; private final Effect gearsEffect; private final Context context; + private ArmorStand tempEntity; + private SchedulerTask task; + private int timeUntilLured; + private int timeUntilHooked; + private int nibble; + private boolean hooked; + private float fishAngle; + private int currentState; + private int jumpTimer; public LavaFishingMechanic(FishHook hook, Effect gearsEffect, Context context) { this.hook = hook; @@ -24,12 +46,17 @@ public class LavaFishingMechanic implements HookMechanic { if (!(boolean) gearsEffect.properties().getOrDefault(EffectProperties.LAVA_FISHING, false)) { return false; } - return false; + float lavaHeight = 0F; + FluidData fluidData = this.hook.getWorld().getFluidData(this.hook.getLocation()); + if (fluidData.getFluidType() == Fluid.LAVA || fluidData.getFluidType() == Fluid.FLOWING_LAVA) { + lavaHeight = (float) (fluidData.getLevel() * 0.125); + } + return lavaHeight > 0 && this.hook.getY() % 1 <= lavaHeight; } @Override public boolean shouldStop() { - return false; + return hook.isOnGround() || (hook.getLocation().getBlock().getType() != Material.LAVA && hook.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.LAVA); } @Override @@ -39,16 +66,123 @@ public class LavaFishingMechanic implements HookMechanic { @Override public void start(Effect finalEffect) { - + this.setWaitTime(finalEffect); + this.task = BukkitCustomFishingPlugin.getInstance().getScheduler().sync().runRepeating(() -> { + float lavaHeight = 0F; + FluidData fluidData = this.hook.getWorld().getFluidData(this.hook.getLocation()); + if (fluidData.getFluidType() == Fluid.LAVA || fluidData.getFluidType() == Fluid.FLOWING_LAVA) { + lavaHeight = (float) (fluidData.getLevel() * 0.125); + } + if (this.nibble > 0) { + --this.nibble; + if (this.hook.getY() % 1 <= lavaHeight) { + this.jumpTimer++; + if (this.jumpTimer >= 4) { + this.jumpTimer = 0; + Vector previousVector = this.hook.getVelocity(); + this.hook.setVelocity(new Vector(0,0.24,0)); + } + } + if (this.nibble <= 0) { + this.timeUntilLured = 0; + this.timeUntilHooked = 0; + this.hooked = false; + this.jumpTimer = 0; + this.currentState = 0; + } + } else { + if (this.hook.getY() % 1 <= lavaHeight) { + Vector previousVector = this.hook.getVelocity(); + this.hook.setVelocity(new Vector(previousVector.getX() * 0.6, Math.min(0.1, Math.max(-0.1, previousVector.getY() + 0.1)), previousVector.getZ() * 0.6)); + this.currentState = 1; + } else { + if (currentState == 1) { + this.currentState = 0; + // set temp entity + this.tempEntity = this.hook.getWorld().spawn(this.hook.getLocation().clone().subtract(0,1,0), ArmorStand.class); + this.setTempEntityProperties(this.tempEntity); + this.hook.setHookedEntity(this.tempEntity); + } + } + float f; + float f1; + float f2; + double d0; + double d1; + double d2; + if (this.timeUntilHooked > 0) { + this.timeUntilHooked -= 1; + if (this.timeUntilHooked > 0) { + this.fishAngle += (float) RandomUtils.triangle(0.0D, 9.188D); + f = this.fishAngle * 0.017453292F; + f1 = (float) Math.sin(f); + f2 = (float) Math.cos(f); + d0 = hook.getX() + (double) (f1 * (float) this.timeUntilHooked * 0.1F); + d1 = hook.getY(); + d2 = hook.getZ() + (double) (f2 * (float) this.timeUntilHooked * 0.1F); + if (RandomUtils.generateRandomFloat(0,1) < 0.15F) { + hook.getWorld().spawnParticle(Particle.FLAME, d0, d1 - 0.10000000149011612D, d2, 1, f1, 0.1D, f2, 0.0D); + } + float f3 = f1 * 0.04F; + float f4 = f2 * 0.04F; + hook.getWorld().spawnParticle(Particle.FLAME, d0, d1, d2, 0, f4, 0.01D, -f3, 1.0D); + } else { + double d3 = hook.getY() + 0.5D; + hook.getWorld().spawnParticle(Particle.FLAME, hook.getX(), d3, hook.getZ(), (int) (1.0F + 0.3 * 20.0F), 0.3, 0.0D, 0.3, 0.20000000298023224D); + this.nibble = RandomUtils.generateRandomInt(20, 40); + this.hooked = true; + hook.getWorld().playSound(hook.getLocation(), Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 0.25F, 1.0F + (RandomUtils.generateRandomFloat(0,1)-RandomUtils.generateRandomFloat(0,1)) * 0.4F); + if (this.tempEntity != null && this.tempEntity.isValid()) { + this.tempEntity.remove(); + } + } + } else if (timeUntilLured > 0) { + timeUntilLured--; + if (this.timeUntilLured <= 0) { + this.fishAngle = RandomUtils.generateRandomFloat(0F, 360F); + this.timeUntilHooked = RandomUtils.generateRandomInt(20, 80); + } + } else { + setWaitTime(finalEffect); + } + } + }, 1, 1, hook.getLocation()); } @Override public boolean isHooked() { - return false; + return hooked; } @Override public void destroy() { + if (this.tempEntity != null && this.tempEntity.isValid()) { + this.tempEntity.remove(); + } + if (this.task != null) { + this.task.cancel(); + } + } + private void setWaitTime(Effect effect) { + int before = ThreadLocalRandom.current().nextInt(ConfigManager.lavaMaxTime() - ConfigManager.lavaMinTime() + 1) + ConfigManager.lavaMinTime(); + int after = Math.max(1, (int) (before * effect.waitTimeMultiplier() + effect.waitTimeAdder())); + BukkitCustomFishingPlugin.getInstance().debug("Wait time: " + before + " -> " + after + " ticks"); + this.timeUntilLured = after; + } + + private void setTempEntityProperties(ArmorStand entity) { + entity.setInvisible(true); + entity.setCollidable(false); + entity.setInvulnerable(true); + entity.setVisible(false); + entity.setCustomNameVisible(false); + entity.setSmall(true); + entity.setGravity(false); + entity.getPersistentDataContainer().set( + Objects.requireNonNull(NamespacedKey.fromString("temp-entity", BukkitCustomFishingPlugin.getInstance().getBoostrap())), + PersistentDataType.STRING, + "lava" + ); } } diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/VoidFishingMechanic.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/VoidFishingMechanic.java index bbc0826f..328fcd92 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/VoidFishingMechanic.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/hook/VoidFishingMechanic.java @@ -5,16 +5,15 @@ import net.momirealms.customfishing.api.mechanic.config.ConfigManager; import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.context.ContextKeys; import net.momirealms.customfishing.api.mechanic.effect.Effect; -import net.momirealms.customfishing.api.mechanic.effect.EffectModifier; import net.momirealms.customfishing.api.mechanic.effect.EffectProperties; import net.momirealms.customfishing.common.plugin.scheduler.SchedulerTask; import net.momirealms.customfishing.common.util.RandomUtils; import org.bukkit.NamespacedKey; import org.bukkit.Particle; +import org.bukkit.Sound; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.FishHook; import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.persistence.PersistentDataType; import java.util.Objects; @@ -113,6 +112,7 @@ public class VoidFishingMechanic implements HookMechanic { hook.getWorld().spawnParticle(Particle.END_ROD, hook.getX(), d3, hook.getZ(), (int) (1.0F + 0.3 * 20.0F), 0.3, 0.0D, 0.3, 0.20000000298023224D); this.nibble = RandomUtils.generateRandomInt(20, 40); this.hooked = true; + hook.getWorld().playSound(hook.getLocation(), Sound.ITEM_TRIDENT_THUNDER, 0.25F, 1.0F + (RandomUtils.generateRandomFloat(0,1)-RandomUtils.generateRandomFloat(0,1)) * 0.4F); } } else if (timeUntilLured > 0) { timeUntilLured--; diff --git a/api/src/main/java/net/momirealms/customfishing/api/mechanic/item/MechanicType.java b/api/src/main/java/net/momirealms/customfishing/api/mechanic/item/MechanicType.java index 0210f7ee..90c3d336 100644 --- a/api/src/main/java/net/momirealms/customfishing/api/mechanic/item/MechanicType.java +++ b/api/src/main/java/net/momirealms/customfishing/api/mechanic/item/MechanicType.java @@ -17,6 +17,7 @@ public class MechanicType { public static final MechanicType BAIT = of("bait"); public static final MechanicType HOOK = of("hook"); public static final MechanicType TOTEM = of("totem"); + public static final MechanicType ENCHANT = of("enchant"); private final String type; diff --git a/common/src/main/resources/library-version.properties b/common/src/main/resources/library-version.properties index 760b0f92..9e236fc3 100644 --- a/common/src/main/resources/library-version.properties +++ b/common/src/main/resources/library-version.properties @@ -1,3 +1,4 @@ +config=${config_version} asm=${asm_version} asm-commons=${asm_commons_version} jar-relocator=${jar_relocator_version} diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java index 17bc82f6..607c55f1 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/config/BukkitConfigManager.java @@ -2,6 +2,11 @@ package net.momirealms.customfishing.bukkit.config; import dev.dejvokep.boostedyaml.YamlDocument; import dev.dejvokep.boostedyaml.block.implementation.Section; +import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning; +import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings; +import dev.dejvokep.boostedyaml.settings.general.GeneralSettings; +import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings; +import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings; import net.momirealms.customfishing.api.BukkitCustomFishingPlugin; import net.momirealms.customfishing.api.mechanic.action.Action; import net.momirealms.customfishing.api.mechanic.action.ActionTrigger; @@ -26,6 +31,7 @@ import net.momirealms.customfishing.api.mechanic.totem.block.property.TotemBlock import net.momirealms.customfishing.api.mechanic.totem.block.type.TypeCondition; import net.momirealms.customfishing.bukkit.totem.particle.DustParticleSetting; import net.momirealms.customfishing.bukkit.totem.particle.ParticleSetting; +import net.momirealms.customfishing.common.dependency.DependencyProperties; import net.momirealms.customfishing.common.helper.AdventureHelper; import net.momirealms.customfishing.common.util.ListUtils; import net.momirealms.customfishing.common.util.Pair; @@ -40,6 +46,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventPriority; import java.io.File; +import java.io.IOException; import java.util.*; import java.util.function.BiFunction; @@ -65,7 +72,34 @@ public class BukkitConfigManager extends ConfigManager { @Override public void load() { - MAIN_CONFIG = loadConfig("config.yml"); + String configVersion = DependencyProperties.getDependencyVersion("config"); + try { + MAIN_CONFIG = YamlDocument.create( + resolveConfig("config.yml").toFile(), + plugin.getResourceStream("config.yml"), + GeneralSettings.builder() + .setRouteSeparator('.') + .setUseDefaults(false) + .build(), + LoaderSettings + .builder() + .setAutoUpdate(true) + .build(), + DumperSettings.DEFAULT, + UpdaterSettings + .builder() + .setVersioning(new BasicVersioning("config-version")) + .addIgnoredRoute(configVersion, "mechanics.mechanic-requirements", '.') + .addIgnoredRoute(configVersion, "mechanics.global-events", '.') + .addIgnoredRoute(configVersion, "mechanics.global-effects", '.') + .addIgnoredRoute(configVersion, "mechanics.fishing-bag.collect-actions", '.') + .addIgnoredRoute(configVersion, "mechanics.fishing-bag.full-actions", '.') + .addIgnoredRoute(configVersion, "other-settings.placeholder-register", '.') + .build() + ); + } catch (IOException e) { + throw new RuntimeException(e); + } this.loadSettings(); this.loadConfigs(); } @@ -122,6 +156,15 @@ public class BukkitConfigManager extends ConfigManager { } } } + + globalEffects = new ArrayList<>(); + Section globalEffectSection = config.getSection("mechanics.global-effects"); + if (globalEffectSection != null) + for (Map.Entry entry : globalEffectSection.getStringRouteMappedValues(false).entrySet()) { + if (entry.getValue() instanceof Section innerSection) { + globalEffects.add(parseEffect(innerSection)); + } + } } private void loadConfigs() { diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/fishing/BukkitFishingManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/fishing/BukkitFishingManager.java index 94e710cb..c082c9c0 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/fishing/BukkitFishingManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/fishing/BukkitFishingManager.java @@ -7,7 +7,6 @@ import net.momirealms.customfishing.api.mechanic.context.Context; import net.momirealms.customfishing.api.mechanic.fishing.CustomFishingHook; import net.momirealms.customfishing.api.mechanic.fishing.FishingGears; import net.momirealms.customfishing.api.mechanic.fishing.FishingManager; -import net.momirealms.customfishing.api.mechanic.fishing.hook.VanillaMechanic; import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager; import net.momirealms.customfishing.bukkit.util.EventUtils; import net.momirealms.customfishing.common.helper.VersionHelper; diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/integration/BukkitIntegrationManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/integration/BukkitIntegrationManager.java index 849353be..579dd7f8 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/integration/BukkitIntegrationManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/integration/BukkitIntegrationManager.java @@ -24,8 +24,10 @@ import net.momirealms.customfishing.bukkit.entity.BukkitEntityManager; import net.momirealms.customfishing.bukkit.integration.block.ItemsAdderBlockProvider; import net.momirealms.customfishing.bukkit.integration.block.OraxenBlockProvider; import net.momirealms.customfishing.bukkit.integration.enchant.AdvancedEnchantmentsProvider; +import net.momirealms.customfishing.bukkit.integration.enchant.VanillaEnchantmentsProvider; import net.momirealms.customfishing.bukkit.integration.entity.ItemsAdderEntityProvider; import net.momirealms.customfishing.bukkit.integration.entity.MythicEntityProvider; +import net.momirealms.customfishing.bukkit.integration.entity.VanillaEntityProvider; import net.momirealms.customfishing.bukkit.integration.item.*; import net.momirealms.customfishing.bukkit.integration.level.*; import net.momirealms.customfishing.bukkit.integration.quest.BattlePassQuest; @@ -67,6 +69,7 @@ public class BukkitIntegrationManager implements IntegrationManager { @Override public void load() { + registerEnchantmentProvider(new VanillaEnchantmentsProvider()); if (isHooked("ItemsAdder")) { registerItemProvider(new ItemsAdderItemProvider()); registerBlockProvider(new ItemsAdderBlockProvider()); diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/requirement/BukkitRequirementManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/requirement/BukkitRequirementManager.java index b55e84ea..9252d1a9 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/requirement/BukkitRequirementManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/requirement/BukkitRequirementManager.java @@ -24,7 +24,6 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; -import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -171,7 +170,7 @@ public class BukkitRequirementManager implements RequirementManager { private void registerCompetitionRequirement() { registerRequirement("competition", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { boolean onCompetition = section.getBoolean("ongoing", true); List ids = ListUtils.toList(section.get("id")); return context -> { @@ -863,7 +862,7 @@ public class BukkitRequirementManager implements RequirementManager { private void registerPAPIRequirement() { registerRequirement("<", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { MathValue v1 = MathValue.auto(section.get("value1")); MathValue v2 = MathValue.auto(section.get("value2")); return context -> { @@ -877,7 +876,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("<=", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { MathValue v1 = MathValue.auto(section.get("value1")); MathValue v2 = MathValue.auto(section.get("value2")); return context -> { @@ -891,7 +890,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("!=", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { MathValue v1 = MathValue.auto(section.get("value1")); MathValue v2 = MathValue.auto(section.get("value2")); return context -> { @@ -905,7 +904,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("==", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { MathValue v1 = MathValue.auto(section.get("value1")); MathValue v2 = MathValue.auto(section.get("value2")); return context -> { @@ -919,7 +918,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement(">=", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { MathValue v1 = MathValue.auto(section.get("value1")); MathValue v2 = MathValue.auto(section.get("value2")); return context -> { @@ -933,7 +932,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement(">", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { MathValue v1 = MathValue.auto(section.get("value1")); MathValue v2 = MathValue.auto(section.get("value2")); return context -> { @@ -947,7 +946,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("regex", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("papi", "")); String v2 = section.getString("regex", ""); return context -> { @@ -961,7 +960,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("startsWith", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -975,7 +974,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("!startsWith", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -989,7 +988,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("endsWith", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -1003,7 +1002,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("!endsWith", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -1017,7 +1016,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("contains", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -1031,7 +1030,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("!contains", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -1045,7 +1044,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("in-list", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue papi = TextValue.auto(section.getString("papi", "")); List values = ListUtils.toList(section.get("values")); return context -> { @@ -1059,7 +1058,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("!in-list", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue papi = TextValue.auto(section.getString("papi", "")); List values = ListUtils.toList(section.get("values")); return context -> { @@ -1073,7 +1072,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("equals", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { @@ -1087,7 +1086,7 @@ public class BukkitRequirementManager implements RequirementManager { } }); registerRequirement("!equals", (args, actions, advanced) -> { - if (args instanceof ConfigurationSection section) { + if (args instanceof Section section) { TextValue v1 = TextValue.auto(section.getString("value1", "")); TextValue v2 = TextValue.auto(section.getString("value2", "")); return context -> { diff --git a/core/src/main/resources/contents/enchant/default.yml b/core/src/main/resources/contents/enchant/default.yml index ea74b3e7..50136281 100644 --- a/core/src/main/resources/contents/enchant/default.yml +++ b/core/src/main/resources/contents/enchant/default.yml @@ -30,21 +30,42 @@ minecraft:luck_of_the_sea:3: value: - silver_star:+6 - golden_star:+3 -#minecraft:lure:1: -# requirements: {} -# effects: -# effect_1: -# type: wait-time -# value: -50 -#minecraft:lure:2: -# requirements: {} -# effects: -# effect_1: -# type: wait-time -# value: -100 -#minecraft:lure:3: -# requirements: {} -# effects: -# effect_1: -# type: wait-time -# value: -150 \ No newline at end of file +minecraft:lure:1: + requirements: {} + effects: + effect_1: + type: conditional + conditions: + "||": + in-lava: true + in-void: true + effects: + effect_1: + type: wait-time + value: -80 +minecraft:lure:2: + requirements: {} + effects: + effect_1: + type: conditional + conditions: + "||": + in-lava: true + in-void: true + effects: + effect_1: + type: wait-time + value: -160 +minecraft:lure:3: + requirements: {} + effects: + effect_1: + type: conditional + conditions: + "||": + in-lava: true + in-void: true + effects: + effect_1: + type: wait-time + value: -240 \ No newline at end of file diff --git a/core/src/main/resources/loot-conditions.yml b/core/src/main/resources/loot-conditions.yml index 3935c6cf..d5c3dfe0 100644 --- a/core/src/main/resources/loot-conditions.yml +++ b/core/src/main/resources/loot-conditions.yml @@ -5,7 +5,7 @@ global-group: sub-groups: loots_in_water: conditions: - lava-fishing: false + in-water: true environment: - normal '!rod': @@ -126,7 +126,7 @@ global-group: - 'skeleton:+30' loots_in_lava: conditions: - lava-fishing: true + in-lava: true list: [] sub-groups: world_loots: