mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-26 20:27:38 +01:00
Added Wound
This commit is contained in:
parent
bc994608fb
commit
7f95b45e1a
@ -193,6 +193,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant DIURNAL = new Diurnal();
|
||||
public static final EcoEnchant MARKING = new Marking();
|
||||
public static final EcoEnchant CORROSIVE = new Corrosive();
|
||||
public static final EcoEnchant WOUND = new Wound();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
@ -0,0 +1,72 @@
|
||||
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.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
import com.willfp.ecoenchants.nms.Target;
|
||||
import com.willfp.ecoenchants.util.HasEnchant;
|
||||
import com.willfp.ecoenchants.util.Rand;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Wound extends EcoEnchant {
|
||||
public Wound() {
|
||||
super(
|
||||
new EcoEnchantBuilder("wound", EnchantmentType.NORMAL, Target.Applicable.SWORD, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Arrow))
|
||||
return;
|
||||
|
||||
if(!(((Arrow) event.getDamager()).getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||
|
||||
if (!HasEnchant.playerHeld(player, this)) return;
|
||||
|
||||
int level = HasEnchant.getPlayerLevel(player, 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/wound.yml
Normal file
25
Plugin/src/main/resources/enchants/normal/wound.yml
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
# Wound EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Wound"
|
||||
|
||||
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
|
@ -212,6 +212,7 @@ permissions:
|
||||
ecoenchants.fromtable.diurnal: true
|
||||
ecoenchants.fromtable.marking: true
|
||||
ecoenchants.fromtable.corrosive: true
|
||||
ecoenchants.fromtable.wound: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -720,4 +721,7 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.corrosive:
|
||||
description: Allows getting corrosive from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.wound:
|
||||
description: Allows getting wound from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user