From 7ca5c7300a8f37ec259559dd32c953d6e5d42adb Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Fri, 5 Nov 2021 20:18:04 +0300 Subject: [PATCH] Added blacklisted-blocks config option to Instantaneous enchantment --- .../ecoenchants/normal/Instantaneous.java | 12 +++++++++++- .../main/resources/enchants/normal/instantaneous.yml | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java index f4fa7019..06929c3b 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Instantaneous.java @@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.normal; import com.willfp.eco.core.integrations.anticheat.AnticheatManager; import com.willfp.ecoenchants.enchantments.EcoEnchant; +import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; import org.bukkit.Material; @@ -10,6 +11,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.BlockDamageEvent; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; + public class Instantaneous extends EcoEnchant { public Instantaneous() { super( @@ -39,7 +43,13 @@ public class Instantaneous extends EcoEnchant { return; } - if (block.getType() == Material.BEDROCK) { + List blacklist = new ArrayList<>(); + + for (String s : this.getConfig().getStrings(EcoEnchants.CONFIG_LOCATION + "blacklisted-blocks")) { + blacklist.add(Material.getMaterial(s)); + } + + if (blacklist.contains(block.getType())) { return; } diff --git a/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml b/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml index b6a15725..77fb03e4 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/normal/instantaneous.yml @@ -28,4 +28,10 @@ general-config: maximum-level: 7 config: - chance-per-level: 3 \ No newline at end of file + chance-per-level: 3 + blacklisted-blocks: + - BEDROCK + - OBSIDIAN + - END_PORTAL + - END_PORTAL_GATE + - NETHER_PORTAL \ No newline at end of file