From 59b098b7e88a49eba01c0d92ff84f23833823ad6 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 8 Sep 2021 10:36:36 +0100 Subject: [PATCH 1/8] Fixed rapid fastbow anticheat trigger --- .../enchantments/ecoenchants/normal/Rapid.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java index 9841544e..e1225eec 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Rapid.java @@ -1,10 +1,12 @@ 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 org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityShootBowEvent; import org.jetbrains.annotations.NotNull; @@ -20,6 +22,9 @@ public class Rapid extends EcoEnchant { @NotNull final Arrow arrow, final int level, @NotNull final EntityShootBowEvent event) { + if (shooter instanceof Player player) { + AnticheatManager.exemptPlayer(player); + } double multiplier = 1 - ((this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-faster-per-level") / 100) * level); if (event.getForce() < multiplier) { @@ -28,5 +33,9 @@ public class Rapid extends EcoEnchant { double force = 1 / event.getForce(); event.getProjectile().setVelocity(event.getProjectile().getVelocity().multiply(force)); + + if (shooter instanceof Player player) { + AnticheatManager.unexemptPlayer(player); + } } } From 4e1fefdb3a7dec0dd809276ef210fc512f5d0d87 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 8 Sep 2021 10:36:47 +0100 Subject: [PATCH 2/8] Updated to 8.10.10 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7df2746b..bf4ad2d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 8.10.9 +version = 8.10.10 plugin-name = EcoEnchants \ No newline at end of file From 966ab49af1cb8d15d704e433a93ad857998238f2 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Wed, 8 Sep 2021 18:47:30 +0300 Subject: [PATCH 3/8] Added disable-on-players option for Razor, Bladed and Force enchantments --- .../ecoenchants/enchantments/ecoenchants/special/Bladed.java | 2 ++ .../ecoenchants/enchantments/ecoenchants/special/Force.java | 2 ++ .../ecoenchants/enchantments/ecoenchants/special/Razor.java | 1 + .../core-plugin/src/main/resources/enchants/special/bladed.yml | 1 + .../core-plugin/src/main/resources/enchants/special/force.yml | 1 + .../core-plugin/src/main/resources/enchants/special/razor.yml | 1 + 6 files changed, 8 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java index 4ad1a095..83341309 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java @@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Trident; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; @@ -21,6 +22,7 @@ public class Bladed extends EcoEnchant { @NotNull final Trident trident, final int level, @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return; double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-multiplier"); double damage = event.getDamage(); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java index e92ee028..099adbbe 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; @@ -21,6 +22,7 @@ public class Force extends EcoEnchant { @NotNull final Arrow arrow, final int level, @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return; double damage = event.getDamage(); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double bonus = (multiplier * (level + 6)) + 1; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java index bef73e33..ec92ace3 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java @@ -20,6 +20,7 @@ public class Razor extends EcoEnchant { @NotNull final LivingEntity victim, final int level, @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return; double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage"); double extra = (level * perLevelMultiplier) + baseDamage; diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml b/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml index f199eba3..a657fac4 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml @@ -31,6 +31,7 @@ general-config: maximum-level: 5 config: + disable-on-players: false # Should this enchantment only boost damage on mobs base-multiplier: 1.5 # Percent more damage to do as base multiplier: 0.5 # 1 + (Level * Multiplier) is multiplied with the damage # To explain, Bladed V would be 4x more damage: 1.5 + (5*0.5) diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/force.yml b/eco-core/core-plugin/src/main/resources/enchants/special/force.yml index 516d905e..9049a13f 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/force.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/force.yml @@ -30,4 +30,5 @@ general-config: maximum-level: 8 config: + disable-on-players: false # Should this enchantment only boost damage on mobs multiplier: 0.25 # Formula is (multiplier * (level + 6) + 1)*damage | Default functions as power 5 + level, eg force 2 = power 7 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml b/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml index ce353329..a3037d16 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml @@ -32,6 +32,7 @@ general-config: maximum-level: 8 config: + disable-on-players: false # Should this enchantment only boost damage on mobs multiplier: 0.3 # Vanilla sharpness is 0.5*level + 0.5 extra damage. Razor formula is multiplier*level + base extra damage. base-damage: 10 # Vanilla Smite 5/BOA 5 extra damage is 12.5 decrease-if-cooldown: true \ No newline at end of file From a9c345317c5afbb8ad35090a2f52d0bc9fce1c0a Mon Sep 17 00:00:00 2001 From: Akiranya Date: Thu, 9 Sep 2021 16:36:57 +0800 Subject: [PATCH 4/8] Fixed Necrotic --- .../ecoenchants/enchantments/ecoenchants/normal/Necrotic.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java index 8be84217..53e3c73a 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Necrotic.java @@ -55,6 +55,10 @@ public class Necrotic extends EcoEnchant { return; } + if (!event.getEntity().getMetadata("eco-target").isEmpty()) { + return; + } + ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1); new DropQueue(player) From b9cd266d0eaa892391925216831b60b555602dde Mon Sep 17 00:00:00 2001 From: Akiranya Date: Thu, 9 Sep 2021 17:05:49 +0800 Subject: [PATCH 5/8] Fixed Soulbound bug There are some cases where the player's inventory is not empty right after respawning. For example, ItemsAdder gives a death map right after the player respawns. In this case, EcoEnchants won't give back soulbound items to the player, causing the items just disappeared. I fix this by checking if there is any soulbound items right after respawning, instead of simply checking whether the player's inventory is empty or not. More robust logic to handle such case is expected. My solution is just a workaround. --- .../enchantments/ecoenchants/special/Soulbound.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java index 26ec8e35..6bd59dcb 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java @@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils; -import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -97,9 +97,10 @@ public class Soulbound extends EcoEnchant { player.setMetadata("soulbound-items", this.getPlugin().getMetadataValueFactory().create(soulboundItems)); } - public boolean hasEmptyInventory(@NotNull final Player player) { + public boolean hasSoulboundItems(@NotNull final Player player) { + final NamespacedKey soulbound = this.getPlugin().getNamespacedKeyFactory().create("soulbound"); for (ItemStack itemStack : player.getInventory().getContents()) { - if (itemStack != null && itemStack.getType() != Material.AIR) { + if (itemStack != null && itemStack.getItemMeta().getPersistentDataContainer().has(soulbound, PersistentDataType.INTEGER)) { return false; } } @@ -111,7 +112,7 @@ public class Soulbound extends EcoEnchant { Player player = event.getPlayer(); this.getPlugin().getScheduler().runLater(() -> { - if (!hasEmptyInventory(player)) { + if (!hasSoulboundItems(player)) { return; } @@ -142,6 +143,7 @@ public class Soulbound extends EcoEnchant { @EventHandler(priority = EventPriority.HIGHEST) public void onDeath(@NotNull final PlayerDeathEvent event) { - event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER)); + final NamespacedKey soulbound = this.getPlugin().getNamespacedKeyFactory().create("soulbound"); + event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(soulbound, PersistentDataType.INTEGER)); } } From 1f0c9d8a87cbbc347eb81aaebc52b42a021f4b7b Mon Sep 17 00:00:00 2001 From: Akiranya Date: Thu, 9 Sep 2021 17:16:32 +0800 Subject: [PATCH 6/8] BukkitScheduler#runTask() already runs the task on next tick --- .../enchantments/ecoenchants/special/Soulbound.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java index 6bd59dcb..e816686a 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java @@ -111,7 +111,7 @@ public class Soulbound extends EcoEnchant { public void onSoulboundRespawn(@NotNull final PlayerRespawnEvent event) { Player player = event.getPlayer(); - this.getPlugin().getScheduler().runLater(() -> { + this.getPlugin().getScheduler().run(() -> { if (!hasSoulboundItems(player)) { return; } @@ -138,7 +138,7 @@ public class Soulbound extends EcoEnchant { } player.removeMetadata("soulbound-items", this.getPlugin()); - }, 1); + }); } @EventHandler(priority = EventPriority.HIGHEST) From 96032c81e23c600304f0e68e39c358b957ee803a Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 9 Sep 2021 12:42:32 +0100 Subject: [PATCH 7/8] Updated to 8.10.11 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bf4ad2d7..307774d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 8.10.10 +version = 8.10.11 plugin-name = EcoEnchants \ No newline at end of file From 431581942d2a669ba5743d0f754934be6b1f1f39 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 9 Sep 2021 13:04:50 +0100 Subject: [PATCH 8/8] Reverting lore now uses FastItemStack --- .../willfp/ecoenchants/display/EnchantDisplay.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index 1d2fbbc3..32c26043 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -189,15 +189,16 @@ public class EnchantDisplay extends DisplayModule { return; } + FastItemStack fast = FastItemStack.wrap(itemStack); + + List lore = fast.getLore(); + lore.removeIf(s -> s.startsWith("§w")); + fast.setLore(lore); + ItemMeta meta = itemStack.getItemMeta(); assert meta != null; - List lore = meta.getLore() == null ? new ArrayList<>() : new ArrayList<>(meta.getLore()); - - lore.removeIf(s -> s.startsWith("§w")); - meta.setLore(lore); - meta.getPersistentDataContainer().remove(legacyV); if (!meta.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) {