9
0
mirror of https://github.com/Auxilor/EcoArmor.git synced 2026-01-04 15:31:51 +00:00

Added attack speed multiplier effect and manyullyn armor

This commit is contained in:
Auxilor
2021-01-19 09:40:53 +00:00
parent 8f91c805d0
commit 6ca6331928
3 changed files with 98 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ package com.willfp.ecoarmor.effects;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import com.willfp.ecoarmor.effects.effects.AttackSpeedMultiplier;
import com.willfp.ecoarmor.effects.effects.BonusHearts;
import com.willfp.ecoarmor.effects.effects.BowDamageMultiplier;
import com.willfp.ecoarmor.effects.effects.DamageMultiplier;
@@ -26,20 +27,21 @@ public class Effects {
/**
* All registered effects.
*/
private static final BiMap<String, Effect> BY_NAME = HashBiMap.create();
private static final BiMap<String, Effect<?>> BY_NAME = HashBiMap.create();
public static final Effect BOW_DAMAGE_MULTIPLIER = new BowDamageMultiplier();
public static final Effect DAMAGE_MULTIPLIER = new DamageMultiplier();
public static final Effect DAMAGE_TAKEN_MULTIPLIER = new DamageTakenMultiplier();
public static final Effect EVADE_CHANCE = new EvadeChance();
public static final Effect FALL_DAMAGE_MULTIPLIER = new FallDamageMultiplier();
public static final Effect MELEE_DAMAGE_MULTIPLIER = new MeleeDamageMultiplier();
public static final Effect TRIDENT_DAMAGE_MULTIPLIER = new TridentDamageMultiplier();
public static final Effect BONUS_HEARTS = new BonusHearts();
public static final Effect SPEED_MULTIPLIER = new SpeedMutiplier();
public static final Effect EXPERIENCE_MULTIPLIER = new ExperienceMultiplier();
public static final Effect REGENERATION_MULTIPLIER = new RegenerationMultiplier();
public static final Effect WARP_CHANCE = new WarpChance();
public static final Effect<?> BOW_DAMAGE_MULTIPLIER = new BowDamageMultiplier();
public static final Effect<?> DAMAGE_MULTIPLIER = new DamageMultiplier();
public static final Effect<?> DAMAGE_TAKEN_MULTIPLIER = new DamageTakenMultiplier();
public static final Effect<?> EVADE_CHANCE = new EvadeChance();
public static final Effect<?> FALL_DAMAGE_MULTIPLIER = new FallDamageMultiplier();
public static final Effect<?> MELEE_DAMAGE_MULTIPLIER = new MeleeDamageMultiplier();
public static final Effect<?> TRIDENT_DAMAGE_MULTIPLIER = new TridentDamageMultiplier();
public static final Effect<?> BONUS_HEARTS = new BonusHearts();
public static final Effect<?> SPEED_MULTIPLIER = new SpeedMutiplier();
public static final Effect<?> EXPERIENCE_MULTIPLIER = new ExperienceMultiplier();
public static final Effect<?> REGENERATION_MULTIPLIER = new RegenerationMultiplier();
public static final Effect<?> WARP_CHANCE = new WarpChance();
public static final Effect<?> ATTACK_SPEED_MULTIPLIER = new AttackSpeedMultiplier();
/**
* Get effect matching name.
@@ -47,7 +49,7 @@ public class Effects {
* @param name The name to query.
* @return The matching effect, or null if not found.
*/
public static Effect getByName(@NotNull final String name) {
public static Effect<?> getByName(@NotNull final String name) {
return BY_NAME.get(name);
}
@@ -56,7 +58,7 @@ public class Effects {
*
* @return The effects.
*/
public static List<Effect> values() {
public static List<Effect<?>> values() {
return ImmutableList.copyOf(BY_NAME.values());
}
@@ -65,7 +67,7 @@ public class Effects {
*
* @param effect The effect to add.
*/
public static void addNewEffect(@NotNull final Effect effect) {
public static void addNewEffect(@NotNull final Effect<?> effect) {
BY_NAME.remove(effect.getName());
BY_NAME.put(effect.getName(), effect);
}

View File

@@ -0,0 +1,41 @@
package com.willfp.ecoarmor.effects.effects;
import com.willfp.eco.util.events.armorequip.ArmorEquipEvent;
import com.willfp.ecoarmor.effects.Effect;
import com.willfp.ecoarmor.sets.util.ArmorUtils;
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.UUID;
public class AttackSpeedMultiplier extends Effect<Double> {
private static final UUID MODIFIER_UUID = UUID.nameUUIDFromBytes("attack-speed-multiplier".getBytes());
public AttackSpeedMultiplier() {
super("attack-speed-multiplier");
}
@EventHandler
public void onArmorEquip(@NotNull final ArmorEquipEvent event) {
Player player = event.getPlayer();
AttributeInstance movementSpeed = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
assert movementSpeed != null;
this.getPlugin().getScheduler().runLater(() -> {
Double multiplier = ArmorUtils.getEffectStrength(player, this);
if (multiplier == null) {
movementSpeed.removeModifier(new AttributeModifier(MODIFIER_UUID, "speed-multiplier", 0, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
} else {
AttributeModifier modifier = new AttributeModifier(MODIFIER_UUID, "speed-multiplier", multiplier - 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1);
if (!movementSpeed.getModifiers().contains(modifier)) {
movementSpeed.addModifier(modifier);
}
}
}, 1);
}
}

View File

@@ -119,4 +119,42 @@ netherite:
boots:
armor: 3
toughness: 3
knockback-resistance: 1
knockback-resistance: 1
manyullyn:
display: "&5&k!!&r &d&lMANYULLYN&r &5&k!!&r"
crystal-craftable: true
crystal-name: "&dManyullyn Upgrade Crystal"
crystal-recipe:
- ecoarmor:upgrade_crystal_netherite
- enchanted_golden_apple
- ecoarmor:upgrade_crystal_netherite
- enchanted_golden_apple
- ecoarmor:upgrade_crystal_netherite
- enchanted_golden_apple
- ecoarmor:upgrade_crystal_netherite
- enchanted_golden_apple
- ecoarmor:upgrade_crystal_netherite
crystal-lore:
- "&8Drop this onto an armor piece"
- "&8to set its tier to:"
- "&5&k!!&r &d&lMANYULLYN&r &5&k!!&r"
properties:
helmet:
armor: 3
toughness: 5
knockback-resistance: 2
chestplate:
armor: 8
toughness: 5
knockback-resistance: 2
leggings:
armor: 6
toughness: 5
knockback-resistance: 2
boots:
armor: 3
toughness: 5
knockback-resistance: 2