From 6122930618cee7b232cbed0c91d38dac4a9c15b7 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 3 Sep 2021 11:07:04 +0100 Subject: [PATCH] Autosell changes --- .../willfp/ecoenchants/autosell/Autosell.java | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/eco-extensions/autosell/src/main/java/com/willfp/ecoenchants/autosell/Autosell.java b/eco-extensions/autosell/src/main/java/com/willfp/ecoenchants/autosell/Autosell.java index 58a7e640..708122d8 100644 --- a/eco-extensions/autosell/src/main/java/com/willfp/ecoenchants/autosell/Autosell.java +++ b/eco-extensions/autosell/src/main/java/com/willfp/ecoenchants/autosell/Autosell.java @@ -7,12 +7,9 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import com.willfp.ecoenchants.enchantments.util.EnchantChecks; import net.brcdev.shopgui.ShopGuiPlusApi; -import org.bukkit.Bukkit; import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Container; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -22,7 +19,6 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -30,13 +26,6 @@ import java.util.Set; public class Autosell extends EcoEnchant { private final Set noRepeat = new HashSet<>(); - private static final Set FORTUNE_MATERIALS = new HashSet<>( - Arrays.asList( - Material.GOLD_INGOT, - Material.IRON_INGOT - ) - ); - public Autosell() { super( "autosell", EnchantmentType.NORMAL @@ -80,28 +69,13 @@ public class Autosell extends EcoEnchant { return; } - BlockDropItemEvent dropEvent = new BlockDropItemEvent(block, block.getState(), player, event.getItems()); - noRepeat.add(dropEvent); - - Bukkit.getPluginManager().callEvent(dropEvent); - - if (dropEvent.getItems().isEmpty() || dropEvent.isCancelled()) { - return; - } - Collection drops = new ArrayList<>(); - for (Item item : dropEvent.getItems()) { + for (Item item : event.getItems()) { drops.add(item.getItemStack()); } - int fortune = EnchantChecks.getMainhandLevel(player, Enchantment.LOOT_BONUS_BLOCKS); - - for (ItemStack itemStack : drops) { - if (fortune > 0 && FORTUNE_MATERIALS.contains(itemStack.getType())) { - itemStack.setAmount((int) Math.round((Math.random() * ((double) fortune - 1)) + 1.1)); - } - + for (ItemStack itemStack : new ArrayList<>(drops)) { double price = ShopGuiPlusApi.getItemStackPriceSell(player, itemStack); if (price <= 0) { continue; @@ -112,7 +86,6 @@ public class Autosell extends EcoEnchant { drops.remove(itemStack); } - dropEvent.getItems().clear(); event.getItems().clear(); new DropQueue(player)