mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Fix #108, update XMaterial, start BoatFly
This commit is contained in:
1 parent
768331011e
commit
8de7ae1c59
4 files changed
+301
-166
No files matched your search
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* AntiCheatReloaded for Bukkit and Spigot.
|
||||||
|
* Copyright (c) 2012-2015 AntiCheat Team
|
||||||
|
* Copyright (c) 2016-2020 Rammelkast
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.rammelkast.anticheatreloaded.check.movement;
|
||||||
|
|
||||||
|
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||||
|
|
||||||
|
public class BoatFlyCheck {
|
||||||
|
|
||||||
|
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -101,7 +101,7 @@ public class FlightCheck {
|
|||||||
&& !Utilities.couldBeOnBoat(player)
|
&& !Utilities.couldBeOnBoat(player)
|
||||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
|
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
|
||||||
&& !VersionUtil.isSlowFalling(player) && !Utilities.isInWeb(player)
|
&& !VersionUtil.isSlowFalling(player) && !Utilities.isNearWeb(player)
|
||||||
&& movementManager.elytraEffectTicks <= 25)
|
&& movementManager.elytraEffectTicks <= 25)
|
||||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
|
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
|
||||||
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
|
+ Math.abs(movementManager.motionY - movementManager.lastMotionY) + ")");
|
||||||
@@ -155,7 +155,7 @@ public class FlightCheck {
|
|||||||
&& movementManager.motionY < 0 && !backend.justVelocity(player)
|
&& movementManager.motionY < 0 && !backend.justVelocity(player)
|
||||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||||
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
||||||
&& !Utilities.isInWeb(player) && movementManager.elytraEffectTicks <= 25
|
&& !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
|
||||||
&& !VersionUtil.isSlowFalling(player)) {
|
&& !VersionUtil.isSlowFalling(player)) {
|
||||||
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||||
double offset = Math.abs(gravitatedY - movementManager.motionY);
|
double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||||
|
|||||||
@@ -504,6 +504,33 @@ public final class Utilities {
|
|||||||
&& location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|
&& location.getBlock().getRelative(BlockFace.SOUTH_EAST).isLiquid()
|
||||||
&& location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
|
&& location.getBlock().getRelative(BlockFace.SOUTH_WEST).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a player is near a web
|
||||||
|
*
|
||||||
|
* @param player player to check
|
||||||
|
* @return true if near a web
|
||||||
|
*/
|
||||||
|
public static boolean isNearWeb(Player player) {
|
||||||
|
return isWeb(player.getLocation().getBlock())
|
||||||
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.DOWN))
|
||||||
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.UP))
|
||||||
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.NORTH))
|
||||||
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.SOUTH))
|
||||||
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.EAST))
|
||||||
|
|| isWeb(player.getLocation().getBlock().getRelative(BlockFace.WEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether a block is a web
|
||||||
|
*
|
||||||
|
* @param block block to check
|
||||||
|
* @return true if web
|
||||||
|
*/
|
||||||
|
public static boolean isWeb(Block block) {
|
||||||
|
return block.getType() == XMaterial.COBWEB.parseMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player is in a web
|
* Determine whether a player is in a web
|
||||||
|
|||||||
@@ -22,12 +22,26 @@
|
|||||||
*/
|
*/
|
||||||
package com.rammelkast.anticheatreloaded.util;
|
package com.rammelkast.anticheatreloaded.util;
|
||||||
|
|
||||||
import com.google.common.base.Enums;
|
import java.util.ArrayList;
|
||||||
import com.google.common.cache.Cache;
|
import java.util.Arrays;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import java.util.Collection;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import java.util.Collections;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import java.util.EnumMap;
|
||||||
import com.google.common.collect.Maps;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
@@ -35,19 +49,18 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import com.google.common.base.Enums;
|
||||||
import javax.annotation.Nullable;
|
import com.google.common.cache.Cache;
|
||||||
import java.util.*;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import java.util.concurrent.TimeUnit;
|
import com.google.common.cache.CacheLoader;
|
||||||
import java.util.regex.Pattern;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
|
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
|
||||||
* 1.13 and above as priority.
|
* 1.13 and above as priority.
|
||||||
* <p>
|
* <p>
|
||||||
* This class is mainly designed to support ItemStacks.
|
* This class is mainly designed to support ItemStacks. If you want to use it on blocks, you'll have to use
|
||||||
* If you want to use it on blocks you'll have to
|
* <a href="https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/XBlock.java">XBlock</a>
|
||||||
* use <a href="https://github.com/CryptoMorin/XSeries/blob/master/XBlock.java">XBlock</a>
|
|
||||||
* <p>
|
* <p>
|
||||||
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
* Pre-flattening: https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
||||||
* Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
* Materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||||
@@ -55,9 +68,13 @@ import java.util.regex.Pattern;
|
|||||||
* Material IDs: https://minecraft-ids.grahamedgecombe.com/
|
* Material IDs: https://minecraft-ids.grahamedgecombe.com/
|
||||||
* Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
|
* Material Source Code: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
|
||||||
* XMaterial v1: https://www.spigotmc.org/threads/329630/
|
* XMaterial v1: https://www.spigotmc.org/threads/329630/
|
||||||
|
* <p>
|
||||||
|
* This class will throw a "unsupported material" error if someone tries to use an item with an invalid data value which can only happen in 1.12 servers and below.
|
||||||
|
* To get an invalid item, (aka <a href="https://minecraft.fandom.com/wiki/Missing_Texture_Block">Missing Texture Block</a>) you can use the command
|
||||||
|
* <b>/give @p minecraft:dirt 1 10</b> where 1 is the item amount, and 10 is the data value. The material {@link #DIRT} with a data value of {@code 10} doesn't exist.
|
||||||
*
|
*
|
||||||
* @author Crypto Morin
|
* @author Crypto Morin
|
||||||
* @version 5.0.1
|
* @version 6.0.2
|
||||||
* @see Material
|
* @see Material
|
||||||
* @see ItemStack
|
* @see ItemStack
|
||||||
*/
|
*/
|
||||||
@@ -72,11 +89,11 @@ public enum XMaterial {
|
|||||||
ACACIA_PLANKS(4, "WOOD"),
|
ACACIA_PLANKS(4, "WOOD"),
|
||||||
ACACIA_PRESSURE_PLATE("WOOD_PLATE"),
|
ACACIA_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
ACACIA_SAPLING(4, "SAPLING"),
|
ACACIA_SAPLING(4, "SAPLING"),
|
||||||
ACACIA_SIGN("SIGN"),
|
ACACIA_SIGN("SIGN_POST", "SIGN"),
|
||||||
ACACIA_SLAB(4, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
ACACIA_SLAB(4, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
ACACIA_STAIRS,
|
ACACIA_STAIRS,
|
||||||
ACACIA_TRAPDOOR("TRAP_DOOR"),
|
ACACIA_TRAPDOOR("TRAP_DOOR"),
|
||||||
ACACIA_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
ACACIA_WALL_SIGN("WALL_SIGN"),
|
||||||
ACACIA_WOOD("LOG_2"),
|
ACACIA_WOOD("LOG_2"),
|
||||||
ACTIVATOR_RAIL,
|
ACTIVATOR_RAIL,
|
||||||
/**
|
/**
|
||||||
@@ -132,22 +149,22 @@ public enum XMaterial {
|
|||||||
BIRCH_PLANKS(2, "WOOD"),
|
BIRCH_PLANKS(2, "WOOD"),
|
||||||
BIRCH_PRESSURE_PLATE("WOOD_PLATE"),
|
BIRCH_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
BIRCH_SAPLING(2, "SAPLING"),
|
BIRCH_SAPLING(2, "SAPLING"),
|
||||||
BIRCH_SIGN("SIGN"),
|
BIRCH_SIGN("SIGN_POST", "SIGN"),
|
||||||
BIRCH_SLAB(2, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
BIRCH_SLAB(2, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
BIRCH_STAIRS("BIRCH_WOOD_STAIRS"),
|
BIRCH_STAIRS("BIRCH_WOOD_STAIRS"),
|
||||||
BIRCH_TRAPDOOR("TRAP_DOOR"),
|
BIRCH_TRAPDOOR("TRAP_DOOR"),
|
||||||
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
BIRCH_WALL_SIGN("WALL_SIGN"),
|
||||||
BIRCH_WOOD(2, "LOG"),
|
BIRCH_WOOD(2, "LOG"),
|
||||||
BLACKSTONE("1.16"),
|
BLACKSTONE("1.16"),
|
||||||
BLACKSTONE_SLAB("1.16"),
|
BLACKSTONE_SLAB("1.16"),
|
||||||
BLACKSTONE_STAIRS("1.16"),
|
BLACKSTONE_STAIRS("1.16"),
|
||||||
BLACKSTONE_WALL("1.16"),
|
BLACKSTONE_WALL("1.16"),
|
||||||
BLACK_BANNER("BANNER", "STANDING_BANNER"),
|
BLACK_BANNER("STANDING_BANNER", "BANNER"),
|
||||||
BLACK_BED(15, "BED_BLOCK", "BED"),
|
BLACK_BED(15, "BED_BLOCK", "BED"),
|
||||||
BLACK_CARPET(15, "CARPET"),
|
BLACK_CARPET(15, "CARPET"),
|
||||||
BLACK_CONCRETE(15, "CONCRETE"),
|
BLACK_CONCRETE(15, "CONCRETE"),
|
||||||
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
|
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
|
||||||
BLACK_DYE("1.14", "INK_SACK"),
|
BLACK_DYE("1.14", "INK_SACK", "INK_SAC"),
|
||||||
BLACK_GLAZED_TERRACOTTA(15, "1.12", "HARD_CLAY", "STAINED_CLAY", "BLACK_TERRACOTTA"),
|
BLACK_GLAZED_TERRACOTTA(15, "1.12", "HARD_CLAY", "STAINED_CLAY", "BLACK_TERRACOTTA"),
|
||||||
BLACK_SHULKER_BOX,
|
BLACK_SHULKER_BOX,
|
||||||
BLACK_STAINED_GLASS(15, "STAINED_GLASS"),
|
BLACK_STAINED_GLASS(15, "STAINED_GLASS"),
|
||||||
@@ -159,7 +176,7 @@ public enum XMaterial {
|
|||||||
BLAZE_POWDER,
|
BLAZE_POWDER,
|
||||||
BLAZE_ROD,
|
BLAZE_ROD,
|
||||||
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
|
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
|
||||||
BLUE_BANNER(4, "BANNER", "STANDING_BANNER"),
|
BLUE_BANNER(4, "STANDING_BANNER", "BANNER"),
|
||||||
BLUE_BED(11, "BED_BLOCK", "BED"),
|
BLUE_BED(11, "BED_BLOCK", "BED"),
|
||||||
BLUE_CARPET(11, "CARPET"),
|
BLUE_CARPET(11, "CARPET"),
|
||||||
BLUE_CONCRETE(11, "CONCRETE"),
|
BLUE_CONCRETE(11, "CONCRETE"),
|
||||||
@@ -192,7 +209,7 @@ public enum XMaterial {
|
|||||||
BRICK_SLAB(4, "STEP"),
|
BRICK_SLAB(4, "STEP"),
|
||||||
BRICK_STAIRS,
|
BRICK_STAIRS,
|
||||||
BRICK_WALL,
|
BRICK_WALL,
|
||||||
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
|
BROWN_BANNER(3, "STANDING_BANNER", "BANNER"),
|
||||||
BROWN_BED(12, "BED_BLOCK", "BED"),
|
BROWN_BED(12, "BED_BLOCK", "BED"),
|
||||||
BROWN_CARPET(12, "CARPET"),
|
BROWN_CARPET(12, "CARPET"),
|
||||||
BROWN_CONCRETE(12, "CONCRETE"),
|
BROWN_CONCRETE(12, "CONCRETE"),
|
||||||
@@ -309,19 +326,19 @@ public enum XMaterial {
|
|||||||
CRIMSON_PLANKS("1.16"),
|
CRIMSON_PLANKS("1.16"),
|
||||||
CRIMSON_PRESSURE_PLATE("1.16"),
|
CRIMSON_PRESSURE_PLATE("1.16"),
|
||||||
CRIMSON_ROOTS("1.16"),
|
CRIMSON_ROOTS("1.16"),
|
||||||
CRIMSON_SIGN("1.16"),
|
CRIMSON_SIGN("1.16", "SIGN_POST"),
|
||||||
CRIMSON_SLAB("1.16"),
|
CRIMSON_SLAB("1.16"),
|
||||||
CRIMSON_STAIRS("1.16"),
|
CRIMSON_STAIRS("1.16"),
|
||||||
CRIMSON_STEM("1.16"),
|
CRIMSON_STEM("1.16"),
|
||||||
CRIMSON_TRAPDOOR("1.16"),
|
CRIMSON_TRAPDOOR("1.16"),
|
||||||
CRIMSON_WALL_SIGN("1.16"),
|
CRIMSON_WALL_SIGN("1.16", "WALL_SIGN"),
|
||||||
CROSSBOW,
|
CROSSBOW,
|
||||||
CRYING_OBSIDIAN("1.16"),
|
CRYING_OBSIDIAN("1.16"),
|
||||||
CUT_RED_SANDSTONE("1.13"),
|
CUT_RED_SANDSTONE("1.13"),
|
||||||
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
|
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
|
||||||
CUT_SANDSTONE("1.13"),
|
CUT_SANDSTONE("1.13"),
|
||||||
CUT_SANDSTONE_SLAB("STEP"),
|
CUT_SANDSTONE_SLAB("STEP"),
|
||||||
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
|
CYAN_BANNER(6, "STANDING_BANNER", "BANNER"),
|
||||||
CYAN_BED(9, "BED_BLOCK", "BED"),
|
CYAN_BED(9, "BED_BLOCK", "BED"),
|
||||||
CYAN_CARPET(9, "CARPET"),
|
CYAN_CARPET(9, "CARPET"),
|
||||||
CYAN_CONCRETE(9, "CONCRETE"),
|
CYAN_CONCRETE(9, "CONCRETE"),
|
||||||
@@ -346,11 +363,11 @@ public enum XMaterial {
|
|||||||
DARK_OAK_PLANKS(5, "WOOD"),
|
DARK_OAK_PLANKS(5, "WOOD"),
|
||||||
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
DARK_OAK_SAPLING(5, "SAPLING"),
|
DARK_OAK_SAPLING(5, "SAPLING"),
|
||||||
DARK_OAK_SIGN("SIGN"),
|
DARK_OAK_SIGN("SIGN_POST", "SIGN"),
|
||||||
DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
DARK_OAK_STAIRS,
|
DARK_OAK_STAIRS,
|
||||||
DARK_OAK_TRAPDOOR("TRAP_DOOR"),
|
DARK_OAK_TRAPDOOR("TRAP_DOOR"),
|
||||||
DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
DARK_OAK_WALL_SIGN("WALL_SIGN"),
|
||||||
DARK_OAK_WOOD(1, "LOG", "LOG_2"),
|
DARK_OAK_WOOD(1, "LOG", "LOG_2"),
|
||||||
DARK_PRISMARINE(1, "PRISMARINE"),
|
DARK_PRISMARINE(1, "PRISMARINE"),
|
||||||
DARK_PRISMARINE_SLAB("1.13"),
|
DARK_PRISMARINE_SLAB("1.13"),
|
||||||
@@ -437,7 +454,7 @@ public enum XMaterial {
|
|||||||
FARMLAND("SOIL"),
|
FARMLAND("SOIL"),
|
||||||
FEATHER,
|
FEATHER,
|
||||||
FERMENTED_SPIDER_EYE,
|
FERMENTED_SPIDER_EYE,
|
||||||
FERN(1, "LONG_GRASS"),
|
FERN(2, "LONG_GRASS"),
|
||||||
/**
|
/**
|
||||||
* For some reasons filled map items are really special.
|
* For some reasons filled map items are really special.
|
||||||
* Their data value starts from 0 and every time a player
|
* Their data value starts from 0 and every time a player
|
||||||
@@ -467,6 +484,7 @@ public enum XMaterial {
|
|||||||
FURNACE_MINECART("POWERED_MINECART"),
|
FURNACE_MINECART("POWERED_MINECART"),
|
||||||
GHAST_SPAWN_EGG(56, "MONSTER_EGG"),
|
GHAST_SPAWN_EGG(56, "MONSTER_EGG"),
|
||||||
GHAST_TEAR,
|
GHAST_TEAR,
|
||||||
|
GILDED_BLACKSTONE("1.16"),
|
||||||
GLASS,
|
GLASS,
|
||||||
GLASS_BOTTLE,
|
GLASS_BOTTLE,
|
||||||
GLASS_PANE("THIN_GLASS"),
|
GLASS_PANE("THIN_GLASS"),
|
||||||
@@ -494,11 +512,11 @@ public enum XMaterial {
|
|||||||
GRANITE_SLAB,
|
GRANITE_SLAB,
|
||||||
GRANITE_STAIRS,
|
GRANITE_STAIRS,
|
||||||
GRANITE_WALL,
|
GRANITE_WALL,
|
||||||
GRASS,
|
GRASS(1, "LONG_GRASS"),
|
||||||
GRASS_BLOCK("GRASS"),
|
GRASS_BLOCK("GRASS"),
|
||||||
GRASS_PATH,
|
GRASS_PATH,
|
||||||
GRAVEL,
|
GRAVEL,
|
||||||
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
|
GRAY_BANNER(8, "STANDING_BANNER", "BANNER"),
|
||||||
GRAY_BED(7, "BED_BLOCK", "BED"),
|
GRAY_BED(7, "BED_BLOCK", "BED"),
|
||||||
GRAY_CARPET(7, "CARPET"),
|
GRAY_CARPET(7, "CARPET"),
|
||||||
GRAY_CONCRETE(7, "CONCRETE"),
|
GRAY_CONCRETE(7, "CONCRETE"),
|
||||||
@@ -511,7 +529,7 @@ public enum XMaterial {
|
|||||||
GRAY_TERRACOTTA(7, "HARD_CLAY", "STAINED_CLAY"),
|
GRAY_TERRACOTTA(7, "HARD_CLAY", "STAINED_CLAY"),
|
||||||
GRAY_WALL_BANNER(8, "WALL_BANNER"),
|
GRAY_WALL_BANNER(8, "WALL_BANNER"),
|
||||||
GRAY_WOOL(7, "WOOL"),
|
GRAY_WOOL(7, "WOOL"),
|
||||||
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
|
GREEN_BANNER(2, "STANDING_BANNER", "BANNER"),
|
||||||
GREEN_BED(13, "BED_BLOCK", "BED"),
|
GREEN_BED(13, "BED_BLOCK", "BED"),
|
||||||
GREEN_CARPET(13, "CARPET"),
|
GREEN_CARPET(13, "CARPET"),
|
||||||
GREEN_CONCRETE(13, "CONCRETE"),
|
GREEN_CONCRETE(13, "CONCRETE"),
|
||||||
@@ -550,6 +568,11 @@ public enum XMaterial {
|
|||||||
INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"),
|
INFESTED_MOSSY_STONE_BRICKS(3, "MONSTER_EGGS"),
|
||||||
INFESTED_STONE("MONSTER_EGGS"),
|
INFESTED_STONE("MONSTER_EGGS"),
|
||||||
INFESTED_STONE_BRICKS(2, "MONSTER_EGGS", "SMOOTH_BRICK"),
|
INFESTED_STONE_BRICKS(2, "MONSTER_EGGS", "SMOOTH_BRICK"),
|
||||||
|
/**
|
||||||
|
* We will only add "INK_SAC" for {@link #BLACK_DYE} since it's
|
||||||
|
* the only material (linked with this material) that is added
|
||||||
|
* after 1.13, which means it can use both INK_SACK and INK_SAC.
|
||||||
|
*/
|
||||||
INK_SAC("INK_SACK"),
|
INK_SAC("INK_SACK"),
|
||||||
IRON_AXE,
|
IRON_AXE,
|
||||||
IRON_BARS("IRON_FENCE"),
|
IRON_BARS("IRON_FENCE"),
|
||||||
@@ -582,11 +605,11 @@ public enum XMaterial {
|
|||||||
JUNGLE_PLANKS(3, "WOOD"),
|
JUNGLE_PLANKS(3, "WOOD"),
|
||||||
JUNGLE_PRESSURE_PLATE("WOOD_PLATE"),
|
JUNGLE_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
JUNGLE_SAPLING(3, "SAPLING"),
|
JUNGLE_SAPLING(3, "SAPLING"),
|
||||||
JUNGLE_SIGN("SIGN"),
|
JUNGLE_SIGN("SIGN_POST", "SIGN"),
|
||||||
JUNGLE_SLAB(3, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
JUNGLE_SLAB(3, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS"),
|
JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS"),
|
||||||
JUNGLE_TRAPDOOR("TRAP_DOOR"),
|
JUNGLE_TRAPDOOR("TRAP_DOOR"),
|
||||||
JUNGLE_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
JUNGLE_WALL_SIGN("WALL_SIGN"),
|
||||||
JUNGLE_WOOD(3, "LOG"),
|
JUNGLE_WOOD(3, "LOG"),
|
||||||
KELP("1.13"),
|
KELP("1.13"),
|
||||||
KELP_PLANT("1.13"),
|
KELP_PLANT("1.13"),
|
||||||
@@ -608,7 +631,7 @@ public enum XMaterial {
|
|||||||
LEATHER_LEGGINGS,
|
LEATHER_LEGGINGS,
|
||||||
LECTERN("1.14", "BOOKSHELF", ""),
|
LECTERN("1.14", "BOOKSHELF", ""),
|
||||||
LEVER,
|
LEVER,
|
||||||
LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"),
|
LIGHT_BLUE_BANNER(12, "STANDING_BANNER", "BANNER"),
|
||||||
LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
|
LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
|
||||||
LIGHT_BLUE_CARPET(3, "CARPET"),
|
LIGHT_BLUE_CARPET(3, "CARPET"),
|
||||||
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
||||||
@@ -619,9 +642,9 @@ public enum XMaterial {
|
|||||||
LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"),
|
LIGHT_BLUE_STAINED_GLASS(3, "STAINED_GLASS"),
|
||||||
LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
LIGHT_BLUE_STAINED_GLASS_PANE(3, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||||
LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"),
|
LIGHT_BLUE_TERRACOTTA(3, "STAINED_CLAY"),
|
||||||
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"),
|
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "STANDING_BANNER", "BANNER"),
|
||||||
LIGHT_BLUE_WOOL(3, "WOOL"),
|
LIGHT_BLUE_WOOL(3, "WOOL"),
|
||||||
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
|
LIGHT_GRAY_BANNER(7, "STANDING_BANNER", "BANNER"),
|
||||||
LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
|
LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
|
||||||
LIGHT_GRAY_CARPET(8, "CARPET"),
|
LIGHT_GRAY_CARPET(8, "CARPET"),
|
||||||
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
||||||
@@ -642,7 +665,7 @@ public enum XMaterial {
|
|||||||
LILAC(1, "DOUBLE_PLANT"),
|
LILAC(1, "DOUBLE_PLANT"),
|
||||||
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
|
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
|
||||||
LILY_PAD("WATER_LILY"),
|
LILY_PAD("WATER_LILY"),
|
||||||
LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
|
LIME_BANNER(10, "STANDING_BANNER", "BANNER"),
|
||||||
LIME_BED(5, "BED_BLOCK", "BED"),
|
LIME_BED(5, "BED_BLOCK", "BED"),
|
||||||
LIME_CARPET(5, "CARPET"),
|
LIME_CARPET(5, "CARPET"),
|
||||||
LIME_CONCRETE(5, "CONCRETE"),
|
LIME_CONCRETE(5, "CONCRETE"),
|
||||||
@@ -659,7 +682,7 @@ public enum XMaterial {
|
|||||||
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
|
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
|
||||||
LODESTONE("1.16"),
|
LODESTONE("1.16"),
|
||||||
LOOM("1.14"),
|
LOOM("1.14"),
|
||||||
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
|
MAGENTA_BANNER(13, "STANDING_BANNER", "BANNER"),
|
||||||
MAGENTA_BED(2, "BED_BLOCK", "BED"),
|
MAGENTA_BED(2, "BED_BLOCK", "BED"),
|
||||||
MAGENTA_CARPET(2, "CARPET"),
|
MAGENTA_CARPET(2, "CARPET"),
|
||||||
MAGENTA_CONCRETE(2, "CONCRETE"),
|
MAGENTA_CONCRETE(2, "CONCRETE"),
|
||||||
@@ -711,6 +734,7 @@ public enum XMaterial {
|
|||||||
MUSIC_DISC_FAR("RECORD_6"),
|
MUSIC_DISC_FAR("RECORD_6"),
|
||||||
MUSIC_DISC_MALL("RECORD_7"),
|
MUSIC_DISC_MALL("RECORD_7"),
|
||||||
MUSIC_DISC_MELLOHI("RECORD_8"),
|
MUSIC_DISC_MELLOHI("RECORD_8"),
|
||||||
|
MUSIC_DISC_PIGSTEP("1.16"),
|
||||||
MUSIC_DISC_STAL("RECORD_9"),
|
MUSIC_DISC_STAL("RECORD_9"),
|
||||||
MUSIC_DISC_STRAD("RECORD_10"),
|
MUSIC_DISC_STRAD("RECORD_10"),
|
||||||
MUSIC_DISC_WAIT("RECORD_11"),
|
MUSIC_DISC_WAIT("RECORD_11"),
|
||||||
@@ -761,16 +785,16 @@ public enum XMaterial {
|
|||||||
OAK_PLANKS("WOOD"),
|
OAK_PLANKS("WOOD"),
|
||||||
OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
OAK_SAPLING("SAPLING"),
|
OAK_SAPLING("SAPLING"),
|
||||||
OAK_SIGN("SIGN"),
|
OAK_SIGN("SIGN_POST", "SIGN"),
|
||||||
OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
OAK_STAIRS("WOOD_STAIRS"),
|
OAK_STAIRS("WOOD_STAIRS"),
|
||||||
OAK_TRAPDOOR("TRAP_DOOR"),
|
OAK_TRAPDOOR("TRAP_DOOR"),
|
||||||
OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
OAK_WALL_SIGN("WALL_SIGN"),
|
||||||
OAK_WOOD("LOG"),
|
OAK_WOOD("LOG"),
|
||||||
OBSERVER,
|
OBSERVER,
|
||||||
OBSIDIAN,
|
OBSIDIAN,
|
||||||
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
|
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
|
||||||
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"),
|
ORANGE_BANNER(14, "STANDING_BANNER", "BANNER"),
|
||||||
ORANGE_BED(1, "BED_BLOCK", "BED"),
|
ORANGE_BED(1, "BED_BLOCK", "BED"),
|
||||||
ORANGE_CARPET(1, "CARPET"),
|
ORANGE_CARPET(1, "CARPET"),
|
||||||
ORANGE_CONCRETE(1, "CONCRETE"),
|
ORANGE_CONCRETE(1, "CONCRETE"),
|
||||||
@@ -794,9 +818,11 @@ public enum XMaterial {
|
|||||||
PETRIFIED_OAK_SLAB("WOOD_STEP"),
|
PETRIFIED_OAK_SLAB("WOOD_STEP"),
|
||||||
PHANTOM_MEMBRANE("1.13"),
|
PHANTOM_MEMBRANE("1.13"),
|
||||||
PHANTOM_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
|
PHANTOM_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
|
||||||
|
PIGLIN_BANNER_PATTERN("1.16"),
|
||||||
|
PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"),
|
||||||
PIG_SPAWN_EGG(90, "MONSTER_EGG"),
|
PIG_SPAWN_EGG(90, "MONSTER_EGG"),
|
||||||
PILLAGER_SPAWN_EGG("1.14"),
|
PILLAGER_SPAWN_EGG("1.14"),
|
||||||
PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
|
PINK_BANNER(9, "STANDING_BANNER", "BANNER"),
|
||||||
PINK_BED(6, "BED_BLOCK", "BED"),
|
PINK_BED(6, "BED_BLOCK", "BED"),
|
||||||
PINK_CARPET(6, "CARPET"),
|
PINK_CARPET(6, "CARPET"),
|
||||||
PINK_CONCRETE(6, "CONCRETE"),
|
PINK_CONCRETE(6, "CONCRETE"),
|
||||||
@@ -852,6 +878,8 @@ public enum XMaterial {
|
|||||||
POTTED_BROWN_MUSHROOM("FLOWER_POT"),
|
POTTED_BROWN_MUSHROOM("FLOWER_POT"),
|
||||||
POTTED_CACTUS("FLOWER_POT"),
|
POTTED_CACTUS("FLOWER_POT"),
|
||||||
POTTED_CORNFLOWER,
|
POTTED_CORNFLOWER,
|
||||||
|
POTTED_CRIMSON_FUNGUS("1.16"),
|
||||||
|
POTTED_CRIMSON_ROOTS("1.16"),
|
||||||
POTTED_DANDELION("YELLOW_FLOWER", "FLOWER_POT"),
|
POTTED_DANDELION("YELLOW_FLOWER", "FLOWER_POT"),
|
||||||
POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"),
|
POTTED_DARK_OAK_SAPLING(5, "SAPLING", "FLOWER_POT"),
|
||||||
POTTED_DEAD_BUSH("FLOWER_POT"),
|
POTTED_DEAD_BUSH("FLOWER_POT"),
|
||||||
@@ -866,6 +894,8 @@ public enum XMaterial {
|
|||||||
POTTED_RED_MUSHROOM("FLOWER_POT"),
|
POTTED_RED_MUSHROOM("FLOWER_POT"),
|
||||||
POTTED_RED_TULIP(4, "RED_ROSE", "FLOWER_POT"),
|
POTTED_RED_TULIP(4, "RED_ROSE", "FLOWER_POT"),
|
||||||
POTTED_SPRUCE_SAPLING(1, "SAPLING", "FLOWER_POT"),
|
POTTED_SPRUCE_SAPLING(1, "SAPLING", "FLOWER_POT"),
|
||||||
|
POTTED_WARPED_FUNGUS("1.16"),
|
||||||
|
POTTED_WARPED_ROOTS("1.16"),
|
||||||
POTTED_WHITE_TULIP(6, "RED_ROSE", "FLOWER_POT"),
|
POTTED_WHITE_TULIP(6, "RED_ROSE", "FLOWER_POT"),
|
||||||
POTTED_WITHER_ROSE,
|
POTTED_WITHER_ROSE,
|
||||||
POWERED_RAIL,
|
POWERED_RAIL,
|
||||||
@@ -885,7 +915,7 @@ public enum XMaterial {
|
|||||||
PUMPKIN_PIE,
|
PUMPKIN_PIE,
|
||||||
PUMPKIN_SEEDS,
|
PUMPKIN_SEEDS,
|
||||||
PUMPKIN_STEM,
|
PUMPKIN_STEM,
|
||||||
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
|
PURPLE_BANNER(5, "STANDING_BANNER", "BANNER"),
|
||||||
PURPLE_BED(10, "BED_BLOCK", "BED"),
|
PURPLE_BED(10, "BED_BLOCK", "BED"),
|
||||||
PURPLE_CARPET(10, "CARPET"),
|
PURPLE_CARPET(10, "CARPET"),
|
||||||
PURPLE_CONCRETE(10, "CONCRETE"),
|
PURPLE_CONCRETE(10, "CONCRETE"),
|
||||||
@@ -904,6 +934,7 @@ public enum XMaterial {
|
|||||||
PURPUR_STAIRS,
|
PURPUR_STAIRS,
|
||||||
QUARTZ,
|
QUARTZ,
|
||||||
QUARTZ_BLOCK,
|
QUARTZ_BLOCK,
|
||||||
|
QUARTZ_BRICKS("1.16"),
|
||||||
QUARTZ_PILLAR(2, "QUARTZ_BLOCK"),
|
QUARTZ_PILLAR(2, "QUARTZ_BLOCK"),
|
||||||
QUARTZ_SLAB(7, "STEP"),
|
QUARTZ_SLAB(7, "STEP"),
|
||||||
QUARTZ_STAIRS,
|
QUARTZ_STAIRS,
|
||||||
@@ -932,7 +963,7 @@ public enum XMaterial {
|
|||||||
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
|
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
|
||||||
REDSTONE_WALL_TORCH,
|
REDSTONE_WALL_TORCH,
|
||||||
REDSTONE_WIRE,
|
REDSTONE_WIRE,
|
||||||
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
|
RED_BANNER(1, "STANDING_BANNER", "BANNER"),
|
||||||
/**
|
/**
|
||||||
* Data value 14 or 0
|
* Data value 14 or 0
|
||||||
*/
|
*/
|
||||||
@@ -940,10 +971,7 @@ public enum XMaterial {
|
|||||||
RED_CARPET(14, "CARPET"),
|
RED_CARPET(14, "CARPET"),
|
||||||
RED_CONCRETE(14, "CONCRETE"),
|
RED_CONCRETE(14, "CONCRETE"),
|
||||||
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
||||||
/**
|
RED_DYE(1, "INK_SACK", "ROSE_RED"),
|
||||||
* Data value 0 or 1?
|
|
||||||
*/
|
|
||||||
RED_DYE(0, "INK_SACK", "ROSE_RED"),
|
|
||||||
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
|
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
|
||||||
RED_MUSHROOM,
|
RED_MUSHROOM,
|
||||||
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
||||||
@@ -963,7 +991,7 @@ public enum XMaterial {
|
|||||||
RED_TULIP(4, "RED_ROSE"),
|
RED_TULIP(4, "RED_ROSE"),
|
||||||
RED_WALL_BANNER(1, "WALL_BANNER"),
|
RED_WALL_BANNER(1, "WALL_BANNER"),
|
||||||
RED_WOOL(14, "WOOL"),
|
RED_WOOL(14, "WOOL"),
|
||||||
REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"),
|
REPEATER("DIODE_BLOCK_ON", "DIODE_BLOCK_OFF", "DIODE"),
|
||||||
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
|
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
|
||||||
RESPAWN_ANCHOR("1.16"),
|
RESPAWN_ANCHOR("1.16"),
|
||||||
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
||||||
@@ -1032,16 +1060,16 @@ public enum XMaterial {
|
|||||||
SPRUCE_DOOR("SPRUCE_DOOR_ITEM", "SPRUCE_DOOR"),
|
SPRUCE_DOOR("SPRUCE_DOOR_ITEM", "SPRUCE_DOOR"),
|
||||||
SPRUCE_FENCE,
|
SPRUCE_FENCE,
|
||||||
SPRUCE_FENCE_GATE,
|
SPRUCE_FENCE_GATE,
|
||||||
SPRUCE_LEAVES(1, "LEAVES"),
|
SPRUCE_LEAVES(1, "LEAVES", "LEAVES_2"),
|
||||||
SPRUCE_LOG(1, "LOG"),
|
SPRUCE_LOG(1, "LOG"),
|
||||||
SPRUCE_PLANKS(1, "WOOD"),
|
SPRUCE_PLANKS(1, "WOOD"),
|
||||||
SPRUCE_PRESSURE_PLATE("WOOD_PLATE"),
|
SPRUCE_PRESSURE_PLATE("WOOD_PLATE"),
|
||||||
SPRUCE_SAPLING(1, "SAPLING"),
|
SPRUCE_SAPLING(1, "SAPLING"),
|
||||||
SPRUCE_SIGN("SIGN"),
|
SPRUCE_SIGN("SIGN_POST", "SIGN"),
|
||||||
SPRUCE_SLAB(1, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
SPRUCE_SLAB(1, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||||
SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS"),
|
SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS"),
|
||||||
SPRUCE_TRAPDOOR("TRAP_DOOR"),
|
SPRUCE_TRAPDOOR("TRAP_DOOR"),
|
||||||
SPRUCE_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
SPRUCE_WALL_SIGN("WALL_SIGN"),
|
||||||
SPRUCE_WOOD(1, "LOG"),
|
SPRUCE_WOOD(1, "LOG"),
|
||||||
SQUID_SPAWN_EGG(94, "MONSTER_EGG"),
|
SQUID_SPAWN_EGG(94, "MONSTER_EGG"),
|
||||||
STICK,
|
STICK,
|
||||||
@@ -1062,6 +1090,7 @@ public enum XMaterial {
|
|||||||
STONE_STAIRS,
|
STONE_STAIRS,
|
||||||
STONE_SWORD,
|
STONE_SWORD,
|
||||||
STRAY_SPAWN_EGG(6, "MONSTER_EGG"),
|
STRAY_SPAWN_EGG(6, "MONSTER_EGG"),
|
||||||
|
STRIDER_SPAWN_EGG("1.16"),
|
||||||
STRING,
|
STRING,
|
||||||
STRIPPED_ACACIA_LOG("LOG_2"),
|
STRIPPED_ACACIA_LOG("LOG_2"),
|
||||||
STRIPPED_ACACIA_WOOD("LOG_2"),
|
STRIPPED_ACACIA_WOOD("LOG_2"),
|
||||||
@@ -1144,12 +1173,12 @@ public enum XMaterial {
|
|||||||
WARPED_PLANKS("1.16"),
|
WARPED_PLANKS("1.16"),
|
||||||
WARPED_PRESSURE_PLATE("1.16"),
|
WARPED_PRESSURE_PLATE("1.16"),
|
||||||
WARPED_ROOTS("1.16"),
|
WARPED_ROOTS("1.16"),
|
||||||
WARPED_SIGN("1.16"),
|
WARPED_SIGN("1.16", "SIGN_POST"),
|
||||||
WARPED_SLAB("1.16"),
|
WARPED_SLAB("1.16"),
|
||||||
WARPED_STAIRS("1.16"),
|
WARPED_STAIRS("1.16"),
|
||||||
WARPED_STEM("1.16"),
|
WARPED_STEM("1.16"),
|
||||||
WARPED_TRAPDOOR("1.16"),
|
WARPED_TRAPDOOR("1.16"),
|
||||||
WARPED_WALL_SIGN("1.16"),
|
WARPED_WALL_SIGN("1.16", "WALL_SIGN"),
|
||||||
WARPED_WART_BLOCK("1.16"),
|
WARPED_WART_BLOCK("1.16"),
|
||||||
/**
|
/**
|
||||||
* This is used for blocks only.
|
* This is used for blocks only.
|
||||||
@@ -1169,7 +1198,7 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
WHEAT("CROPS"),
|
WHEAT("CROPS"),
|
||||||
WHEAT_SEEDS("SEEDS"),
|
WHEAT_SEEDS("SEEDS"),
|
||||||
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
|
WHITE_BANNER(15, "STANDING_BANNER", "BANNER"),
|
||||||
WHITE_BED("BED_BLOCK", "BED"),
|
WHITE_BED("BED_BLOCK", "BED"),
|
||||||
WHITE_CARPET("CARPET"),
|
WHITE_CARPET("CARPET"),
|
||||||
WHITE_CONCRETE("CONCRETE"),
|
WHITE_CONCRETE("CONCRETE"),
|
||||||
@@ -1196,7 +1225,7 @@ public enum XMaterial {
|
|||||||
WOODEN_SWORD("WOOD_SWORD"),
|
WOODEN_SWORD("WOOD_SWORD"),
|
||||||
WRITABLE_BOOK("BOOK_AND_QUILL"),
|
WRITABLE_BOOK("BOOK_AND_QUILL"),
|
||||||
WRITTEN_BOOK,
|
WRITTEN_BOOK,
|
||||||
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
|
YELLOW_BANNER(11, "STANDING_BANNER", "BANNER"),
|
||||||
YELLOW_BED(4, "BED_BLOCK", "BED"),
|
YELLOW_BED(4, "BED_BLOCK", "BED"),
|
||||||
YELLOW_CARPET(4, "CARPET"),
|
YELLOW_CARPET(4, "CARPET"),
|
||||||
YELLOW_CONCRETE(4, "CONCRETE"),
|
YELLOW_CONCRETE(4, "CONCRETE"),
|
||||||
@@ -1209,22 +1238,31 @@ public enum XMaterial {
|
|||||||
YELLOW_TERRACOTTA(4, "HARD_CLAY", "STAINED_CLAY"),
|
YELLOW_TERRACOTTA(4, "HARD_CLAY", "STAINED_CLAY"),
|
||||||
YELLOW_WALL_BANNER(11, "WALL_BANNER"),
|
YELLOW_WALL_BANNER(11, "WALL_BANNER"),
|
||||||
YELLOW_WOOL(4, "WOOL"),
|
YELLOW_WOOL(4, "WOOL"),
|
||||||
|
ZOGLIN_SPAWN_EGG("1.16"),
|
||||||
ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"),
|
ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||||
ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"),
|
ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"),
|
||||||
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
|
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
|
||||||
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
|
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
|
||||||
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
|
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||||
PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"),
|
|
||||||
ZOMBIFIED_PIGLIN_SPAWN_EGG(57, "MONSTER_EGG", "ZOMBIE_PIGMAN_SPAWN_EGG");
|
ZOMBIFIED_PIGLIN_SPAWN_EGG(57, "MONSTER_EGG", "ZOMBIE_PIGMAN_SPAWN_EGG");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An immutable cached set of {@link XMaterial#values()} to avoid allocating memory for
|
* Cached set of {@link XMaterial#values()} to avoid allocating memory for
|
||||||
* calling the method every time.
|
* calling the method every time.
|
||||||
|
* This list is unmodifiable.
|
||||||
*
|
*
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public static final EnumSet<XMaterial> VALUES = EnumSet.allOf(XMaterial.class);
|
public static final List<XMaterial> VALUES = Collections.unmodifiableList(Arrays.asList(values()));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We don't want to use {@link Enums#getIfPresent(Class, String)} to avoid a few checks.
|
||||||
|
*
|
||||||
|
* @since 5.1.0
|
||||||
|
*/
|
||||||
|
private static final Map<String, XMaterial> NAMES = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of material names that can be damaged.
|
* A set of material names that can be damaged.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1233,13 +1271,13 @@ public enum XMaterial {
|
|||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private static final ImmutableSet<String> DAMAGEABLE = ImmutableSet.of(
|
private static final Set<String> DAMAGEABLE = new HashSet<>(Arrays.asList(
|
||||||
"HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS",
|
"HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS",
|
||||||
"SWORD", "AXE", "PICKAXE", "SHOVEL", "HOE",
|
"SWORD", "AXE", "PICKAXE", "SHOVEL", "HOE",
|
||||||
"ELYTRA", "TRIDENT", "HORSE_ARMOR", "BARDING",
|
"ELYTRA", "TRIDENT", "HORSE_ARMOR", "BARDING",
|
||||||
"SHEARS", "FLINT_AND_STEEL", "BOW", "FISHING_ROD",
|
"SHEARS", "FLINT_AND_STEEL", "BOW", "FISHING_ROD",
|
||||||
"CARROT_ON_A_STICK", "CARROT_STICK", "SPADE", "SHIELD"
|
"CARROT_ON_A_STICK", "CARROT_STICK", "SPADE", "SHIELD"
|
||||||
);
|
));
|
||||||
/**
|
/**
|
||||||
* <b>XMaterial Paradox (Duplication Check)</b>
|
* <b>XMaterial Paradox (Duplication Check)</b>
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1250,29 +1288,25 @@ public enum XMaterial {
|
|||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
private static final ImmutableMap<XMaterial, XMaterial> duplicated = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
private static final EnumMap<XMaterial, XMaterial> DUPLICATED = new EnumMap<XMaterial, XMaterial>(XMaterial.class);
|
||||||
.put(MELON, MELON_SLICE)
|
/**
|
||||||
.put(CARROT, CARROTS)
|
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||||
.put(POTATO, POTATOES)
|
* For strings that match a certain XMaterial. Mostly cached for configs.
|
||||||
.put(BEETROOT, BEETROOTS)
|
*
|
||||||
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK)
|
* @since 1.0.0
|
||||||
.put(BRICK, BRICKS)
|
*/
|
||||||
.put(NETHER_BRICK, NETHER_BRICKS)
|
private static final Cache<String, XMaterial> NAME_CACHE = CacheBuilder.newBuilder()
|
||||||
|
.expireAfterAccess(15, TimeUnit.MINUTES)
|
||||||
// Illegal Elements
|
.build();
|
||||||
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it
|
/**
|
||||||
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM.
|
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||||
// We'll trick XMaterial into thinking this needs to be parsed
|
* For XMaterials that are already parsed once.
|
||||||
// using the old methods.
|
*
|
||||||
// These materials have their enum name added to the legacy list as well.
|
* @since 3.0.0
|
||||||
.put(DARK_OAK_DOOR, DARK_OAK_DOOR)
|
*/
|
||||||
.put(ACACIA_DOOR, ACACIA_DOOR)
|
private static final Cache<XMaterial, Optional<Material>> PARSED_CACHE = CacheBuilder.newBuilder()
|
||||||
.put(BIRCH_DOOR, BIRCH_DOOR)
|
.expireAfterAccess(10, TimeUnit.MINUTES)
|
||||||
.put(JUNGLE_DOOR, JUNGLE_DOOR)
|
.build();
|
||||||
.put(SPRUCE_DOOR, SPRUCE_DOOR)
|
|
||||||
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
/*
|
/*
|
||||||
* A set of all the legacy names without duplicates.
|
* A set of all the legacy names without duplicates.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1287,36 +1321,24 @@ public enum XMaterial {
|
|||||||
.filter(m -> m.charAt(1) == '.')
|
.filter(m -> m.charAt(1) == '.')
|
||||||
.collect(Collectors.collectingAndThen(Collectors.toSet(), ImmutableSet::copyOf));
|
.collect(Collectors.collectingAndThen(Collectors.toSet(), ImmutableSet::copyOf));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
* This is used for {@link #isOneOf(Collection)}
|
||||||
* For strings that match a certain XMaterial. Mostly cached for configs.
|
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 3.4.0
|
||||||
*/
|
*/
|
||||||
private static final Cache<String, XMaterial> NAME_CACHE = CacheBuilder.newBuilder()
|
private static final LoadingCache<String, Pattern> CACHED_REGEX = CacheBuilder.newBuilder()
|
||||||
.softValues()
|
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||||
.expireAfterAccess(15, TimeUnit.MINUTES)
|
.build(new CacheLoader<String, Pattern>() {
|
||||||
.build();
|
@Override
|
||||||
/**
|
public Pattern load(@Nonnull String str) {
|
||||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
try {
|
||||||
* For XMaterials that are already parsed once.
|
return Pattern.compile(str);
|
||||||
*
|
} catch (PatternSyntaxException ex) {
|
||||||
* @since 3.0.0
|
ex.printStackTrace();
|
||||||
*/
|
return null;
|
||||||
private static final Cache<XMaterial, Optional<Material>> PARSED_CACHE = CacheBuilder.newBuilder()
|
}
|
||||||
.softValues()
|
}
|
||||||
.expireAfterAccess(10, TimeUnit.MINUTES)
|
});
|
||||||
.concurrencyLevel(Runtime.getRuntime().availableProcessors())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pre-compiled RegEx pattern.
|
|
||||||
* Include both replacements to avoid recreating string multiple times with multiple RegEx checks.
|
|
||||||
*
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
private static final Pattern FORMAT_PATTERN = Pattern.compile("\\W+");
|
|
||||||
/**
|
/**
|
||||||
* The current version of the server in the a form of a major version.
|
* The current version of the server in the a form of a major version.
|
||||||
*
|
*
|
||||||
@@ -1330,6 +1352,35 @@ public enum XMaterial {
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
private static final boolean ISFLAT = supports(13);
|
private static final boolean ISFLAT = supports(13);
|
||||||
|
|
||||||
|
static {
|
||||||
|
DUPLICATED.put(MELON, MELON_SLICE);
|
||||||
|
DUPLICATED.put(CARROT, CARROTS);
|
||||||
|
DUPLICATED.put(POTATO, POTATOES);
|
||||||
|
DUPLICATED.put(BEETROOT, BEETROOTS);
|
||||||
|
DUPLICATED.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK);
|
||||||
|
DUPLICATED.put(BRICK, BRICKS);
|
||||||
|
DUPLICATED.put(NETHER_BRICK, NETHER_BRICKS);
|
||||||
|
|
||||||
|
// Illegal Elements
|
||||||
|
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it
|
||||||
|
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM.
|
||||||
|
// We'll trick XMaterial into thinking this needs to be parsed
|
||||||
|
// using the old methods.
|
||||||
|
// Some of these materials have their enum name added to the legacy list as well.
|
||||||
|
DUPLICATED.put(DARK_OAK_DOOR, DARK_OAK_DOOR);
|
||||||
|
DUPLICATED.put(ACACIA_DOOR, ACACIA_DOOR);
|
||||||
|
DUPLICATED.put(BIRCH_DOOR, BIRCH_DOOR);
|
||||||
|
DUPLICATED.put(JUNGLE_DOOR, JUNGLE_DOOR);
|
||||||
|
DUPLICATED.put(SPRUCE_DOOR, SPRUCE_DOOR);
|
||||||
|
DUPLICATED.put(CAULDRON, CAULDRON);
|
||||||
|
DUPLICATED.put(BREWING_STAND, BREWING_STAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (XMaterial material : VALUES) NAMES.put(material.name(), material);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data value of this material https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
* The data value of this material https://minecraft.gamepedia.com/Java_Edition_data_values/Pre-flattening
|
||||||
*
|
*
|
||||||
@@ -1382,7 +1433,7 @@ public enum XMaterial {
|
|||||||
* An invocation of this method yields exactly the same result as the expression:
|
* An invocation of this method yields exactly the same result as the expression:
|
||||||
* <p>
|
* <p>
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
* {@link #getVersion()} == 1.8
|
* !{@link #supports(int)} 9
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
*
|
*
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
@@ -1391,6 +1442,18 @@ public enum XMaterial {
|
|||||||
return !supports(9);
|
return !supports(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link XMaterial} with this name without throwing an exception.
|
||||||
|
*
|
||||||
|
* @param name the name of the material.
|
||||||
|
* @return an optional that can be empty.
|
||||||
|
* @since 5.1.0
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
private static Optional<XMaterial> getIfPresent(@Nonnull String name) {
|
||||||
|
return Optional.ofNullable(NAMES.get(name));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current version of the server.
|
* The current version of the server.
|
||||||
*
|
*
|
||||||
@@ -1442,8 +1505,9 @@ public enum XMaterial {
|
|||||||
Validate.notEmpty(name, "Cannot check for null or empty material name");
|
Validate.notEmpty(name, "Cannot check for null or empty material name");
|
||||||
name = format(name);
|
name = format(name);
|
||||||
|
|
||||||
for (XMaterial materials : VALUES)
|
for (XMaterial materials : VALUES) {
|
||||||
if (materials.name().equals(name)) return true;
|
if (materials.name().equals(name)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1463,13 +1527,13 @@ public enum XMaterial {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses material name and data value from the specified string.
|
* Parses material name and data value from the specified string.
|
||||||
* The seperators are: <b>, or :</b>
|
* The separator for the material name and its data value is {@code :}
|
||||||
* Spaces are allowed. Mostly used when getting materials from config for old school minecrafters.
|
* Spaces are allowed. Mostly used when getting materials from config for old school minecrafters.
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Examples</b>
|
* <b>Examples</b>
|
||||||
* <p><pre>
|
* <p><pre>
|
||||||
* {@code INK_SACK:1 -> RED_DYE}
|
* {@code INK_SACK:1 -> RED_DYE}
|
||||||
* {@code WOOL, 14 -> RED_WOOL}
|
* {@code WOOL: 14 -> RED_WOOL}
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param name the material string that consists of the material name, data and separator character.
|
* @param name the material string that consists of the material name, data and separator character.
|
||||||
@@ -1477,14 +1541,17 @@ public enum XMaterial {
|
|||||||
* @see #matchXMaterial(String)
|
* @see #matchXMaterial(String)
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
private static Optional<XMaterial> matchXMaterialWithData(String name) {
|
private static Optional<XMaterial> matchXMaterialWithData(String name) {
|
||||||
for (char separator : new char[]{',', ':'}) {
|
int index = name.indexOf(':');
|
||||||
int index = name.indexOf(separator);
|
if (index != -1) {
|
||||||
if (index == -1) continue;
|
|
||||||
|
|
||||||
String mat = format(name.substring(0, index));
|
String mat = format(name.substring(0, index));
|
||||||
byte data = Byte.parseByte(StringUtils.deleteWhitespace(name.substring(index + 1)));
|
|
||||||
return matchDefinedXMaterial(mat, data);
|
try {
|
||||||
|
byte data = (byte) Integer.parseInt(StringUtils.deleteWhitespace(name.substring(index + 1)));
|
||||||
|
return matchDefinedXMaterial(mat, data);
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@@ -1502,7 +1569,7 @@ public enum XMaterial {
|
|||||||
public static XMaterial matchXMaterial(@Nonnull Material material) {
|
public static XMaterial matchXMaterial(@Nonnull Material material) {
|
||||||
Objects.requireNonNull(material, "Cannot match null material");
|
Objects.requireNonNull(material, "Cannot match null material");
|
||||||
return matchDefinedXMaterial(material.name(), (byte) -1)
|
return matchDefinedXMaterial(material.name(), (byte) -1)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material With No Bytes: " + material.name()));
|
.orElseThrow(() -> new IllegalArgumentException("Unsupported material with no data value: " + material.name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1522,7 +1589,7 @@ public enum XMaterial {
|
|||||||
byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability());
|
byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability());
|
||||||
|
|
||||||
return matchDefinedXMaterial(material, data)
|
return matchDefinedXMaterial(material, data)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material + " (" + data + ')'));
|
.orElseThrow(() -> new IllegalArgumentException("Unsupported material: " + material + " (" + data + ')'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1544,11 +1611,12 @@ public enum XMaterial {
|
|||||||
// Do basic number and boolean checks before accessing more complex enum stuff.
|
// Do basic number and boolean checks before accessing more complex enum stuff.
|
||||||
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
|
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
|
||||||
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
|
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
|
||||||
if (data <= 0 && !duplicated) {
|
Optional<XMaterial> xMaterial = null;
|
||||||
|
if (data <= 0 && (ISFLAT || !duplicated)) {
|
||||||
// Apparently the transform method is more efficient than toJavaUtil()
|
// Apparently the transform method is more efficient than toJavaUtil()
|
||||||
// toJavaUtil isn't even supported in older versions.
|
// toJavaUtil isn't even supported in older versions.
|
||||||
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
xMaterial = getIfPresent(name);
|
||||||
if (xMat.isPresent()) return xMat;
|
if (xMaterial.isPresent()) return xMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XMaterial Paradox (Duplication Check)
|
// XMaterial Paradox (Duplication Check)
|
||||||
@@ -1566,7 +1634,7 @@ public enum XMaterial {
|
|||||||
// A solution for XMaterial Paradox.
|
// A solution for XMaterial Paradox.
|
||||||
// Manually parses the duplicated materials to find the exact material based on the server version.
|
// Manually parses the duplicated materials to find the exact material based on the server version.
|
||||||
// If ends with "S" -> Plural Form Material
|
// If ends with "S" -> Plural Form Material
|
||||||
return Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
return xMaterial == null ? getIfPresent(name) : xMaterial;
|
||||||
}
|
}
|
||||||
return Optional.ofNullable(xMat);
|
return Optional.ofNullable(xMat);
|
||||||
}
|
}
|
||||||
@@ -1585,7 +1653,7 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
private static boolean isDuplicated(@Nonnull String name) {
|
private static boolean isDuplicated(@Nonnull String name) {
|
||||||
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
|
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
|
||||||
for (Map.Entry<XMaterial, XMaterial> duplicated : duplicated.entrySet()) {
|
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet()) {
|
||||||
XMaterial material = duplicated.getKey();
|
XMaterial material = duplicated.getKey();
|
||||||
if (material.name().equals(name) || material.anyMatchLegacy(name)) return true;
|
if (material.name().equals(name) || material.anyMatchLegacy(name)) return true;
|
||||||
}
|
}
|
||||||
@@ -1614,16 +1682,41 @@ public enum XMaterial {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to build the string like an enum name.
|
* Attempts to build the string like an enum name.
|
||||||
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings.
|
* Removes all the spaces, and extra non-English characters. Also removes some config/in-game based strings.
|
||||||
|
* While this method is hard to maintain, it's extremely efficient. It's approximately more than x5 times faster than
|
||||||
|
* the normal RegEx + String Methods approach for both formatted and unformatted material names.
|
||||||
*
|
*
|
||||||
* @param name the material name to modify.
|
* @param name the material name to modify.
|
||||||
* @return a Material enum name.
|
* @return a Material enum name.
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static String format(@Nonnull String name) {
|
protected static String format(@Nonnull String name) {
|
||||||
return FORMAT_PATTERN.matcher(
|
int len = name.length();
|
||||||
name.trim().replace('-', '_').replace(' ', '_')).replaceAll("").toUpperCase(Locale.ENGLISH);
|
char[] chs = new char[len];
|
||||||
|
int count = 0;
|
||||||
|
boolean appendUnderline = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
char ch = name.charAt(i);
|
||||||
|
|
||||||
|
if (!appendUnderline && count != 0 && (ch == '-' || ch == ' ' || ch == '_') && chs[count] != '_') appendUnderline = true;
|
||||||
|
else {
|
||||||
|
boolean number = false;
|
||||||
|
// Old materials have numbers in them.
|
||||||
|
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (number = (ch >= '0' && ch <= '9'))) {
|
||||||
|
if (appendUnderline) {
|
||||||
|
chs[count++] = '_';
|
||||||
|
appendUnderline = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number) chs[count++] = ch;
|
||||||
|
else chs[count++] = (char) (ch & 0x5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(chs, 0, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1709,8 +1802,9 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
public static boolean isDamageable(@Nonnull String name) {
|
public static boolean isDamageable(@Nonnull String name) {
|
||||||
Objects.requireNonNull(name, "Material name cannot be null");
|
Objects.requireNonNull(name, "Material name cannot be null");
|
||||||
for (String damageable : DAMAGEABLE)
|
for (String damageable : DAMAGEABLE) {
|
||||||
if (name.contains(damageable)) return true;
|
if (name.contains(damageable)) return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1750,32 +1844,31 @@ public enum XMaterial {
|
|||||||
* <p>
|
* <p>
|
||||||
* Want to learn RegEx? You can mess around in <a href="https://regexr.com/">RegExr</a> website.
|
* Want to learn RegEx? You can mess around in <a href="https://regexr.com/">RegExr</a> website.
|
||||||
*
|
*
|
||||||
* @param material the base material to match other materials with.
|
|
||||||
* @param materials the material names to check base material on.
|
* @param materials the material names to check base material on.
|
||||||
* @return true if one of the given material names is similar to the base material.
|
* @return true if one of the given material names is similar to the base material.
|
||||||
* @since 3.1.1
|
* @since 3.1.1
|
||||||
*/
|
*/
|
||||||
public static boolean isOneOf(@Nonnull Material material, @Nullable List<String> materials) {
|
public boolean isOneOf(@Nullable Collection<String> materials) {
|
||||||
if (materials == null || materials.isEmpty()) return false;
|
if (materials == null || materials.isEmpty()) return false;
|
||||||
Objects.requireNonNull(material, "Cannot match materials with a null material");
|
String name = this.name();
|
||||||
String name = material.name();
|
|
||||||
|
|
||||||
for (String comp : materials) {
|
for (String comp : materials) {
|
||||||
comp = comp.toUpperCase();
|
String checker = comp.toUpperCase(Locale.ENGLISH);
|
||||||
if (comp.startsWith("CONTAINS:")) {
|
if (checker.startsWith("CONTAINS:")) {
|
||||||
comp = format(comp.substring(9));
|
comp = format(checker.substring(9));
|
||||||
if (name.contains(comp)) return true;
|
if (name.contains(comp)) return true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (comp.startsWith("REGEX:")) {
|
if (checker.startsWith("REGEX:")) {
|
||||||
comp = comp.substring(6);
|
comp = comp.substring(6);
|
||||||
if (name.matches(comp)) return true;
|
Pattern pattern = CACHED_REGEX.getUnchecked(comp);
|
||||||
|
if (pattern != null && pattern.matcher(name).matches()) return true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Direct Object Equals
|
// Direct Object Equals
|
||||||
Optional<XMaterial> mat = matchXMaterial(comp);
|
Optional<XMaterial> xMat = matchXMaterial(comp);
|
||||||
if (mat.isPresent() && mat.get().parseMaterial() == material) return true;
|
if (xMat.isPresent() && xMat.get() == this) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1809,27 +1902,14 @@ public enum XMaterial {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ItemStack setType(@Nonnull ItemStack item) {
|
public ItemStack setType(@Nonnull ItemStack item) {
|
||||||
Objects.requireNonNull(item, "Cannot set material for null ItemStack");
|
Objects.requireNonNull(item, "Cannot set material for null ItemStack");
|
||||||
|
Material material = this.parseMaterial();
|
||||||
|
Objects.requireNonNull(material, "Unsupported material: " + this.name());
|
||||||
|
|
||||||
item.setType(this.parseMaterial());
|
item.setType(material);
|
||||||
if (!ISFLAT && !this.isDamageable()) item.setDurability(this.data);
|
if (!ISFLAT && !this.isDamageable()) item.setDurability(this.data);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the list of given material names matches the given base material.
|
|
||||||
* Mostly used for configs.
|
|
||||||
*
|
|
||||||
* @param materials the material names to check base material on.
|
|
||||||
* @return true if one of the given material names is similar to the base material.
|
|
||||||
* @see #isOneOf(Material, List)
|
|
||||||
* @since 3.0.0
|
|
||||||
*/
|
|
||||||
public boolean isOneOf(@Nullable List<String> materials) {
|
|
||||||
Material material = this.parseMaterial();
|
|
||||||
if (material == null) return false;
|
|
||||||
return isOneOf(material, materials);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given string matches any of this material's legacy material names.
|
* Checks if the given string matches any of this material's legacy material names.
|
||||||
* All the values passed to this method will not be null or empty and are formatted correctly.
|
* All the values passed to this method will not be null or empty and are formatted correctly.
|
||||||
@@ -1868,7 +1948,7 @@ public enum XMaterial {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public int getId() {
|
public int getId() {
|
||||||
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1;
|
if (this.data != 0 || (this.legacy.length != 0 && this.legacy[0].charAt(1) == '.' && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1;
|
||||||
Material material = this.parseMaterial();
|
Material material = this.parseMaterial();
|
||||||
return material == null ? -1 : material.getId();
|
return material == null ? -1 : material.getId();
|
||||||
}
|
}
|
||||||
@@ -1881,7 +1961,7 @@ public enum XMaterial {
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public boolean isDuplicated() {
|
public boolean isDuplicated() {
|
||||||
return duplicated.containsKey(this);
|
return DUPLICATED.containsKey(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1984,7 +2064,8 @@ public enum XMaterial {
|
|||||||
if (mat == null) mat = requestOldMaterial(suggest);
|
if (mat == null) mat = requestOldMaterial(suggest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mat != null) PARSED_CACHE.put(this, Optional.ofNullable(mat));
|
Optional<Material> opt = Optional.ofNullable(mat);
|
||||||
|
PARSED_CACHE.put(this, opt);
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user