Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/volmit/adapt/AdaptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
73 changes: 49 additions & 24 deletions src/main/java/com/volmit/adapt/api/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
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;
import org.bukkit.block.data.BlockData;
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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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<PotionEffectType> 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<EntityDamageEvent.DamageCause> 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<PotionEffect> 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);
});
});

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Block> blockMap = new HashSet<>();
int blockCount = 0;
Expand Down Expand Up @@ -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<ItemStack> items = blocks.getDrops();
for (ItemStack item : items) {
safeGiveItem(p, item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand All @@ -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);
}
}
}
}
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand All @@ -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);
}
}
}
}
Expand All @@ -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;
Expand Down
Loading