mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-29 01:31:20 +01:00
Added Lesion
This commit is contained in:
parent
defc44038e
commit
7a16f7de2d
@ -219,6 +219,7 @@ public class EcoEnchants {
|
|||||||
public static final EcoEnchant VOID_AFFINITY = new VoidAffinity();
|
public static final EcoEnchant VOID_AFFINITY = new VoidAffinity();
|
||||||
public static final EcoEnchant CUBISM = new Cubism();
|
public static final EcoEnchant CUBISM = new Cubism();
|
||||||
public static final EcoEnchant QUADRILATERALISM = new Quadrilateralism();
|
public static final EcoEnchant QUADRILATERALISM = new Quadrilateralism();
|
||||||
|
public static final EcoEnchant LESION = new Lesion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all registered {@link EcoEnchant}s
|
* Get all registered {@link EcoEnchant}s
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||||
|
|
||||||
|
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||||
|
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.integrations.antigrief.AntigriefManager;
|
||||||
|
import com.willfp.ecoenchants.nms.Target;
|
||||||
|
import com.willfp.ecoenchants.nms.TridentStack;
|
||||||
|
import com.willfp.ecoenchants.util.Rand;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Trident;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
public class Lesion extends EcoEnchant {
|
||||||
|
public Lesion() {
|
||||||
|
super(
|
||||||
|
new EcoEnchantBuilder("lesion", EnchantmentType.NORMAL, Target.Applicable.TRIDENT, 4.0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// START OF LISTENERS
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onHit(EntityDamageByEntityEvent event) {
|
||||||
|
if (!(event.getDamager() instanceof Trident))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!(((Trident) event.getDamager()).getShooter() instanceof Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(event.getEntity() instanceof LivingEntity))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = (Player) ((Trident) event.getDamager()).getShooter();
|
||||||
|
Trident trident = (Trident) event.getDamager();
|
||||||
|
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||||
|
ItemStack item = TridentStack.getTridentStack(trident);
|
||||||
|
|
||||||
|
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||||
|
|
||||||
|
if (!EnchantChecks.item(item, this)) return;
|
||||||
|
|
||||||
|
int level = EnchantChecks.getItemLevel(item, this);
|
||||||
|
if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
double bleedDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "bleed-damage");
|
||||||
|
|
||||||
|
int bleedCount = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "amount-per-level");
|
||||||
|
bleedCount *= level;
|
||||||
|
final int finalBleedCount = bleedCount;
|
||||||
|
|
||||||
|
AtomicInteger currentBleedCount = new AtomicInteger(0);
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
currentBleedCount.addAndGet(1);
|
||||||
|
|
||||||
|
victim.damage(bleedDamage);
|
||||||
|
|
||||||
|
if(currentBleedCount.get() >= finalBleedCount) this.cancel();
|
||||||
|
}
|
||||||
|
}.runTaskTimer(EcoEnchantsPlugin.getInstance(), 0, 10);
|
||||||
|
}
|
||||||
|
}
|
25
Plugin/src/main/resources/enchants/normal/lesion.yml
Normal file
25
Plugin/src/main/resources/enchants/normal/lesion.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#
|
||||||
|
# Lesion EcoEnchant
|
||||||
|
#
|
||||||
|
|
||||||
|
config-version: 4.0 # Don't edit this.
|
||||||
|
|
||||||
|
name: "Lesion"
|
||||||
|
|
||||||
|
description: Causes your opponent to bleed, damaging them repeatedly.
|
||||||
|
|
||||||
|
obtaining:
|
||||||
|
table: true
|
||||||
|
villager: true
|
||||||
|
loot: true
|
||||||
|
rarity: legendary
|
||||||
|
|
||||||
|
general-config:
|
||||||
|
grindstoneable: true
|
||||||
|
conflicts: []
|
||||||
|
maximum-level: 3
|
||||||
|
|
||||||
|
config:
|
||||||
|
chance-per-level: 5 #chance of bleeding per level
|
||||||
|
bleed-damage: 1
|
||||||
|
amount-per-level: 2 # Bleed number per level
|
@ -238,6 +238,7 @@ permissions:
|
|||||||
ecoenchants.fromtable.voidaffinity: true
|
ecoenchants.fromtable.voidaffinity: true
|
||||||
ecoenchants.fromtable.cubism: true
|
ecoenchants.fromtable.cubism: true
|
||||||
ecoenchants.fromtable.quadrilateralism: true
|
ecoenchants.fromtable.quadrilateralism: true
|
||||||
|
ecoenchants.fromtable.lesion: true
|
||||||
|
|
||||||
ecoenchants.updateannounce:
|
ecoenchants.updateannounce:
|
||||||
description: Informs admins of a new update
|
description: Informs admins of a new update
|
||||||
@ -825,3 +826,6 @@ permissions:
|
|||||||
ecoenchants.fromtable.quadrilateralism:
|
ecoenchants.fromtable.quadrilateralism:
|
||||||
description: Allows getting quadrilateralism from an enchanting table
|
description: Allows getting quadrilateralism from an enchanting table
|
||||||
default: true
|
default: true
|
||||||
|
ecoenchants.fromtable.lesion:
|
||||||
|
description: Allows getting lesion from an enchanting table
|
||||||
|
default: true
|
Loading…
Reference in New Issue
Block a user