Fixes an issue where items can be a block but not an item #332

This commit is contained in:
tastybento 2024-09-18 14:49:29 -07:00
parent 58bcf9e08b
commit b66ecb23d1

View File

@ -11,6 +11,8 @@ import java.util.stream.Collectors;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -58,6 +60,7 @@ public class ValuePanel
this.activeFilter = Filter.NAME_ASC; this.activeFilter = Filter.NAME_ASC;
this.materialRecordList = Arrays.stream(Material.values()). this.materialRecordList = Arrays.stream(Material.values()).
filter(Material::isBlock). filter(Material::isBlock).
filter(Material::isItem). // Remove things like PITCHER_CROP
filter(m -> !m.name().startsWith("LEGACY_")). filter(m -> !m.name().startsWith("LEGACY_")).
filter(this.addon.getBlockConfig()::isNotHiddenBlock). filter(this.addon.getBlockConfig()::isNotHiddenBlock).
map(material -> map(material ->
@ -584,6 +587,7 @@ public class ValuePanel
return null; return null;
} }
@SuppressWarnings("deprecation")
int index = this.pageIndex * slot.amountMap().getOrDefault(BLOCK, 1) + slot.slot(); int index = this.pageIndex * slot.amountMap().getOrDefault(BLOCK, 1) + slot.slot();
if (index >= this.elementList.size()) if (index >= this.elementList.size())