mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Autosell changes
This commit is contained in:
parent
8138a17f6c
commit
6122930618
@ -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<BlockDropItemEvent> noRepeat = new HashSet<>();
|
||||
|
||||
private static final Set<Material> 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<ItemStack> 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)
|
||||
|
Loading…
Reference in New Issue
Block a user