Added vibrance talisman
This commit is contained in:
@@ -33,6 +33,7 @@ import com.willfp.talismans.talismans.talismans.SpiderResistanceTalisman;
|
||||
import com.willfp.talismans.talismans.talismans.SpiderTalisman;
|
||||
import com.willfp.talismans.talismans.talismans.StormRing;
|
||||
import com.willfp.talismans.talismans.talismans.StrengthTalisman;
|
||||
import com.willfp.talismans.talismans.talismans.VibranceTalisman;
|
||||
import com.willfp.talismans.talismans.talismans.ZombieResistanceTalisman;
|
||||
import com.willfp.talismans.talismans.talismans.ZombieTalisman;
|
||||
import com.willfp.talismans.talismans.util.TalismanUtils;
|
||||
@@ -84,6 +85,7 @@ public class Talismans {
|
||||
public static final Talisman NECROMANCE_RING = new NecromanceRing();
|
||||
public static final Talisman GROUNDING_CHARM = new GroundingCharm();
|
||||
public static final Talisman STORM_RING = new StormRing();
|
||||
public static final Talisman VIBRANCE_TALISMAN = new VibranceTalisman();
|
||||
|
||||
/**
|
||||
* Get all registered {@link Talisman}s.
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.willfp.talismans.talismans.talismans;
|
||||
|
||||
import com.willfp.talismans.talismans.Talisman;
|
||||
import com.willfp.talismans.talismans.TalismanLevel;
|
||||
import com.willfp.talismans.talismans.Talismans;
|
||||
import com.willfp.talismans.talismans.util.equipevent.EquipType;
|
||||
import com.willfp.talismans.talismans.util.equipevent.TalismanEquipEvent;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VibranceTalisman extends Talisman {
|
||||
private Map<TalismanLevel, AttributeModifier> modifiers;
|
||||
private final AttributeModifier legacyModifier = new AttributeModifier(
|
||||
UUID.nameUUIDFromBytes(this.getKey().getKey().getBytes()),
|
||||
this.getKey().getKey(),
|
||||
0,
|
||||
AttributeModifier.Operation.ADD_NUMBER
|
||||
);
|
||||
|
||||
public VibranceTalisman() {
|
||||
super("vibrance");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postUpdate() {
|
||||
modifiers = new HashMap<>();
|
||||
for (TalismanLevel level : this.getLevels()) {
|
||||
modifiers.put(
|
||||
level,
|
||||
new AttributeModifier(
|
||||
level.getUuid(),
|
||||
level.getKey().getKey(),
|
||||
level.getConfig().getDouble(Talismans.CONFIG_LOCATION + "bonus-hearts") / 2,
|
||||
AttributeModifier.Operation.ADD_NUMBER
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void listener(@NotNull final TalismanEquipEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!event.getTalisman().getTalisman().equals(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
|
||||
assert maxHealth != null;
|
||||
|
||||
AttributeModifier modifier = modifiers.get(event.getTalisman());
|
||||
|
||||
maxHealth.removeModifier(legacyModifier);
|
||||
|
||||
if (event.getType() == EquipType.EQUIP) {
|
||||
if (this.getDisabledWorlds().contains(player.getWorld())) {
|
||||
maxHealth.removeModifier(modifier);
|
||||
} else {
|
||||
if (!maxHealth.getModifiers().contains(modifier)) {
|
||||
maxHealth.addModifier(modifier);
|
||||
|
||||
player.setHealth(maxHealth.getValue());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
maxHealth.removeModifier(modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
enabled: true
|
||||
disabled-in-worlds: [ ]
|
||||
|
||||
levels:
|
||||
1:
|
||||
name: "&aVibrance Talisman I"
|
||||
description: Get an extra heart.
|
||||
|
||||
obtaining:
|
||||
craftable: true
|
||||
recipe:
|
||||
- ghast_tear
|
||||
- golden_apple
|
||||
- ghast_tear
|
||||
|
||||
- golden_apple
|
||||
- ender_eye
|
||||
- golden_apple
|
||||
|
||||
- ghast_tear
|
||||
- golden_apple
|
||||
- ghast_tear
|
||||
|
||||
general-config:
|
||||
material: player_head
|
||||
texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzRmODQyMTgxYzUyZDFkZGFkY2ZiMWE1YjM5OGExOThlZDhmZWQ0MTNlMGFjNzM1NDBiN2MxMzgyZDJmN2M1YiJ9fX0=
|
||||
custom-model-data: -1
|
||||
|
||||
config:
|
||||
bonus-hearts: 1
|
||||
|
||||
2:
|
||||
name: "&eVibrance Talisman II"
|
||||
description: Get two extra hearts.
|
||||
|
||||
obtaining:
|
||||
craftable: true
|
||||
# Recipes are left-right, top-bottom
|
||||
# The first item is the top left, the second is top middle, and so on. The last is bottom right.
|
||||
recipe:
|
||||
- talismans:vibrance_1
|
||||
- talismans:vibrance_1
|
||||
- talismans:vibrance_1
|
||||
|
||||
- talismans:vibrance_1
|
||||
- heart_of_the_sea
|
||||
- talismans:vibrance_1
|
||||
|
||||
- talismans:vibrance_1
|
||||
- talismans:vibrance_1
|
||||
- talismans:vibrance_1
|
||||
|
||||
general-config:
|
||||
material: player_head
|
||||
# Texture is base64, https://minecraft-heads.com has a list of skulls. Ignored if material is not player_head
|
||||
texture: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2ZlNTUyM2E5YWQwYTY1MGFkMjhhMGY2Mjg2MzVjYThlMzIxYmM0ZjI4NWUwNjMxNGViNjU3YmQyYmZjM2UzIn19fQ==
|
||||
custom-model-data: -1
|
||||
|
||||
config:
|
||||
bonus-hearts: 2
|
||||
Reference in New Issue
Block a user