Added backstab
This commit is contained in:
@@ -228,6 +228,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse();
|
||||
public static final EcoEnchant RESPIRATOR = new Respirator();
|
||||
public static final EcoEnchant FETCHING = new Fetching();
|
||||
public static final EcoEnchant BACKSTAB = new Backstab();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
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 org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Backstab extends EcoEnchant {
|
||||
public Backstab() {
|
||||
super(
|
||||
new EcoEnchantBuilder("backstab", EnchantmentType.NORMAL,5.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
|
||||
@Override
|
||||
public void onMeleeAttack(LivingEntity attacker, LivingEntity victim, int level, EntityDamageByEntityEvent event) {
|
||||
Vector victimLoc = victim.getLocation().toVector();
|
||||
Vector attackerLoc = attacker.getLocation().toVector();
|
||||
Vector locationDelta = victimLoc.subtract(attackerLoc);
|
||||
Vector attackerDirection = attacker.getLocation().getDirection();
|
||||
double dot = locationDelta.dot(attackerDirection);
|
||||
|
||||
if(dot > 0) return;
|
||||
|
||||
event.setDamage(event.getDamage() * ((level * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier-per-level")) + 1));
|
||||
}
|
||||
}
|
||||
26
Plugin/src/main/resources/enchants/normal/backstab.yml
Normal file
26
Plugin/src/main/resources/enchants/normal/backstab.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Backstab EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 5.0 # Don't edit this.
|
||||
|
||||
name: "Backstab"
|
||||
description: Increases damage when behind opponent
|
||||
enabled: true
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- sword
|
||||
- axe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
damage-multiplier-per-level: 0.1
|
||||
@@ -12,7 +12,7 @@ obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
|
||||
@@ -22,4 +22,4 @@ general-config:
|
||||
maximum-level: 5
|
||||
|
||||
config:
|
||||
damage-multiplier-per-level: 0.05
|
||||
damage-multiplier-per-level: 0.15
|
||||
Reference in New Issue
Block a user