Skip to content

Commit

Permalink
restructure util
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 13, 2024
1 parent 3f77c84 commit 85689b3
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions shared/src/main/java/me/xginko/aef/utils/MaterialUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,66 +21,66 @@

public class MaterialUtil {

public static final Set<Material> POTIONS = Arrays.stream(XMaterial.values())
.filter(xMaterial -> xMaterial.name().toUpperCase().contains("POTION"))
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
public static final Set<Material> INVENTORY_HOLDERS = Arrays.stream(Material.values())
.filter(Material::isItem) // Prevents loading issues in 1.20.6+
.map(ItemStack::new)
.filter(itemStack -> itemStack.getItemMeta() instanceof BlockStateMeta)
.map(itemStack -> ((BlockStateMeta) itemStack.getItemMeta()).getBlockState())
.filter(blockState -> blockState instanceof InventoryHolder)
.map(BlockState::getType)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> PISTONS = Arrays.stream(XMaterial.values())
.filter(xMaterial -> xMaterial.name().toUpperCase().contains("PISTON"))
public static final Set<Material> LECTERN_BOOKS = XTag.ITEMS_LECTERN_BOOKS.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> SPAWN_EGGS = Arrays.stream(XMaterial.values())
.filter(xMaterial -> xMaterial.name().toUpperCase().endsWith("_SPAWN_EGG"))
public static final Set<Material> SIGNS = XTag.SIGNS.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> LECTERN_BOOKS = XTag.ITEMS_LECTERN_BOOKS.getValues().stream()
public static final Set<Material> TRAPDOORS = XTag.TRAPDOORS.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> SIGNS = XTag.SIGNS.getValues().stream()
public static final Set<Material> PRESSURE_PLATES = XTag.PRESSURE_PLATES.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> TRAPDOORS = XTag.TRAPDOORS.getValues().stream()
public static final Set<Material> SHULKER_BOXES = XTag.SHULKER_BOXES.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> PRESSURE_PLATES = XTag.PRESSURE_PLATES.getValues().stream()
public static final Set<Material> ANVILS = XTag.ANVIL.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> SHULKER_BOXES = XTag.SHULKER_BOXES.getValues().stream()
public static final Set<Material> BEDS = XTag.BEDS.getValues().stream()
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> ANVILS = XTag.ANVIL.getValues().stream()
public static final Set<Material> POTIONS = Arrays.stream(XMaterial.values())
.filter(xMaterial -> xMaterial.name().toUpperCase().contains("POTION"))
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> BEDS = XTag.BEDS.getValues().stream()
public static final Set<Material> PISTONS = Arrays.stream(XMaterial.values())
.filter(xMaterial -> xMaterial.name().toUpperCase().contains("PISTON"))
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> INVENTORY_HOLDERS = Arrays.stream(Material.values())
.filter(Material::isItem) // Prevents loading issues in 1.20.6+
.map(ItemStack::new)
.filter(itemStack -> itemStack.getItemMeta() instanceof BlockStateMeta)
.map(itemStack -> ((BlockStateMeta) itemStack.getItemMeta()).getBlockState())
.filter(blockState -> blockState instanceof InventoryHolder)
.map(BlockState::getType)
public static final Set<Material> SPAWN_EGGS = Arrays.stream(XMaterial.values())
.filter(xMaterial -> xMaterial.name().toUpperCase().endsWith("_SPAWN_EGG"))
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> SLAB_LIKE = Stream.concat(
Expand All @@ -104,6 +104,15 @@ public class MaterialUtil {
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

// Blocks that the player gets lowered into slightly when walking on them
public static final Set<Material> SINK_IN_BLOCKS = Stream.of(
XMaterial.SOUL_SAND,
XMaterial.FARMLAND,
XMaterial.MUD)
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static final Set<Material> SOLID_INDESTRUCTIBLES = Stream.of(
XMaterial.BEDROCK,
XMaterial.END_PORTAL_FRAME,
Expand Down Expand Up @@ -135,15 +144,6 @@ public class MaterialUtil {
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

// Blocks that the player gets lowered into slightly when walking on them
public static final Set<Material> SINK_IN_BLOCKS = Stream.of(
XMaterial.SOUL_SAND,
XMaterial.FARMLAND,
XMaterial.MUD)
.filter(XMaterial::isSupported)
.map(XMaterial::parseMaterial)
.collect(Collectors.toCollection(() -> EnumSet.noneOf(Material.class)));

public static boolean isElytra(@Nullable ItemStack itemStack) {
return itemStack != null && itemStack.getType() == XMaterial.ELYTRA.parseMaterial();
}
Expand Down

0 comments on commit 85689b3

Please sign in to comment.