CryptoMorin / XSeries

Library for cross-version Minecraft Bukkit support and various efficient API methods.
https://www.spigotmc.org/threads/378136/
MIT License
403 stars 126 forks source link

[XMaterial] - Implement Material#isItem() for 1.12 and Below #113

Closed GabrielAtlas closed 3 years ago

GabrielAtlas commented 3 years ago

Description Add a method that when use XMaterial.MATERIAL_ID.isItem() checks if item can be displayed in menu, versions like 1.8 don't have the [Material#isItem() method](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html#isItem()) and need to be checked manually

This code can be help you to return if material can be displayed in 1.8 in GUI menus:

private static final List<Material> blacklist = Arrays.asList(Material.FIRE, Material.LAVA, Material.MELON_STEM, Material.PUMPKIN_STEM, Material.REDSTONE_WIRE, Material.TRIPWIRE, 
            Material.WATER, Material.STATIONARY_WATER, Material.STATIONARY_LAVA, Material.BED_BLOCK, Material.PISTON_EXTENSION, Material.PISTON_MOVING_PIECE, Material.DOUBLE_STEP, 
            Material.CROPS, Material.BURNING_FURNACE, Material.SIGN_POST, Material.WOODEN_DOOR, Material.WALL_SIGN, Material.IRON_DOOR_BLOCK, Material.GLOWING_REDSTONE_ORE, Material.REDSTONE_TORCH_OFF,
            Material.SUGAR_CANE_BLOCK, Material.PORTAL, Material.CAKE_BLOCK, Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON, Material.NETHER_WARTS, Material.BREWING_STAND, Material.CAULDRON, 
            Material.FLOWER_POT, Material.CARROT, Material.POTATO, Material.SKULL, Material.REDSTONE_COMPARATOR_OFF, Material.REDSTONE_COMPARATOR_OFF, Material.STANDING_BANNER, Material.WALL_BANNER, Material.DAYLIGHT_DETECTOR_INVERTED,
            Material.DOUBLE_STONE_SLAB2, Material.SPRUCE_DOOR, Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.ACACIA_DOOR, Material.DARK_OAK_DOOR, Material.ENDER_PORTAL, Material.REDSTONE_LAMP_ON, Material.WOOD_DOUBLE_STEP, Material.COCOA,Material.AIR, Material.SOIL, Material.CACTUS, Material.MOB_SPAWNER, Material.DRAGON_EGG, Material.BARRIER, Material.WOOD_PLATE, Material.STONE_PLATE, Material.IRON_PLATE, Material.GOLD_PLATE,
            Material.REDSTONE_TORCH_OFF, Material.REDSTONE_TORCH_ON, Material.GLOWING_REDSTONE_ORE, Material.DOUBLE_STONE_SLAB2, Material.REDSTONE_LAMP_ON, Material.CAULDRON, Material.BED_BLOCK, Material.PISTON_EXTENSION, Material.PISTON_MOVING_PIECE, 
            Material.DOUBLE_STEP, Material.BURNING_FURNACE, Material.WOODEN_DOOR, Material.SIGN_POST, Material.WALL_SIGN, Material.SUGAR_CANE_BLOCK, Material.IRON_DOOR_BLOCK, Material.CAKE_BLOCK, Material.DIODE_BLOCK_ON, Material.DIODE_BLOCK_OFF, 
            Material.BREWING_STAND, Material.ENDER_PORTAL, Material.WOOD_DOUBLE_STEP, Material.DOUBLE_PLANT, Material.DAYLIGHT_DETECTOR_INVERTED, Material.STANDING_BANNER, Material.WALL_BANNER);

Congrats, Atlas.

CryptoMorin commented 3 years ago

Sounds good, yeah. I use this method myself sometimes. I guess I'll just take Spigot's 1.13 isItem() method and remove the 1.13 materials.

GabrielAtlas commented 3 years ago

Sounds good, yeah. I use this method myself sometimes. I guess I'll just take Spigot's 1.13 isItem() method and remove the 1.13 materials.

Yeah, works too 😁

CryptoMorin commented 3 years ago

Added in v7.9.1.1