mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-26 20:27:38 +01:00
Added Blind and Sickening
This commit is contained in:
parent
a7c515b276
commit
b8bc9d983f
@ -195,6 +195,8 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant CORROSIVE = new Corrosive();
|
||||
public static final EcoEnchant WOUND = new Wound();
|
||||
public static final EcoEnchant FINALITY = new Finality();
|
||||
public static final EcoEnchant BLIND = new Blind();
|
||||
public static final EcoEnchant SICKENING = new Sickening();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
@ -0,0 +1,57 @@
|
||||
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 com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
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.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Blind extends EcoEnchant {
|
||||
public Blind() {
|
||||
super(
|
||||
new EcoEnchantBuilder("blind", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.CROSSBOW, Target.Applicable.BOW}, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Arrow))
|
||||
return;
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
if(!(((Arrow) event.getDamager()).getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||
|
||||
if(event.isCancelled()) 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;
|
||||
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
||||
victim.setVelocity(new Vector(0, 0, 0));
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration * level, level));
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
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 com.willfp.ecoenchants.integrations.antigrief.AntigriefManager;
|
||||
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.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Sickening extends EcoEnchant {
|
||||
public Sickening() {
|
||||
super(
|
||||
new EcoEnchantBuilder("sickening", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.CROSSBOW, Target.Applicable.BOW}, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Arrow))
|
||||
return;
|
||||
if (!(event.getEntity() instanceof LivingEntity))
|
||||
return;
|
||||
if(!(((Arrow) event.getDamager()).getShooter() instanceof Player))
|
||||
return;
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
|
||||
LivingEntity victim = (LivingEntity) event.getEntity();
|
||||
|
||||
if(!AntigriefManager.canInjure(player, victim)) return;
|
||||
|
||||
if(event.isCancelled()) 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;
|
||||
|
||||
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
|
||||
|
||||
victim.setVelocity(new Vector(0, 0, 0));
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, duration * level, level));
|
||||
}
|
||||
}
|
24
Plugin/src/main/resources/enchants/normal/blind.yml
Normal file
24
Plugin/src/main/resources/enchants/normal/blind.yml
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Blind EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Blind"
|
||||
|
||||
description: Chance of blinding your opponent.
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 2
|
||||
|
||||
config:
|
||||
chance-per-level: 3 #as percentage
|
||||
duration-per-level: 30
|
24
Plugin/src/main/resources/enchants/normal/sickening.yml
Normal file
24
Plugin/src/main/resources/enchants/normal/sickening.yml
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Sickening EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Sickening"
|
||||
|
||||
description: Chance of nauseating your opponent.
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: legendary
|
||||
|
||||
general-config:
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 2
|
||||
|
||||
config:
|
||||
chance-per-level: 3 #as percentage
|
||||
duration-per-level: 30
|
@ -214,6 +214,8 @@ permissions:
|
||||
ecoenchants.fromtable.corrosive: true
|
||||
ecoenchants.fromtable.wound: true
|
||||
ecoenchants.fromtable.finality: true
|
||||
ecoenchants.fromtable.sickening: true
|
||||
ecoenchants.fromtable.blind: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -728,4 +730,10 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.finality:
|
||||
description: Allows getting finality from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.blind:
|
||||
description: Allows getting blind from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.sickening:
|
||||
description: Allows getting sickening from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user