From 6b84a23719250e99ddb4651f8f7e058218ed5f59 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Thu, 21 Apr 2022 00:30:10 +0300 Subject: [PATCH] Updated Aiming (added configurable targets) --- .../ecoenchants/special/Aiming.java | 10 ++++++++++ .../resources/enchants/special/aiming.yml | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java index 1bd172f6..387bee5f 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Aiming.java @@ -1,5 +1,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; +import com.willfp.eco.core.entities.Entities; +import com.willfp.eco.core.entities.TestableEntity; import com.willfp.eco.core.integrations.antigrief.AntigriefManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; @@ -15,16 +17,23 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @SuppressWarnings({"unchecked", "unused"}) public class Aiming extends EcoEnchant { + private final List targets = new ArrayList<>(); + public Aiming() { super( "aiming", EnchantmentType.SPECIAL ); + targets.clear(); + targets.addAll(this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "targets").stream().map( + Entities::lookup + ).toList()); } @EventHandler @@ -74,6 +83,7 @@ public class Aiming extends EcoEnchant { Runnable runnable = this.getPlugin().getRunnableFactory().create(bukkitRunnable -> { List nearbyEntities = (List) (List) Arrays.asList(arrow.getNearbyEntities(finalDistance, finalDistance, finalDistance).stream() .filter(entity -> entity instanceof LivingEntity) + .filter(entity -> this.targets.stream().anyMatch(target -> target.matches(entity))) .map(entity -> (LivingEntity) entity) .filter(entity -> !entity.equals(player)) .filter(entity -> !(entity instanceof Enderman)) diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml b/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml index dfb08f46..fc053c45 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/aiming.yml @@ -29,4 +29,21 @@ config: scale-on-force: true # Scale distance based on bow pull require-full-force: true # Require full bow pull (works with rapid) If true, then scale-on-force is irrelevant. check-ticks: 10 # Ticks between rotations - checks-per-level: 2 # Amount of times to rotate arrow per level (prevents "floating") \ No newline at end of file + checks-per-level: 2 # Amount of times to rotate arrow per level (prevents "floating") + targets: # List of entity lookups (https://plugins.auxilor.io/all-plugins/the-entity-lookup-system) + - "zombie" + - "creeper" + - "player" + - "skeleton" + - "spider" + - "wither" + - "ender_dragon" + - "wither_skeleton" + - "husk" + - "piglin" + - "hoglin" + - "pig" + - "chicken" + - "cow" + - "cave_spider" + - "horse"