Skip to content

Commit

Permalink
Merge from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchampions committed Dec 2, 2024
2 parents c7ac804 + 2189558 commit fbe52f6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package city.norain.slimefun4.compatibillty;

import city.norain.slimefun4.SlimefunExtended;
import lombok.experimental.UtilityClass;
import org.bukkit.attribute.Attribute;

@UtilityClass
public class VersionedAttribute {
public static Attribute getMaxHealth() {
if (SlimefunExtended.getMinecraftVersion().isAtLeast(1, 21, 3)) {
return Attribute.valueOf("MAX_HEALTH");
} else {
return Attribute.valueOf("GENERIC_MAX_HEALTH");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.medical;

import city.norain.slimefun4.compatibillty.VersionedAttribute;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
Expand All @@ -11,7 +12,6 @@
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -45,7 +45,8 @@ public ItemUseHandler getItemHandler() {
// Player is neither burning nor injured
if (p.getFireTicks() <= 0
&& p.getHealth()
>= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) {
>= p.getAttribute(VersionedAttribute.getMaxHealth()).getValue()) {

return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.medical;

import city.norain.slimefun4.compatibillty.VersionedAttribute;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
Expand All @@ -11,7 +12,6 @@
import java.util.Set;

import lombok.Getter;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -41,8 +41,7 @@ protected MedicalSupply(
/**
* This method clears any negative {@link PotionEffect} from the given {@link LivingEntity}.
*
* @param n
* The {@link LivingEntity} to clear the effects from.
* @param n The {@link LivingEntity} to clear the effects from.
*/
public void clearNegativeEffects(LivingEntity n) {
for (PotionEffectType effect : curedEffects) {
Expand All @@ -55,12 +54,11 @@ public void clearNegativeEffects(LivingEntity n) {
/**
* This method heals the given {@link LivingEntity} by the amount provided via the constructor.
*
* @param n
* The {@link LivingEntity} to heal
* @param n The {@link LivingEntity} to heal
*/
public void heal(LivingEntity n) {
double health = n.getHealth() + healAmount;
double maxHealth = n.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
double maxHealth = n.getAttribute(VersionedAttribute.getMaxHealth()).getValue();
n.setHealth(Math.min(health, maxHealth));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.medical;

import city.norain.slimefun4.compatibillty.VersionedAttribute;
import io.github.bakedlibs.dough.items.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
Expand All @@ -10,7 +11,6 @@

import io.github.thebusybiscuit.slimefun4.utils.compatibility.VersionedPotionEffectType;
import org.bukkit.GameMode;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
Expand All @@ -33,7 +33,7 @@ public ItemUseHandler getItemHandler() {
// Player is neither burning nor injured
if (p.getFireTicks() <= 0
&& p.getHealth()
>= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) {
>= p.getAttribute(VersionedAttribute.getMaxHealth()).getValue()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.weapons;

import city.norain.slimefun4.compatibillty.VersionedAttribute;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
Expand All @@ -8,9 +9,9 @@
import io.github.thebusybiscuit.slimefun4.core.handlers.WeaponUseHandler;
import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;

import java.util.concurrent.ThreadLocalRandom;

import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand All @@ -20,7 +21,6 @@
* who damages another {@link LivingEntity} with this sword.
*
* @author TheBusyBiscuit
*
*/
public class VampireBlade extends SimpleSlimefunItem<WeaponUseHandler> {
private static final double HEALING_AMOUNT = 4.0;
Expand All @@ -39,7 +39,8 @@ public WeaponUseHandler getItemHandler() {
if (ThreadLocalRandom.current().nextInt(100) < getChance()) {
SoundEffect.VAMPIRE_BLADE_HEALING_SOUND.playFor(p);
double health = p.getHealth() + HEALING_AMOUNT;
double maxHealth = p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
double maxHealth =
p.getAttribute(VersionedAttribute.getMaxHealth()).getValue();
p.setHealth(Math.min(health, maxHealth));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
import io.github.thebusybiscuit.slimefun4.api.exceptions.BiomeMapException;
import io.github.thebusybiscuit.slimefun4.utils.JsonUtils;
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import java.util.*;

import org.bukkit.NamespacedKey;
import org.bukkit.block.Biome;
Expand Down

0 comments on commit fbe52f6

Please sign in to comment.