mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Added Corrosive
This commit is contained in:
parent
aae45e98d5
commit
bc994608fb
@ -192,6 +192,7 @@ public class EcoEnchants {
|
|||||||
public static final EcoEnchant END_INFUSION = new EndInfusion();
|
public static final EcoEnchant END_INFUSION = new EndInfusion();
|
||||||
public static final EcoEnchant DIURNAL = new Diurnal();
|
public static final EcoEnchant DIURNAL = new Diurnal();
|
||||||
public static final EcoEnchant MARKING = new Marking();
|
public static final EcoEnchant MARKING = new Marking();
|
||||||
|
public static final EcoEnchant CORROSIVE = new Corrosive();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.comphenix.protocol.PacketType;
|
||||||
|
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.ItemDurability;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Corrosive extends EcoEnchant {
|
||||||
|
public Corrosive() {
|
||||||
|
super(
|
||||||
|
new EcoEnchantBuilder("corrosive", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.BOW, Target.Applicable.CROSSBOW}, 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 Player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||||
|
Player victim = (Player) event.getEntity();
|
||||||
|
|
||||||
|
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||||
|
|
||||||
|
if (!HasEnchant.playerHeld(player, this)) return;
|
||||||
|
|
||||||
|
int level = HasEnchant.getPlayerLevel(player, this);
|
||||||
|
|
||||||
|
ArrayList<ItemStack> armor = new ArrayList<ItemStack>(Arrays.asList(victim.getInventory().getArmorContents()));
|
||||||
|
if (armor.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (ItemStack armorPiece : armor) {
|
||||||
|
if (armorPiece == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (Target.Applicable.HELMET.getMaterials().contains(armorPiece.getType())) {
|
||||||
|
ItemDurability.damageItem(player, player.getInventory().getHelmet(), level, 39);
|
||||||
|
}
|
||||||
|
if (Target.Applicable.CHESTPLATE.getMaterials().contains(armorPiece.getType())) {
|
||||||
|
ItemDurability.damageItem(player, player.getInventory().getChestplate(), level, 38);
|
||||||
|
}
|
||||||
|
if (Target.Applicable.LEGGINGS.getMaterials().contains(armorPiece.getType())) {
|
||||||
|
ItemDurability.damageItem(player, player.getInventory().getLeggings(), level, 37);
|
||||||
|
}
|
||||||
|
if (Target.Applicable.BOOTS.getMaterials().contains(armorPiece.getType())) {
|
||||||
|
ItemDurability.damageItem(player, player.getInventory().getBoots(), level, 36);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
Plugin/src/main/resources/enchants/normal/corrosive.yml
Normal file
23
Plugin/src/main/resources/enchants/normal/corrosive.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# Corrosive EcoEnchant
|
||||||
|
#
|
||||||
|
|
||||||
|
config-version: 4.0 # Don't edit this.
|
||||||
|
|
||||||
|
name: "Corrosive"
|
||||||
|
|
||||||
|
description: Damages your opponents armor.
|
||||||
|
|
||||||
|
obtaining:
|
||||||
|
table: true
|
||||||
|
villager: true
|
||||||
|
loot: true
|
||||||
|
rarity: legendary
|
||||||
|
|
||||||
|
general-config:
|
||||||
|
grindstoneable: true
|
||||||
|
conflicts: []
|
||||||
|
maximum-level: 2
|
||||||
|
|
||||||
|
config:
|
||||||
|
# No config is available for this enchantment
|
@ -211,6 +211,7 @@ permissions:
|
|||||||
ecoenchants.fromtable.endinfusion: true
|
ecoenchants.fromtable.endinfusion: true
|
||||||
ecoenchants.fromtable.diurnal: true
|
ecoenchants.fromtable.diurnal: true
|
||||||
ecoenchants.fromtable.marking: true
|
ecoenchants.fromtable.marking: true
|
||||||
|
ecoenchants.fromtable.corrosive: true
|
||||||
|
|
||||||
ecoenchants.updateannounce:
|
ecoenchants.updateannounce:
|
||||||
description: Informs admins of a new update
|
description: Informs admins of a new update
|
||||||
@ -717,3 +718,6 @@ permissions:
|
|||||||
ecoenchants.fromtable.marking:
|
ecoenchants.fromtable.marking:
|
||||||
description: Allows getting marking from an enchanting table
|
description: Allows getting marking from an enchanting table
|
||||||
default: true
|
default: true
|
||||||
|
ecoenchants.fromtable.corrosive:
|
||||||
|
description: Allows getting corrosive from an enchanting table
|
||||||
|
default: true
|
Loading…
Reference in New Issue
Block a user