From 15ff87cfd878e910a34331775ed8a50a8f0b9cc2 Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Fri, 17 Feb 2023 12:04:39 -0500 Subject: [PATCH 1/2] lots of fixes --- .../java/com/volmit/adapt/AdaptConfig.java | 2 +- .../java/com/volmit/adapt/api/Component.java | 73 +++++++++++++------ .../adapt/api/adaptation/Adaptation.java | 2 +- .../api/adaptation/SimpleAdaptation.java | 3 +- .../adaptation/axe/AxeWoodVeinminer.java | 5 +- .../adaptation/hunter/HunterInvis.java | 32 +++++--- .../adaptation/hunter/HunterJumpBoost.java | 32 ++++++-- .../content/adaptation/hunter/HunterLuck.java | 36 ++++++--- .../adaptation/hunter/HunterRegen.java | 32 ++++++-- .../adaptation/hunter/HunterResistance.java | 36 ++++++--- .../adaptation/hunter/HunterSpeed.java | 32 ++++++-- .../adaptation/hunter/HunterStrength.java | 31 ++++++-- src/main/resources/en_US.json | 4 +- 13 files changed, 228 insertions(+), 92 deletions(-) diff --git a/src/main/java/com/volmit/adapt/AdaptConfig.java b/src/main/java/com/volmit/adapt/AdaptConfig.java index b3fc02e3..cfc8124f 100644 --- a/src/main/java/com/volmit/adapt/AdaptConfig.java +++ b/src/main/java/com/volmit/adapt/AdaptConfig.java @@ -66,7 +66,7 @@ public class AdaptConfig { private boolean actionbarNotifyXp = true; private boolean actionbarNotifyLevel = true; private boolean unlearnAllButton = false; - private boolean potionStackingPreventionInAllSKills = false; + boolean preventHunterSkillsWhenHungerApplied = true; private SqlSettings sql = new SqlSettings(); @Setter diff --git a/src/main/java/com/volmit/adapt/api/Component.java b/src/main/java/com/volmit/adapt/api/Component.java index 667efb68..b2be4d13 100644 --- a/src/main/java/com/volmit/adapt/api/Component.java +++ b/src/main/java/com/volmit/adapt/api/Component.java @@ -26,6 +26,7 @@ import com.volmit.adapt.api.data.WorldData; import com.volmit.adapt.api.value.MaterialValue; import com.volmit.adapt.api.xp.XP; +import com.volmit.adapt.util.J; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -33,6 +34,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityPickupItemEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -47,7 +49,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Objects; +import java.util.Set; import java.util.function.Predicate; public interface Component { @@ -180,32 +182,55 @@ default PotionEffect getRawPotionEffect(ItemStack is) { return null; } - default void addPotionStacks(Player p, PotionEffectType potionEffect, int amplifier, int duration, Boolean overlap) { - List activeList = p.getActivePotionEffects().stream().map(PotionEffect::getType).toList(); - if (activeList.size() > 0) { - for (PotionEffectType type : activeList) { - if (type.equals(potionEffect)) { - if (!AdaptConfig.get().isPotionStackingPreventionInAllSKills()) { - if (overlap) { - p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 0.25f, 0.25f); - int newAmplifier = Objects.requireNonNull(p.getPotionEffect(type)).getAmplifier(); - int newDuration = Objects.requireNonNull(p.getPotionEffect(type)).getDuration(); - p.removePotionEffect(type); - p.addPotionEffect(new PotionEffect(potionEffect, newDuration + duration, newAmplifier + amplifier, false, false)); - } - int newAmplifier = Objects.requireNonNull(p.getPotionEffect(type)).getAmplifier(); - int newDuration = Objects.requireNonNull(p.getPotionEffect(type)).getDuration(); - p.removePotionEffect(type); - p.addPotionEffect(new PotionEffect(potionEffect, newDuration, newAmplifier + 1, false, false)); - } + default boolean isAdaptableDamageCause(EntityDamageEvent event) { + Set excludedCauses = Set.of( + // These are not damage causes that can are going to trigger adaptability + EntityDamageEvent.DamageCause.VOID, + EntityDamageEvent.DamageCause.LAVA, + EntityDamageEvent.DamageCause.HOT_FLOOR, + EntityDamageEvent.DamageCause.CRAMMING, + EntityDamageEvent.DamageCause.MELTING, + EntityDamageEvent.DamageCause.SUFFOCATION, + EntityDamageEvent.DamageCause.SUICIDE, + EntityDamageEvent.DamageCause.WITHER, + EntityDamageEvent.DamageCause.FLY_INTO_WALL, + EntityDamageEvent.DamageCause.FALL, + EntityDamageEvent.DamageCause.SONIC_BOOM, + EntityDamageEvent.DamageCause.THORNS + ); + return !excludedCauses.contains(event.getCause()); + } + + default void addPotionStacks(Player p, PotionEffectType potionEffect, int amplifier, int duration, boolean overlap) { + List activeEffects = new ArrayList<>(p.getActivePotionEffects()); + + for (PotionEffect activeEffect : activeEffects) { + if (activeEffect.getType() == potionEffect) { + if (!overlap) { + return; // don't modify the effect if overlap is false } + // modify the effect if overlap is true + int newDuration = activeEffect.getDuration() + duration; + int newAmplifier = Math.max(activeEffect.getAmplifier(), amplifier); + p.removePotionEffect(potionEffect); + p.addPotionEffect(new PotionEffect(potionEffect, newDuration, newAmplifier)); + p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 0.25f, 0.25f); + return; } - - } - if (!activeList.contains(potionEffect)) { - p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 0.25f, 0.25f); - p.addPotionEffect(new PotionEffect(potionEffect, duration, amplifier)); } + // if we didn't find an existing effect, add a new one + J.a(() -> { + try { + Thread.sleep(5); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + J.s(() -> { + p.addPotionEffect(new PotionEffect(potionEffect, duration, amplifier)); + p.playSound(p.getLocation(), Sound.ENTITY_IRON_GOLEM_STEP, 0.25f, 0.25f); + }); + }); + } diff --git a/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java b/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java index 9022da16..25c7e093 100644 --- a/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java +++ b/src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java @@ -370,7 +370,7 @@ default void openGui(Player player) { .setProgress(1D) .addLore(Form.wrapWordsPrefixed(getDescription(), "" + C.GRAY, 40)) .addLore(mylevel >= lvl ? ("") : ("" + C.WHITE + c + C.GRAY + " " + Localizer.dLocalize("snippets", "adaptmenu", "knowledgecost") + " " + (AdaptConfig.get().isHardcoreNoRefunds() ? C.DARK_RED + "" + C.BOLD + Localizer.dLocalize("snippets", "adaptmenu", "norefunds") : ""))) - .addLore(mylevel >= lvl ? AdaptConfig.get().isHardcoreNoRefunds() ? (C.GREEN + Localizer.dLocalize("snippets", "adaptmenu", "alreadylearned") + " " + C.DARK_RED + "" + C.BOLD + Localizer.dLocalize("snippets", "adaptmenu", "norefunds")) : (isPermanent() ? "" : (C.GREEN + Localizer.dLocalize("snippets", "adaptmenu", "alreadylearned") + " " + C.GRAY + Localizer.dLocalize("snippets", "adaptmenu", "unlearnrefund") + " " + C.GREEN + rc + " " + Localizer.dLocalize("snippets", "adaptmenu", "knowledgecost"))) : (k >= c ? (C.BLUE + Localizer.dLocalize("snippets", "adaptmenu", "clicklearn") + " " + getDisplayName(i)) : (k == 0 ? (C.RED + Localizer.dLocalize("snippets", "adaptmenu", "noknowledge")) : (C.RED + "(" + Localizer.dLocalize("snippets", "adaptmenu", "youonlyhave") + " " + C.WHITE + k + C.RED + " " + Localizer.dLocalize("snippets", "adaptmenu", "knowledgecost") + ")")))) + .addLore(mylevel >= lvl ? AdaptConfig.get().isHardcoreNoRefunds() ? (C.GREEN + Localizer.dLocalize("snippets", "adaptmenu", "alreadylearned") + " " + C.DARK_RED + "" + C.BOLD + Localizer.dLocalize("snippets", "adaptmenu", "norefunds")) : (isPermanent() ? "" : (C.GREEN + Localizer.dLocalize("snippets", "adaptmenu", "alreadylearned") + " " + C.GRAY + Localizer.dLocalize("snippets", "adaptmenu", "unlearnrefund") + " " + C.GREEN + rc + " " + Localizer.dLocalize("snippets", "adaptmenu", "knowledgecost"))) : (k >= c ? (C.BLUE + Localizer.dLocalize("snippets", "adaptmenu", "clicklearn") + " " + getDisplayName(i)) : (k == 0 ? (C.RED + Localizer.dLocalize("snippets", "adaptmenu", "noknowledge")) : (C.RED + "(" + Localizer.dLocalize("snippets", "adaptmenu", "youonlyhave") + " " + C.WHITE + k + C.RED + " " + Localizer.dLocalize("snippets", "adaptmenu", "knowledgeavailable") + ")")))) .addLore(mylevel < lvl && getPlayer(player).getData().hasPowerAvailable(pc) ? C.GREEN + "" + lvl + " " + Localizer.dLocalize("snippets", "adaptmenu", "powerdrain") : mylevel >= lvl ? C.GREEN + "" + lvl + " " + Localizer.dLocalize("snippets", "adaptmenu", "powerdrain") : C.RED + Localizer.dLocalize("snippets", "adaptmenu", "notenoughpower") + "\n" + C.RED + Localizer.dLocalize("snippets", "adaptmenu", "howtolevelup")) .addLore((isPermanent() ? C.RED + "" + C.BOLD + Localizer.dLocalize("snippets", "adaptmenu", "maynotunlearn") : "")) .onLeftClick((e) -> { diff --git a/src/main/java/com/volmit/adapt/api/adaptation/SimpleAdaptation.java b/src/main/java/com/volmit/adapt/api/adaptation/SimpleAdaptation.java index a53c9f11..e9cf99ec 100644 --- a/src/main/java/com/volmit/adapt/api/adaptation/SimpleAdaptation.java +++ b/src/main/java/com/volmit/adapt/api/adaptation/SimpleAdaptation.java @@ -21,7 +21,6 @@ import art.arcane.amulet.io.FileWatcher; import com.google.gson.Gson; import com.volmit.adapt.Adapt; -import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.advancement.AdaptAdvancement; import com.volmit.adapt.api.potion.BrewingRecipe; import com.volmit.adapt.api.recipe.AdaptRecipe; @@ -171,7 +170,7 @@ public AdaptAdvancement buildAdvancements() { return AdaptAdvancement.builder() .key("adaptation_" + getName()) .title(C.WHITE + "[ " + getDisplayName() + C.WHITE + " ]") - .description(getDescription() + ". " + Localizer.dLocalize("snippets", "gui", "unlockthisbyclicking") + AdaptConfig.get().adaptActivatorBlock.toLowerCase().capitalizeWords()) + .description(getDescription() + ". " + Localizer.dLocalize("snippets", "gui", "unlockthisbyclicking") + " " + Localizer.dLocalize("snippets", "adaptmenu", "activatorblock")) .icon(getIcon()) .children(a) .visibility(AdvancementVisibility.PARENT_GRANTED) diff --git a/src/main/java/com/volmit/adapt/content/adaptation/axe/AxeWoodVeinminer.java b/src/main/java/com/volmit/adapt/content/adaptation/axe/AxeWoodVeinminer.java index 76c09824..f0f66b21 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/axe/AxeWoodVeinminer.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/axe/AxeWoodVeinminer.java @@ -86,7 +86,7 @@ public void on(BlockBreakEvent e) { } if (isLog(new ItemStack(e.getBlock().getType()))) { - + Adapt.info("Axe Wood Veinminer: " + p.getName() + " is using " + e.getBlock().getType() + " at " + e.getBlock().getLocation()); Block block = e.getBlock(); Set blockMap = new HashSet<>(); int blockCount = 0; @@ -114,7 +114,8 @@ public void on(BlockBreakEvent e) { J.s(() -> { for (Block blocks : blockMap) { - if (getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory").getLevel() > 0) { + Adapt.info("Axe Wood Veinminer: " + p.getName() + " is breaking " + blocks.getType() + " at " + blocks.getLocation()); + if (getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory") != null && getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory").getLevel() > 0) { Collection items = blocks.getDrops(); for (ItemStack item : items) { safeGiveItem(p, item); diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterInvis.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterInvis.java index f8cd6de0..211c7176 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterInvis.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterInvis.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -48,7 +49,7 @@ public HunterInvis() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "invisibility", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "invisibility", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "invisibility", "lore3")); + v.addLore(C.RED + "- " + (5 + level) + C.GRAY + Localizer.dLocalize("hunter", "invisibility", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "invisibility", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "invisibility", "lore5")); v.addLore(C.RED + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -62,24 +63,29 @@ public void on(EntityDamageEvent e) { if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } if (!getConfig().useConsumable) { - if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); - + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, 5 + getLevel(p), 100, true); - addPotionStacks(p, PotionEffectType.INVISIBILITY, 1, 50 * getLevel(p), true); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration* getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.INVISIBILITY, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.INVISIBILITY, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.INVISIBILITY, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -106,6 +112,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 100; + int baseHungerFromLevel = 10; + int baseHungerDuration = 50; + int basePoisonFromLevel = 6; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterJumpBoost.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterJumpBoost.java index 7c0dc5d4..68a2d788 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterJumpBoost.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterJumpBoost.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -47,7 +48,7 @@ public HunterJumpBoost() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "jumpboost", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "jumpboost", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "jumpboost", "lore3")); + v.addLore(C.RED + "- " + (5 + level) + C.GRAY + Localizer.dLocalize("hunter", "jumpboost", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "jumpboost", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "jumpboost", "lore5")); v.addLore(C.GRAY + "- " + level + C.RED + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -60,24 +61,31 @@ public void on(EntityDamageEvent e) { if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { - if (!getConfig().useConsumable) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } + if (!getConfig().useConsumable) { if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, 5 + getLevel(p), 100, true); - addPotionStacks(p, PotionEffectType.JUMP, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration* getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.JUMP, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.JUMP, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.JUMP, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -104,6 +112,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 100; + int baseHungerFromLevel = 10; + int baseHungerDuration = 50; + int basePoisonFromLevel = 6; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterLuck.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterLuck.java index 16c77db4..4077f93e 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterLuck.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterLuck.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -47,7 +48,7 @@ public HunterLuck() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "luck", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "luck", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "luck", "lore3")); + v.addLore(C.RED + "- " +(5 + level) + C.GRAY + Localizer.dLocalize("hunter", "luck", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "luck", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "luck", "lore5")); v.addLore(C.GRAY + "- " + level + C.RED + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -60,26 +61,33 @@ public void on(EntityDamageEvent e) { if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { - if (!getConfig().useConsumable) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } + if (!getConfig().useConsumable) { if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); - addPotionStacks(p, PotionEffectType.UNLUCK, 2 + getLevel(p), 600, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + addPotionStacks(p, PotionEffectType.UNLUCK, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, 5 + getLevel(p), 100, true); - addPotionStacks(p, PotionEffectType.LUCK, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration* getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.LUCK, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.LUCK, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.LUCK, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); - addPotionStacks(p, PotionEffectType.UNLUCK, 2 + getLevel(p), 600, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + addPotionStacks(p, PotionEffectType.UNLUCK, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -106,6 +114,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 100; + int baseHungerFromLevel = 10; + int baseHungerDuration = 50; + int basePoisonFromLevel = 6; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterRegen.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterRegen.java index 4a54c4c2..01f94714 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterRegen.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterRegen.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -47,7 +48,7 @@ public HunterRegen() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "regen", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "regen", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "regen", "lore3")); + v.addLore(C.RED + "- " + (5 + level) + C.GRAY + Localizer.dLocalize("hunter", "regen", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "regen", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "regen", "lore5")); v.addLore(C.GRAY + "- " + level + C.RED + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -60,24 +61,31 @@ public void on(EntityDamageEvent e) { if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { - if (!getConfig().useConsumable) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } + if (!getConfig().useConsumable) { if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, 10 + getLevel(p), 100, true); - addPotionStacks(p, PotionEffectType.REGENERATION, getLevel(p), 2 + getLevel(p), false); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration * getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.REGENERATION, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.REGENERATION, getLevel(p), 2 + getLevel(p), false); + addPotionStacks(p, PotionEffectType.REGENERATION, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -104,6 +112,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 5; + int baseHungerFromLevel = 10; + int baseHungerDuration = 50; + int basePoisonFromLevel = 6; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterResistance.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterResistance.java index 81b7af03..0db0fb29 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterResistance.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterResistance.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -25,7 +26,6 @@ import lombok.NoArgsConstructor; import org.bukkit.Material; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; @@ -48,7 +48,7 @@ public HunterResistance() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "resistance", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "resistance", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "resistance", "lore3")); + v.addLore(C.RED + "- " + (5 + level) + C.GRAY + Localizer.dLocalize("hunter", "resistance", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "resistance", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "resistance", "lore5")); v.addLore(C.GRAY + "- " + level + C.RED + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -56,30 +56,36 @@ public void addStats(int level, Element v) { } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler public void on(EntityDamageEvent e) { - if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { - if (!getConfig().useConsumable) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } + if (!getConfig().useConsumable) { if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, getLevel(p), 300, false); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, getLevel(p), 900, false); - addPotionStacks(p, PotionEffectType.DAMAGE_RESISTANCE, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration* getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.DAMAGE_RESISTANCE, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.DAMAGE_RESISTANCE, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.DAMAGE_RESISTANCE, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, getLevel(p), 300, false); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -106,6 +112,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 10; + int baseHungerFromLevel = 10; + int baseHungerDuration = 50; + int basePoisonFromLevel = 6; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterSpeed.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterSpeed.java index 84c6e7d3..91ad51c2 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterSpeed.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterSpeed.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -47,7 +48,7 @@ public HunterSpeed() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "speed", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "speed", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "speed", "lore3")); + v.addLore(C.RED + "- " + (5 + level) + C.GRAY + Localizer.dLocalize("hunter", "speed", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "speed", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "speed", "lore5")); v.addLore(C.GRAY + "- " + level + C.RED + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -60,24 +61,31 @@ public void on(EntityDamageEvent e) { if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { - if (!getConfig().useConsumable) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } + if (!getConfig().useConsumable) { if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, 5 + getLevel(p), 100, true); - addPotionStacks(p, PotionEffectType.SPEED, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration* getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.SPEED, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.SPEED, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.SPEED, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -104,6 +112,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 100; + int baseHungerDuration = 50; + int baseHungerFromLevel = 10; + int basePoisonFromLevel = 6; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterStrength.java b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterStrength.java index 2b4b4877..10c61d61 100644 --- a/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterStrength.java +++ b/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterStrength.java @@ -18,6 +18,7 @@ package com.volmit.adapt.content.adaptation.hunter; +import com.volmit.adapt.AdaptConfig; import com.volmit.adapt.api.adaptation.SimpleAdaptation; import com.volmit.adapt.util.C; import com.volmit.adapt.util.Element; @@ -47,7 +48,7 @@ public HunterStrength() { public void addStats(int level, Element v) { v.addLore(C.GRAY + Localizer.dLocalize("hunter", "strength", "lore1")); v.addLore(C.GREEN + "+ " + level + C.GRAY + Localizer.dLocalize("hunter", "strength", "lore2")); - v.addLore(C.RED + "- " + 5 + level + C.GRAY + Localizer.dLocalize("hunter", "strength", "lore3")); + v.addLore(C.RED + "- " + (5 + level) + C.GRAY + Localizer.dLocalize("hunter", "strength", "lore3")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "strength", "lore4")); v.addLore(C.GRAY + "* " + level + C.GRAY + " " + Localizer.dLocalize("hunter", "strength", "lore5")); v.addLore(C.GRAY + "- " + level + C.RED + " " + Localizer.dLocalize("hunter", "penalty", "lore1")); @@ -60,23 +61,31 @@ public void on(EntityDamageEvent e) { if (e.isCancelled()) { return; } - if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { + if (e.getEntity() instanceof org.bukkit.entity.Player p && isAdaptableDamageCause(e) && hasAdaptation(p)) { + if (AdaptConfig.get().isPreventHunterSkillsWhenHungerApplied() && p.hasPotionEffect(PotionEffectType.HUNGER)) { + return; + } + if (!getConfig().useConsumable) { if (p.getFoodLevel() == 0) { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } else { - addPotionStacks(p, PotionEffectType.HUNGER, 5 + getLevel(p), 100, true); - addPotionStacks(p, PotionEffectType.INCREASE_DAMAGE, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.HUNGER, getConfig().baseHungerFromLevel - getLevel(p), getConfig().baseHungerDuration* getLevel(p), getConfig().stackHungerPenalty); + addPotionStacks(p, PotionEffectType.INCREASE_DAMAGE, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } } else { if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) { Material mat = Material.getMaterial(getConfig().consumable); if (mat != null && p.getInventory().contains(mat)) { p.getInventory().removeItem(new ItemStack(mat, 1)); - addPotionStacks(p, PotionEffectType.INCREASE_DAMAGE, getLevel(p), 50, false); + addPotionStacks(p, PotionEffectType.INCREASE_DAMAGE, getLevel(p), getConfig().baseEffectbyLevel * getLevel(p), getConfig().stackBuff); } else { - addPotionStacks(p, PotionEffectType.POISON, 2 + getLevel(p), 300, true); + if (getConfig().poisonPenalty) { + addPotionStacks(p, PotionEffectType.POISON, getConfig().basePoisonFromLevel - getLevel(p), getConfig().baseHungerDuration, getConfig().stackPoisonPenalty); + } } } } @@ -103,6 +112,14 @@ protected static class Config { boolean permanent = false; boolean enabled = true; boolean useConsumable = false; + boolean poisonPenalty = true; + boolean stackHungerPenalty = false; + boolean stackPoisonPenalty = false; + boolean stackBuff = false; + int baseEffectbyLevel = 25; + int baseHungerFromLevel = 10; + int basePoisonFromLevel = 6; + int baseHungerDuration = 50; String consumable = "ROTTEN_FLESH"; int baseCost = 4; int maxLevel = 5; diff --git a/src/main/resources/en_US.json b/src/main/resources/en_US.json index 3eba1c6f..51008d40 100644 --- a/src/main/resources/en_US.json +++ b/src/main/resources/en_US.json @@ -217,6 +217,7 @@ "maynotunlearn": "YOU MAY NOT UNLEARN", "mayunlearn": "YOU MAY LEARN/UNLEARN", "knowledgecost": "Knowledge Cost", + "knowledgeavailable": "Knowledge Available", "alreadylearned": "Already Learned", "unlearnrefund": "Click to Unlearn & Refund", "norefunds": "HARDCORE, REFUNDS DISABLED", @@ -229,7 +230,8 @@ "power": "power", "powerdrain": "Power Drain", "learned": "Learned ", - "unlearned": "Unlearned " + "unlearned": "Unlearned ", + "activatorblock": "Bookshelf" }, "knowledgeorb": { "contains": "contains", From 097da2c018212f4bf9b4ed9c11d2b240da987cb6 Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Fri, 17 Feb 2023 12:12:31 -0500 Subject: [PATCH 2/2] v+ --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a473d770..8be86c30 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ plugins { id "de.undercouch.download" version "5.0.1" } -version '1.5.4-1.19.3' +version '1.5.5-1.19.3' def nmsVersion = "1.19.3" //[NMS] def apiVersion = '1.19' def specialSourceVersion = '1.11.0' //[NMS]