mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-25 00:51:20 +01:00
Added Backstab
This commit is contained in:
parent
cd525553ac
commit
9cc3a79783
@ -1,69 +1,9 @@
|
||||
package com.willfp.ecoenchants.enchantments;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AshArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CloudsArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CrimsonArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DamageArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DragonArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DustArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EmeraldArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EnchantmentArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EndArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.FireArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.HeartArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.HoneyArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.InkArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.LavaArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.LimeArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MagicArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MagmaArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MusicArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.NetherArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.RedstoneArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SmokeArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SnowArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SoulArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SoulFireArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SparkleArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.TearArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.TotemArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WarpedArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WaterArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WitchArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.ZapArtifact;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.BreaklessnessCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.CallingCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.DecayCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.FragilityCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HarmlessnessCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HungerCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.InaccuracyCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.MisfortuneCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.PermanenceCurse;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.*;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Aiming;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Annihilate;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Bladed;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Bolt;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Carve;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Confusion;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Energizing;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Force;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Frenzy;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Harpoon;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Indestructibility;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Instability;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Intellect;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.LifeSteal;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Pentashot;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Preservation;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Prosperity;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Razor;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Repairing;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Spring;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Streamlining;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Volatile;
|
||||
import com.willfp.ecoenchants.enchantments.ecoenchants.special.*;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -294,6 +234,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant ASH_ARTIFACT = new AshArtifact();
|
||||
public static final EcoEnchant WARPED_ARTIFACT = new WarpedArtifact();
|
||||
public static final EcoEnchant TEAR_ARTIFACT = new TearArtifact();
|
||||
public static final EcoEnchant BACKSTAB = new Backstab();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
@ -0,0 +1,34 @@
|
||||
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.LivingEntity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public final 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 pDir = attacker.getLocation().getDirection();
|
||||
Vector eDir = victim.getLocation().getDirection();
|
||||
double xv = pDir.getX() * eDir.getZ() - pDir.getZ() * eDir.getX();
|
||||
double zv = pDir.getX() * eDir.getX() + pDir.getZ() * eDir.getZ();
|
||||
double angle = Math.atan2(xv, zv); // Value between -π and +π
|
||||
double angleInDegrees = (angle * 180) / Math.PI;
|
||||
|
||||
if(angleInDegrees > 60 || angleInDegrees < -32)
|
||||
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: rare
|
||||
|
||||
general-config:
|
||||
targets:
|
||||
- sword
|
||||
- axe
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
damage-multiplier-per-level: 0.1
|
@ -256,6 +256,7 @@ permissions:
|
||||
ecoenchants.fromtable.warpedartifact: true
|
||||
ecoenchants.fromtable.ashartifact: true
|
||||
ecoenchants.fromtable.tearartifact: true
|
||||
ecoenchants.fromtable.backstab: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -890,4 +891,7 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.tearartifact:
|
||||
description: Allows getting tear artifact from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.backstab:
|
||||
description: Allows getting backstab from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user