Added Curse of Inaccuracy

Changed default curse obtaining values
This commit is contained in:
Auxilor 2020-08-30 11:50:22 +01:00
parent 0a6084703f
commit 9f889ac323
6 changed files with 77 additions and 2 deletions

View File

@ -225,6 +225,7 @@ public class EcoEnchants {
public static final EcoEnchant BLOCK_BREATHER = new BlockBreather();
public static final EcoEnchant VOLTAGE = new Voltage();
public static final EcoEnchant TRANSFUSE = new Transfuse();
public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse();
/**
* Get all registered {@link EcoEnchant}s

View File

@ -0,0 +1,48 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.curse;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks;
import com.willfp.ecoenchants.nms.Target;
import com.willfp.ecoenchants.util.Rand;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.util.Vector;
public class InaccuracyCurse extends EcoEnchant {
public InaccuracyCurse() {
super(
new EcoEnchantBuilder("inaccuracy_curse", EnchantmentType.CURSE, Target.Applicable.BOW, 4.0)
);
}
// START OF LISTENERS
@EventHandler
public void onShoot(EntityShootBowEvent event) {
if (event.getProjectile().getType() != EntityType.ARROW)
return;
if (!(event.getEntity() instanceof Player))
return;
Player player = (Player) event.getEntity();
if (!EnchantChecks.mainhand(player, this)) return;
double spread = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "spread");
Vector velocity = event.getProjectile().getVelocity().clone();
velocity.add(new Vector(Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread), Rand.randFloat(-spread, spread)));
event.getProjectile().setVelocity(velocity);
}
}

View File

@ -9,7 +9,7 @@ name: "Curse of Breaklessness"
description: Chance to prevent block breaking.
obtaining:
table: true
table: false
villager: true
loot: true
rarity: legendary

View File

@ -0,0 +1,22 @@
#
# Curse of Inaccuracy EcoEnchant
#
config-version: 4.0 # Don't edit this.
name: "Curse of Inaccuracy"
description: Arrows fire incorrectly.
obtaining:
table: false
villager: true
loot: true
rarity: legendary
general-config:
grindstoneable: true
conflicts: []
config:
spread: 0.2

View File

@ -9,7 +9,7 @@ name: "Curse of Misfortune"
description: Chance for blocks to not drop items.
obtaining:
table: true
table: false
villager: true
loot: true
rarity: legendary

View File

@ -244,6 +244,7 @@ permissions:
ecoenchants.fromtable.blockbreather: true
ecoenchants.fromtable.voltage: true
ecoenchants.fromtable.transfuse: true
ecoenchants.fromtable.inaccuracycurse: true
ecoenchants.updateannounce:
description: Informs admins of a new update
@ -848,4 +849,7 @@ permissions:
default: true
ecoenchants.fromtable.transfuse:
description: Allows getting transfuse from an enchanting table
default: true
ecoenchants.fromtable.inaccuracycurse:
description: Allows getting curse of inaccuracy from an enchanting table
default: true