mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-10 03:31:20 +01:00
Added Defender
This commit is contained in:
parent
b8bc9d983f
commit
e765b7c989
@ -197,6 +197,7 @@ public class EcoEnchants {
|
|||||||
public static final EcoEnchant FINALITY = new Finality();
|
public static final EcoEnchant FINALITY = new Finality();
|
||||||
public static final EcoEnchant BLIND = new Blind();
|
public static final EcoEnchant BLIND = new Blind();
|
||||||
public static final EcoEnchant SICKENING = new Sickening();
|
public static final EcoEnchant SICKENING = new Sickening();
|
||||||
|
public static final EcoEnchant DEFENDER = new Defender();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all registered {@link EcoEnchant}s
|
* Get all registered {@link EcoEnchant}s
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
|
||||||
|
|
||||||
|
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||||
|
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||||
|
import com.willfp.ecoenchants.nms.Target;
|
||||||
|
import com.willfp.ecoenchants.util.HasEnchant;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
public class Defender extends EcoEnchant {
|
||||||
|
public Defender() {
|
||||||
|
super(
|
||||||
|
new EcoEnchantBuilder("defender", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.SWORD, Target.Applicable.AXE}, 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 Tameable))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||||
|
Tameable entity = (Tameable) event.getEntity();
|
||||||
|
if(entity.getOwner() == null) return;
|
||||||
|
if(!entity.getOwner().equals(player)) return;
|
||||||
|
|
||||||
|
if (!HasEnchant.playerHeld(player, this)) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
22
Plugin/src/main/resources/enchants/normal/defender.yml
Normal file
22
Plugin/src/main/resources/enchants/normal/defender.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#
|
||||||
|
# Defender EcoEnchant
|
||||||
|
#
|
||||||
|
|
||||||
|
config-version: 4.0 # Don't edit this.
|
||||||
|
|
||||||
|
name: "Defender"
|
||||||
|
|
||||||
|
description: Prevents damaging your own pets.
|
||||||
|
|
||||||
|
obtaining:
|
||||||
|
table: true
|
||||||
|
villager: true
|
||||||
|
loot: true
|
||||||
|
rarity: uncommon
|
||||||
|
|
||||||
|
general-config:
|
||||||
|
grindstoneable: true
|
||||||
|
conflicts: []
|
||||||
|
|
||||||
|
config:
|
||||||
|
# No config available for this enchantment
|
@ -216,6 +216,7 @@ permissions:
|
|||||||
ecoenchants.fromtable.finality: true
|
ecoenchants.fromtable.finality: true
|
||||||
ecoenchants.fromtable.sickening: true
|
ecoenchants.fromtable.sickening: true
|
||||||
ecoenchants.fromtable.blind: true
|
ecoenchants.fromtable.blind: true
|
||||||
|
ecoenchants.fromtable.defender: true
|
||||||
|
|
||||||
ecoenchants.updateannounce:
|
ecoenchants.updateannounce:
|
||||||
description: Informs admins of a new update
|
description: Informs admins of a new update
|
||||||
@ -737,3 +738,6 @@ permissions:
|
|||||||
ecoenchants.fromtable.sickening:
|
ecoenchants.fromtable.sickening:
|
||||||
description: Allows getting sickening from an enchanting table
|
description: Allows getting sickening from an enchanting table
|
||||||
default: true
|
default: true
|
||||||
|
ecoenchants.fromtable.defender:
|
||||||
|
description: Allows getting defender from an enchanting table
|
||||||
|
default: true
|
Loading…
Reference in New Issue
Block a user