mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Added Voltage
This commit is contained in:
parent
d351c0b0c1
commit
8ac7b1a383
@ -223,6 +223,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant CONCLUDE = new Conclude();
|
||||
public static final EcoEnchant GRACEFUL = new Graceful();
|
||||
public static final EcoEnchant BLOCK_BREATHER = new BlockBreather();
|
||||
public static final EcoEnchant VOLTAGE = new Voltage();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks;
|
||||
import com.willfp.ecoenchants.nms.Target;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Voltage extends EcoEnchant {
|
||||
public Voltage() {
|
||||
super(
|
||||
new EcoEnchantBuilder("voltage", EnchantmentType.NORMAL, Target.Applicable.SWORD, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
private static final Material[] items = {
|
||||
Material.IRON_HELMET,
|
||||
Material.IRON_CHESTPLATE,
|
||||
Material.IRON_LEGGINGS,
|
||||
Material.IRON_BOOTS,
|
||||
|
||||
Material.GOLDEN_HELMET,
|
||||
Material.GOLDEN_CHESTPLATE,
|
||||
Material.GOLDEN_LEGGINGS,
|
||||
Material.GOLDEN_BOOTS,
|
||||
|
||||
Material.CHAINMAIL_HELMET,
|
||||
Material.CHAINMAIL_CHESTPLATE,
|
||||
Material.CHAINMAIL_LEGGINGS,
|
||||
Material.CHAINMAIL_BOOTS,
|
||||
};
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Player))
|
||||
return;
|
||||
if(!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getDamager();
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
EntityEquipment equipment = victim.getEquipment();
|
||||
if(equipment == null) return;
|
||||
|
||||
int pieces = 0;
|
||||
for (ItemStack armorPiece : equipment.getArmorContents()) {
|
||||
if(Arrays.asList(items).contains(armorPiece.getType())) pieces++;
|
||||
}
|
||||
|
||||
if(pieces == 0) return;
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) return;
|
||||
|
||||
int level = EnchantChecks.getMainhandLevel(player, this);
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier * pieces)));
|
||||
}
|
||||
}
|
23
Plugin/src/main/resources/enchants/normal/voltage.yml
Normal file
23
Plugin/src/main/resources/enchants/normal/voltage.yml
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Voltage EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Voltage"
|
||||
|
||||
description: Increases damage dealt against opponents with iron, gold, or chain armor.
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
multiplier: 0.02 # bonus damage multiplier = multiplier * level * pieces
|
@ -242,6 +242,7 @@ permissions:
|
||||
ecoenchants.fromtable.conclude: true
|
||||
ecoenchants.fromtable.graceful: true
|
||||
ecoenchants.fromtable.blockbreather: true
|
||||
ecoenchants.fromtable.voltage: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -840,4 +841,7 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.blockbreather:
|
||||
description: Allows getting block breather from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.voltage:
|
||||
description: Allows getting voltage from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user