diff --git a/core/src/main/java/com/cryptomorin/xseries/XBlock.java b/core/src/main/java/com/cryptomorin/xseries/XBlock.java index f36e1cc6..f135d1e4 100644 --- a/core/src/main/java/com/cryptomorin/xseries/XBlock.java +++ b/core/src/main/java/com/cryptomorin/xseries/XBlock.java @@ -79,7 +79,7 @@ public final class XBlock { XMaterial.MAGMA_BLOCK, XMaterial.LAVA, XMaterial.CAMPFIRE, XMaterial.FIRE, XMaterial.SOUL_FIRE )); public static final byte CAKE_SLICES = 6; - private static final boolean ISFLAT = XMaterial.supports(13); + private static final boolean ISFLAT = XMaterial.supports(1, 13); private static final Map ITEM_TO_BLOCK = new EnumMap<>(XMaterial.class); static { @@ -407,7 +407,7 @@ public static XMaterial getType(Block block) { break; case BED: case BED_BLOCK: - if (!XMaterial.supports(12)) return XMaterial.RED_BED; + if (!XMaterial.supports(1, 12)) return XMaterial.RED_BED; // This doesn't work, the returned data value is incorrect. // data = (byte) (data & 0x7); // Mask to ignore head/foot, facing, occupied bits @@ -1060,7 +1060,7 @@ public static boolean isSimilar(Block block, XMaterial material) { Material mat = block.getType(); - if (material.name().endsWith("_BED") && !XMaterial.supports(12)) + if (material.name().endsWith("_BED") && !XMaterial.supports(1, 12)) return mat == LegacyBlockMaterial.BED_BLOCK.material || mat == LegacyBlockMaterial.BED.material; switch (material) { diff --git a/core/src/main/java/com/cryptomorin/xseries/XItemStack.java b/core/src/main/java/com/cryptomorin/xseries/XItemStack.java index e6d05d61..baa7efe8 100644 --- a/core/src/main/java/com/cryptomorin/xseries/XItemStack.java +++ b/core/src/main/java/com/cryptomorin/xseries/XItemStack.java @@ -654,7 +654,7 @@ private static Object singleOrList(List list) { @SuppressWarnings("deprecation") private void legacySpawnEgg() { - if (!supports(11)) { + if (!supports(1, 11)) { MaterialData data = item.getData(); if (data instanceof SpawnEgg) { SpawnEgg spawnEgg = (SpawnEgg) data; @@ -727,7 +727,7 @@ private void handleMapMeta(MapMeta map) { ConfigurationSection mapSection = config.createSection("map"); mapSection.set("scaling", map.isScaling()); - if (supports(11)) { + if (supports(1, 11)) { if (map.hasLocationName()) mapSection.set("location", map.getLocationName()); if (map.hasColor()) { Color color = map.getColor(); @@ -735,7 +735,7 @@ private void handleMapMeta(MapMeta map) { } } - if (supports(14)) { + if (supports(1, 14)) { if (map.hasMapView()) { MapView mapView = map.getMapView(); ConfigurationSection view = mapSection.createSection("view"); @@ -757,7 +757,7 @@ private void handleBookMeta(BookMeta book) { if (book.getTitle() != null) bookInfo.set("title", book.getTitle()); if (book.getAuthor() != null) bookInfo.set("author", book.getAuthor()); - if (supports(9)) { + if (supports(1, 9)) { BookMeta.Generation generation = book.getGeneration(); if (generation != null) { bookInfo.set("generation", book.getGeneration().toString()); @@ -811,7 +811,7 @@ private void handleFireworkMeta(FireworkMeta firework) { @SuppressWarnings({"deprecation", "StatementWithEmptyBody"}) private void handlePotionMeta(PotionMeta meta) { - if (supports(9)) { + if (supports(1, 9)) { if (SUPPORTS_PotionMeta_getBasePotionType) { PotionType basePotionType = meta.getBasePotionType(); if (basePotionType != null) @@ -880,7 +880,7 @@ private void handleEnchantmentStorageMeta(EnchantmentStorageMeta meta) { private void handleBlockStateMeta(BlockStateMeta meta) { BlockState state = safeBlockState(meta); - if (supports(11) && state instanceof ShulkerBox) { + if (supports(1, 11) && state instanceof ShulkerBox) { ShulkerBox box = (ShulkerBox) state; ConfigurationSection shulker = config.createSection("contents"); int i = 0; @@ -901,7 +901,7 @@ private void handleBlockStateMeta(BlockStateMeta meta) { @SuppressWarnings("deprecation") private void handleAttributes(ItemMeta meta) { - if (supports(13)) { + if (supports(1, 13)) { Multimap attributes = meta.getAttributeModifiers(); if (attributes != null) { for (Map.Entry attribute : attributes.entries()) { @@ -936,7 +936,7 @@ private void handleEnchants() { @SuppressWarnings("deprecation") private void handleDurability(ItemMeta meta) { - if (supports(13)) { + if (supports(1, 13)) { if (meta instanceof Damageable) { Damageable damageable = (Damageable) meta; if (damageable.hasDamage()) config.set("damage", damageable.getDamage()); @@ -1070,7 +1070,7 @@ public ItemStack deserialize() { private void attributes() { // Atrributes - https://minecraft.wiki/w/Attribute - if (!supports(13)) return; + if (!supports(1, 13)) return; ConfigurationSection attributes = config.getConfigurationSection("attributes"); if (attributes != null) { @@ -1119,7 +1119,7 @@ private void attributes() { @SuppressWarnings("deprecation") private void legacySpawnEgg() { - if (!supports(11)) { + if (!supports(1, 11)) { MaterialData data = item.getData(); if (data instanceof SpawnEgg) { String creatureName = config.getString("creature"); @@ -1416,14 +1416,14 @@ private void handleMapMeta(MapMeta map) { if (mapSection == null) return; map.setScaling(mapSection.getBoolean("scaling")); - if (supports(11)) { + if (supports(1, 11)) { if (mapSection.isSet("location")) map.setLocationName(mapSection.getString("location")); if (mapSection.isSet("color")) { parseColor(mapSection.getString("color")).ifPresent(map::setColor); } } - if (supports(14)) { + if (supports(1, 14)) { ConfigurationSection view = mapSection.getConfigurationSection("view"); if (view != null) { World world = Bukkit.getWorld(view.getString("world")); @@ -1455,7 +1455,7 @@ private void handleBookMeta(BookMeta book) { book.setAuthor(bookInfo.getString("author")); book.setPages(bookInfo.getStringList("pages")); - if (supports(9)) { + if (supports(1, 9)) { String generationValue = bookInfo.getString("generation"); if (generationValue != null) { BookMeta.Generation generation = Enums.getIfPresent(BookMeta.Generation.class, generationValue).orNull(); @@ -1515,7 +1515,7 @@ private void handleBlockStateMeta(BlockStateMeta bsm) { spawner.update(true); bsm.setBlockState(spawner); } - } else if (supports(11) && state instanceof ShulkerBox) { + } else if (supports(1, 11) && state instanceof ShulkerBox) { ConfigurationSection shulkerSection = config.getConfigurationSection("contents"); if (shulkerSection != null) { ShulkerBox box = (ShulkerBox) state; @@ -1532,7 +1532,7 @@ private void handleBlockStateMeta(BlockStateMeta bsm) { } else if (state instanceof Banner) { Banner banner = (Banner) state; ConfigurationSection patterns = config.getConfigurationSection("patterns"); - if (!supports(14)) { + if (!supports(1, 14)) { // https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/diff/src/main/java/org/bukkit/craftbukkit/block/CraftBanner.java?until=b3dc236663a55450c69356e660c0c84f0abbb3aa banner.setBaseColor(DyeColor.WHITE); } @@ -1563,7 +1563,7 @@ private void handleBlockStateMeta(BlockStateMeta bsm) { @SuppressWarnings("StatementWithEmptyBody") private void handlePotionMeta(ItemMeta meta) { - if (supports(9)) { + if (supports(1, 9)) { PotionMeta potion = (PotionMeta) meta; for (String effects : config.getStringList("effects")) { @@ -1694,7 +1694,7 @@ private void handleSkullMeta(SkullMeta meta) { @SuppressWarnings("deprecation") private void handleDurability() { - if (supports(13)) { + if (supports(1, 13)) { if (meta instanceof Damageable) { int damage = config.getInt("damage"); if (damage > 0) ((Damageable) meta).setDamage(damage); diff --git a/core/src/main/java/com/cryptomorin/xseries/XMaterial.java b/core/src/main/java/com/cryptomorin/xseries/XMaterial.java index a9919a24..5616af1c 100644 --- a/core/src/main/java/com/cryptomorin/xseries/XMaterial.java +++ b/core/src/main/java/com/cryptomorin/xseries/XMaterial.java @@ -199,7 +199,7 @@ public enum XMaterial implements XBase { /** * Version 1.12+ interprets "BED" as BLACK_BED due to enum alphabetic ordering. */ - BLACK_BED(supports(12) ? 15 : 0, "BED_BLOCK", "BED"), + BLACK_BED(supports(1, 12) ? 15 : 0, "BED_BLOCK", "BED"), BLACK_BUNDLE, BLACK_CANDLE, BLACK_CANDLE_CAKE, @@ -222,7 +222,7 @@ public enum XMaterial implements XBase { BLAZE_ROD, BLAZE_SPAWN_EGG(61, "MONSTER_EGG"), BLUE_BANNER(4, "STANDING_BANNER", "BANNER"), - BLUE_BED(supports(12) ? 11 : 0, "BED_BLOCK", "BED"), + BLUE_BED(supports(1, 12) ? 11 : 0, "BED_BLOCK", "BED"), BLUE_BUNDLE, BLUE_CANDLE, BLUE_CANDLE_CAKE, @@ -268,7 +268,7 @@ public enum XMaterial implements XBase { BRICK_STAIRS, BRICK_WALL, BROWN_BANNER(3, "STANDING_BANNER", "BANNER"), - BROWN_BED(supports(12) ? 12 : 0, "BED_BLOCK", "BED"), + BROWN_BED(supports(1, 12) ? 12 : 0, "BED_BLOCK", "BED"), BROWN_BUNDLE, BROWN_CANDLE, BROWN_CANDLE_CAKE, @@ -466,7 +466,7 @@ public enum XMaterial implements XBase { @XInfo(since = "1.14") CUT_SANDSTONE, @XInfo(since = "1.14") CUT_SANDSTONE_SLAB, CYAN_BANNER(6, "STANDING_BANNER", "BANNER"), - CYAN_BED(supports(12) ? 9 : 0, "BED_BLOCK", "BED"), + CYAN_BED(supports(1, 12) ? 9 : 0, "BED_BLOCK", "BED"), CYAN_BUNDLE, CYAN_CANDLE, CYAN_CANDLE_CAKE, @@ -711,7 +711,7 @@ public enum XMaterial implements XBase { GRASS_BLOCK("GRASS"), GRAVEL, GRAY_BANNER(8, "STANDING_BANNER", "BANNER"), - GRAY_BED(supports(12) ? 7 : 0, "BED_BLOCK", "BED"), + GRAY_BED(supports(1, 12) ? 7 : 0, "BED_BLOCK", "BED"), GRAY_BUNDLE, GRAY_CANDLE, GRAY_CANDLE_CAKE, @@ -729,7 +729,7 @@ public enum XMaterial implements XBase { GRAY_WALL_BANNER(8, "WALL_BANNER"), GRAY_WOOL(7, "WOOL"), GREEN_BANNER(2, "STANDING_BANNER", "BANNER"), - GREEN_BED(supports(12) ? 13 : 0, "BED_BLOCK", "BED"), + GREEN_BED(supports(1, 12) ? 13 : 0, "BED_BLOCK", "BED"), GREEN_BUNDLE, GREEN_CANDLE, GREEN_CANDLE_CAKE, @@ -862,7 +862,7 @@ public enum XMaterial implements XBase { LIGHT, LIGHTNING_ROD, LIGHT_BLUE_BANNER(12, "STANDING_BANNER", "BANNER"), - LIGHT_BLUE_BED(supports(12) ? 3 : 0, "BED_BLOCK", "BED"), + LIGHT_BLUE_BED(supports(1, 12) ? 3 : 0, "BED_BLOCK", "BED"), LIGHT_BLUE_BUNDLE, LIGHT_BLUE_CANDLE, LIGHT_BLUE_CANDLE_CAKE, @@ -880,7 +880,7 @@ public enum XMaterial implements XBase { LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "STANDING_BANNER", "BANNER"), LIGHT_BLUE_WOOL(3, "WOOL"), LIGHT_GRAY_BANNER(7, "STANDING_BANNER", "BANNER"), - LIGHT_GRAY_BED(supports(12) ? 8 : 0, "BED_BLOCK", "BED"), + LIGHT_GRAY_BED(supports(1, 12) ? 8 : 0, "BED_BLOCK", "BED"), LIGHT_GRAY_BUNDLE, LIGHT_GRAY_CANDLE, LIGHT_GRAY_CANDLE_CAKE, @@ -906,7 +906,7 @@ public enum XMaterial implements XBase { LILY_OF_THE_VALLEY, LILY_PAD("WATER_LILY"), LIME_BANNER(10, "STANDING_BANNER", "BANNER"), - LIME_BED(supports(12) ? 5 : 0, "BED_BLOCK", "BED"), + LIME_BED(supports(1, 12) ? 5 : 0, "BED_BLOCK", "BED"), LIME_BUNDLE, LIME_CANDLE, LIME_CANDLE_CAKE, @@ -929,7 +929,7 @@ public enum XMaterial implements XBase { LOOM, MACE, MAGENTA_BANNER(13, "STANDING_BANNER", "BANNER"), - MAGENTA_BED(supports(12) ? 2 : 0, "BED_BLOCK", "BED"), + MAGENTA_BED(supports(1, 12) ? 2 : 0, "BED_BLOCK", "BED"), MAGENTA_BUNDLE, MAGENTA_CANDLE, MAGENTA_CANDLE_CAKE, @@ -1100,7 +1100,7 @@ public enum XMaterial implements XBase { OMINOUS_TRIAL_KEY, OPEN_EYEBLOSSOM, ORANGE_BANNER(14, "STANDING_BANNER", "BANNER"), - ORANGE_BED(supports(12) ? 1 : 0, "BED_BLOCK", "BED"), + ORANGE_BED(supports(1, 12) ? 1 : 0, "BED_BLOCK", "BED"), ORANGE_BUNDLE, ORANGE_CANDLE, ORANGE_CANDLE_CAKE, @@ -1169,7 +1169,7 @@ public enum XMaterial implements XBase { PIG_SPAWN_EGG(90, "MONSTER_EGG"), PILLAGER_SPAWN_EGG, PINK_BANNER(9, "STANDING_BANNER", "BANNER"), - PINK_BED(supports(12) ? 6 : 0, "BED_BLOCK", "BED"), + PINK_BED(supports(1, 12) ? 6 : 0, "BED_BLOCK", "BED"), PINK_BUNDLE, PINK_CANDLE, PINK_CANDLE_CAKE, @@ -1301,7 +1301,7 @@ public enum XMaterial implements XBase { PUMPKIN_SEEDS, PUMPKIN_STEM, PURPLE_BANNER(5, "STANDING_BANNER", "BANNER"), - PURPLE_BED(supports(12) ? 10 : 0, "BED_BLOCK", "BED"), + PURPLE_BED(supports(1, 12) ? 10 : 0, "BED_BLOCK", "BED"), PURPLE_BUNDLE, PURPLE_CANDLE, PURPLE_CANDLE_CAKE, @@ -1366,7 +1366,7 @@ public enum XMaterial implements XBase { /** * Data value 14 or 0 */ - RED_BED(supports(12) ? 14 : 0, "BED_BLOCK", "BED"), + RED_BED(supports(1, 12) ? 14 : 0, "BED_BLOCK", "BED"), RED_BUNDLE, RED_CANDLE, RED_CANDLE_CAKE, @@ -1772,7 +1772,7 @@ public enum XMaterial implements XBase { WRITABLE_BOOK("BOOK_AND_QUILL"), WRITTEN_BOOK, YELLOW_BANNER(11, "STANDING_BANNER", "BANNER"), - YELLOW_BED(supports(12) ? 4 : 0, "BED_BLOCK", "BED"), + YELLOW_BED(supports(1, 12) ? 4 : 0, "BED_BLOCK", "BED"), YELLOW_BUNDLE, YELLOW_CANDLE, YELLOW_CANDLE_CAKE, @@ -1898,6 +1898,9 @@ public enum XMaterial implements XBase { @XInfo(since = "1.21.11") NETHERITE_NAUTILUS_ARMOR, @XInfo(since = "1.21.11") COPPER_NAUTILUS_ARMOR, + @XInfo(since = "26.1") GOLDEN_DANDELION, + @XInfo(since = "26.1") POTTED_GOLDEN_DANDELION, + ; @@ -2033,15 +2036,37 @@ private static Optional getIfPresent(@NotNull String name) { return Optional.ofNullable(NAMES.get(name)); } + /** + * The current major version of the server. + * + * @return the current server major minor number. + * @see #supports(int, int) + */ + public static int getVersionMajor() { + return Data.VERSION_MAJOR; + } + + /** + * The current minor version of the server. + * + * @return the current server version minor number. + * @see #supports(int, int) + */ + public static int getVersionMinor() { + return Data.VERSION_MINOR; + } + /** * The current version of the server. * * @return the current server version minor number. - * @see #supports(int) + * @see #supports(int, int) * @since 2.0.0 + * @deprecated Use {@link #getVersionMajor()} and {@link #getVersionMinor()} instead */ + @Deprecated public static int getVersion() { - return Data.VERSION; + return XMaterial.getVersionMinor(); } /** @@ -2156,7 +2181,7 @@ public static XMaterial matchXMaterial(@NotNull ItemStack item) { byte data = (byte) (Data.ISFLAT || material.equals("MAP") || item.getType().getMaxDurability() > 0 ? 0 : item.getDurability()); // Versions 1.9-1.12 didn't really use the items data value. - if (Data.SUPPORTS_SpawnEggMeta && !supports(13) && item.hasItemMeta() && material.equals("MONSTER_EGG")) { + if (Data.SUPPORTS_SpawnEggMeta && !supports(1, 13) && item.hasItemMeta() && material.equals("MONSTER_EGG")) { ItemMeta meta = item.getItemMeta(); if (meta instanceof SpawnEggMeta) { SpawnEggMeta egg = (SpawnEggMeta) meta; @@ -2175,7 +2200,7 @@ public static XMaterial matchXMaterial(@NotNull ItemStack item) { // Potions used the items data value to store // information about the type of potion in 1.8 - if (!supports(9) && material.equals("POTION")) { + if (!supports(1, 9) && material.equals("POTION")) { // Source: v1.8.8 org.bukkit.potion.Potion.fromDamage(int damage) int damage = item.getDurability(); return ((damage & 16384) > 0) ? SPLASH_POTION : POTION; @@ -2185,7 +2210,7 @@ public static XMaterial matchXMaterial(@NotNull ItemStack item) { // Currently, these are the only materials with a non-zero data value // that has been renamed after the flattening update. // If this happens to more materials in the future, I might have to change the system. - if (supports(13) && !supports(14)) { + if (supports(1, 13) && !supports(1, 14)) { // https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/diff/src/main/java/org/bukkit/Material.java?until=67d908a9830c71267ee740f5bddd728ce9c64cc7 switch (material) { case "CACTUS_GREEN": @@ -2303,13 +2328,14 @@ protected static String format(@NotNull String name) { * This is an internal API. Use {@link com.cryptomorin.xseries.reflection.XReflection#supports(int)} instead. * Checks if the specified version is the same version or higher than the current server version. * - * @param version the major version to be checked. "1." is ignored. E.g. 1.12 = 12 | 1.9 = 9 + * @param major the major version to be checked. E.g. 26 for 26. + * @param minor the minor version to be checked. E.g. 1 for 26.1 * @return true of the version is equal or higher than the current version. * @since 2.0.0 */ @ApiStatus.Internal - public static boolean supports(int version) { - return Data.VERSION >= version; + public static boolean supports(int major, int minor) { + return Data.VERSION_MAJOR > major || (Data.VERSION_MAJOR == major && Data.VERSION_MINOR >= minor); } public String[] getLegacy() { @@ -2433,7 +2459,7 @@ public ItemStack parseItem() { if (!Data.ISFLAT && this == SPLASH_POTION) { base.setDurability((short) 16384); // Hard-coded as 'data' is only a byte. } - if (supports(9) && !supports(13) && base.hasItemMeta() && this.name().endsWith("_SPAWN_EGG")) { + if (supports(1, 9) && !supports(1, 13) && base.hasItemMeta() && this.name().endsWith("_SPAWN_EGG")) { ItemMeta meta = base.getItemMeta(); if (meta instanceof SpawnEggMeta) { SpawnEggMeta egg = (SpawnEggMeta) meta; @@ -2558,7 +2584,7 @@ private static final class Data { * * @since 1.0.0 */ - private static final int VERSION; + private static final int VERSION_MAJOR, VERSION_MINOR; private static final Map BUKKIT_NAME_MAPPINGS; static { // This needs to be right below VERSION because of initialization order. @@ -2566,12 +2592,16 @@ private static final class Data { // noinspection ConstantValue if (Bukkit.getServer() == null) { System.err.println("Bukkit.getServer() is null. This should not happen when running a plugin normally."); - VERSION = 21; + VERSION_MAJOR = 1; + VERSION_MINOR = 21; } else { String version = Bukkit.getVersion(); - Matcher matcher = Pattern.compile("MC: \\d\\.(\\d+)").matcher(version); + Matcher matcher = Pattern.compile("MC: (\\d+)\\.(\\d+)").matcher(version); - if (matcher.find()) VERSION = Integer.parseInt(matcher.group(1)); + if (matcher.find()) { + VERSION_MAJOR = Integer.parseInt(matcher.group(1)); + VERSION_MINOR = Integer.parseInt(matcher.group(2)); + } else throw new IllegalArgumentException("Failed to parse server version: " + version); } } @@ -2617,7 +2647,7 @@ private static Material getExactMaterial(String name) { * * @since 3.0.0 */ - private static final boolean ISFLAT = supports(13); + private static final boolean ISFLAT = supports(1, 13); /** * Added around Minecraft v1.11 diff --git a/core/src/main/java/com/cryptomorin/xseries/XSound.java b/core/src/main/java/com/cryptomorin/xseries/XSound.java index e00eff2d..0bf7b4b7 100644 --- a/core/src/main/java/com/cryptomorin/xseries/XSound.java +++ b/core/src/main/java/com/cryptomorin/xseries/XSound.java @@ -1957,6 +1957,72 @@ public final class XSound extends XModule { ITEM_SPEAR_WOOD_HIT = std("item.spear_wood.hit"), ITEM_SPEAR_WOOD_USE = std("item.spear_wood.use"); + @XInfo(since = "26.1") + public static final XSound + BLOCK_NOTE_BLOCK_TRUMPET = std("block.note_block.trumpet"), + BLOCK_NOTE_BLOCK_TRUMPET_EXPOSED = std("block.note_block.trumpet_exposed"), + BLOCK_NOTE_BLOCK_TRUMPET_OXIDIZED = std("block.note_block.trumpet_oxidized"), + BLOCK_NOTE_BLOCK_TRUMPET_WEATHERED = std("block.note_block.trumpet_weathered"), + ENTITY_BABY_CAT_AMBIENT = std("entity.baby_cat.ambient"), + ENTITY_BABY_CAT_BEG_FOR_FOOD = std("entity.baby_cat.beg_for_food"), + ENTITY_BABY_CAT_DEATH = std("entity.baby_cat.death"), + ENTITY_BABY_CAT_EAT = std("entity.baby_cat.eat"), + ENTITY_BABY_CAT_HISS = std("entity.baby_cat.hiss"), + ENTITY_BABY_CAT_HURT = std("entity.baby_cat.hurt"), + ENTITY_BABY_CAT_PURR = std("entity.baby_cat.purr"), + ENTITY_BABY_CAT_PURREOW = std("entity.baby_cat.purreow"), + ENTITY_BABY_CAT_STRAY_AMBIENT = std("entity.baby_cat.stray_ambient"), + ENTITY_BABY_CHICKEN_AMBIENT = std("entity.baby_chicken.ambient"), + ENTITY_BABY_CHICKEN_DEATH = std("entity.baby_chicken.death"), + ENTITY_BABY_CHICKEN_HURT = std("entity.baby_chicken.hurt"), + ENTITY_BABY_CHICKEN_STEP = std("entity.baby_chicken.step"), + ENTITY_BABY_HORSE_AMBIENT = std("entity.baby_horse.ambient"), + ENTITY_BABY_HORSE_ANGRY = std("entity.baby_horse.angry"), + ENTITY_BABY_HORSE_BREATHE = std("entity.baby_horse.breathe"), + ENTITY_BABY_HORSE_DEATH = std("entity.baby_horse.death"), + ENTITY_BABY_HORSE_EAT = std("entity.baby_horse.eat"), + ENTITY_BABY_HORSE_HURT = std("entity.baby_horse.hurt"), + ENTITY_BABY_HORSE_LAND = std("entity.baby_horse.land"), + ENTITY_BABY_HORSE_STEP = std("entity.baby_horse.step"), + ENTITY_BABY_PIG_AMBIENT = std("entity.baby_pig.ambient"), + ENTITY_BABY_PIG_DEATH = std("entity.baby_pig.death"), + ENTITY_BABY_PIG_EAT = std("entity.baby_pig.eat"), + ENTITY_BABY_PIG_HURT = std("entity.baby_pig.hurt"), + ENTITY_BABY_PIG_STEP = std("entity.baby_pig.step"), + ENTITY_BABY_WOLF_AMBIENT = std("entity.baby_wolf.ambient"), + ENTITY_BABY_WOLF_DEATH = std("entity.baby_wolf.death"), + ENTITY_BABY_WOLF_GROWL = std("entity.baby_wolf.growl"), + ENTITY_BABY_WOLF_HURT = std("entity.baby_wolf.hurt"), + ENTITY_BABY_WOLF_PANT = std("entity.baby_wolf.pant"), + ENTITY_BABY_WOLF_STEP = std("entity.baby_wolf.step"), + ENTITY_BABY_WOLF_WHINE = std("entity.baby_wolf.whine"), + ENTITY_CAT_ROYAL_AMBIENT = std("entity.cat_royal.ambient"), + ENTITY_CAT_ROYAL_BEG_FOR_FOOD = std("entity.cat_royal.beg_for_food"), + ENTITY_CAT_ROYAL_DEATH = std("entity.cat_royal.death"), + ENTITY_CAT_ROYAL_EAT = std("entity.cat_royal.eat"), + ENTITY_CAT_ROYAL_HISS = std("entity.cat_royal.hiss"), + ENTITY_CAT_ROYAL_HURT = std("entity.cat_royal.hurt"), + ENTITY_CAT_ROYAL_PURR = std("entity.cat_royal.purr"), + ENTITY_CAT_ROYAL_PURREOW = std("entity.cat_royal.purreow"), + ENTITY_CAT_ROYAL_STRAY_AMBIENT = std("entity.cat_royal.stray_ambient"), + ENTITY_CHICKEN_PICKY_AMBIENT = std("entity.chicken_picky.ambient"), + ENTITY_CHICKEN_PICKY_DEATH = std("entity.chicken_picky.death"), + ENTITY_CHICKEN_PICKY_HURT = std("entity.chicken_picky.hurt"), + ENTITY_COW_MOODY_AMBIENT = std("entity.cow_moody.ambient"), + ENTITY_COW_MOODY_DEATH = std("entity.cow_moody.death"), + ENTITY_COW_MOODY_HURT = std("entity.cow_moody.hurt"), + ENTITY_COW_MOODY_STEP = std("entity.cow_moody.step"), + ENTITY_PIG_BIG_AMBIENT = std("entity.pig_big.ambient"), + ENTITY_PIG_BIG_DEATH = std("entity.pig_big.death"), + ENTITY_PIG_BIG_EAT = std("entity.pig_big.eat"), + ENTITY_PIG_BIG_HURT = std("entity.pig_big.hurt"), + ENTITY_PIG_EAT = std("entity.pig.eat"), + ENTITY_PIG_MINI_AMBIENT = std("entity.pig_mini.ambient"), + ENTITY_PIG_MINI_DEATH = std("entity.pig_mini.death"), + ENTITY_PIG_MINI_EAT = std("entity.pig_mini.eat"), + ENTITY_PIG_MINI_HURT = std("entity.pig_mini.hurt"), + ITEM_GOLDEN_DANDELION_UNUSE = std("item.golden_dandelion.unuse"), + ITEM_GOLDEN_DANDELION_USE = std("item.golden_dandelion.use"); static { REGISTRY.discardMetadata(); diff --git a/core/src/main/java/com/cryptomorin/xseries/XTag.java b/core/src/main/java/com/cryptomorin/xseries/XTag.java index f67d5b09..289fd9f6 100644 --- a/core/src/main/java/com/cryptomorin/xseries/XTag.java +++ b/core/src/main/java/com/cryptomorin/xseries/XTag.java @@ -2751,7 +2751,7 @@ private static XMaterial[] findAllCorals(boolean alive, boolean block, boolean f * @since 1.13 */ public static boolean isItem(XMaterial material) { - if (XMaterial.supports(13)) { + if (XMaterial.supports(1, 13)) { Material mat = material.get(); return mat != null && mat.isItem(); } @@ -2855,7 +2855,7 @@ public static boolean isItem(XMaterial material) { * @since 1.13 */ public static boolean isInteractable(XMaterial material) { - if (XMaterial.supports(13)) return material.get().isInteractable(); + if (XMaterial.supports(1, 13)) return material.get().isInteractable(); switch (material) { // 1.12 materials only case ACACIA_BUTTON: case ACACIA_DOOR: diff --git a/core/src/main/java/com/cryptomorin/xseries/particles/XParticle.java b/core/src/main/java/com/cryptomorin/xseries/particles/XParticle.java index b50b988c..c62f23fa 100644 --- a/core/src/main/java/com/cryptomorin/xseries/particles/XParticle.java +++ b/core/src/main/java/com/cryptomorin/xseries/particles/XParticle.java @@ -299,6 +299,9 @@ public enum XParticle implements XBase { WITCH("SPELL_WITCH"), @XInfo(since = "1.21.9") COPPER_FIRE_FLAME, + + @XInfo(since = "26.1") PAUSE_MOB_GROWTH, + @XInfo(since = "26.1") RESET_MOB_GROWTH, ; public static final XRegistry REGISTRY = Data.REGISTRY; diff --git a/core/src/main/java/com/cryptomorin/xseries/reflection/XReflection.java b/core/src/main/java/com/cryptomorin/xseries/reflection/XReflection.java index bb48c0e1..1f7ef7b9 100644 --- a/core/src/main/java/com/cryptomorin/xseries/reflection/XReflection.java +++ b/core/src/main/java/com/cryptomorin/xseries/reflection/XReflection.java @@ -447,6 +447,7 @@ public static VersionHandle v(int version, int patch, Callable handle) /** * Checks whether the server version is equal or greater than the given version. + * The major version number is always assumed to be 1. * * @param minorNumber the version to compare the server version with. * @return true if the version is equal or newer, otherwise false. @@ -455,7 +456,7 @@ public static VersionHandle v(int version, int patch, Callable handle) */ @Contract(pure = true) public static boolean supports(int minorNumber) { - return MINOR_NUMBER >= minorNumber; + return supports(1, minorNumber, 0); } /** @@ -463,12 +464,12 @@ public static boolean supports(int minorNumber) { */ @Contract(pure = true) public static boolean supports(int majorNumber, int minorNumber, int patchNumber) { - if (majorNumber != 1) throw new IllegalArgumentException("Invalid major number: " + majorNumber); - return supports(minorNumber, patchNumber); + return MAJOR_NUMBER == majorNumber ? MINOR_NUMBER == minorNumber ? PATCH_NUMBER >= patchNumber : MINOR_NUMBER > minorNumber : MAJOR_NUMBER > majorNumber; } /** * Checks whether the server version is equal or greater than the given version. + * The major version number is always assumed to be 1. * * @param minorNumber the minor version to compare the server version with. * @param patchNumber the patch number to compare the server version with. @@ -479,7 +480,7 @@ public static boolean supports(int majorNumber, int minorNumber, int patchNumber */ @Contract(pure = true) public static boolean supports(int minorNumber, int patchNumber) { - return MINOR_NUMBER == minorNumber ? PATCH_NUMBER >= patchNumber : supports(minorNumber); + return supports(1, minorNumber, patchNumber); } /** diff --git a/core/src/main/java/com/cryptomorin/xseries/reflection/asm/XReflectASM.java b/core/src/main/java/com/cryptomorin/xseries/reflection/asm/XReflectASM.java index d2d654c6..03bf1367 100644 --- a/core/src/main/java/com/cryptomorin/xseries/reflection/asm/XReflectASM.java +++ b/core/src/main/java/com/cryptomorin/xseries/reflection/asm/XReflectASM.java @@ -208,10 +208,10 @@ public final class XReflectASM extends ClassVis Class.forName("jdk.internal.reflect.MagicAccessorImpl"); magicAccessor = "jdk/internal/reflect/MagicAccessorImpl"; } catch (ClassNotFoundException ex) { - IllegalStateException state = new IllegalStateException("Cannot find MagicAccessorImpl class"); - state.addSuppressed(e); - state.addSuppressed(ex); - throw state; + // MagicAccessorImpl has been removed https://github.com/openjdk/jdk/commit/d6eddcdaf92f2352266ba519608879141997cd63 + // Therefore throwing an exception here would prevent this class from being used on Java 25 (required + // for Minecraft 26.1). Instead, the class name is set to null as it is currently not used anyway. + magicAccessor = null; } } diff --git a/core/src/test/com/cryptomorin/xseries/test/XSeriesTests.java b/core/src/test/com/cryptomorin/xseries/test/XSeriesTests.java index 13b9ccef..027f5629 100644 --- a/core/src/test/com/cryptomorin/xseries/test/XSeriesTests.java +++ b/core/src/test/com/cryptomorin/xseries/test/XSeriesTests.java @@ -351,7 +351,7 @@ private static void testXMaterial() { assertMaterial("INK_SACK:3", XMaterial.COCOA_BEANS); assertMaterial("INK_SACK:4", XMaterial.LAPIS_LAZULI); - if (XMaterial.supports(14)) { + if (XMaterial.supports(1, 14)) { assertNotNull(XMaterial.ACACIA_SIGN.parseItem(), "Acacia Sign is null"); assertMaterial(XMaterial.RED_DYE, Material.RED_DYE); assertMaterial(XMaterial.GREEN_DYE, Material.GREEN_DYE); @@ -359,7 +359,7 @@ private static void testXMaterial() { assertMaterial("RED_BED", "RED_BED"); assertMaterial("GREEN_CONCRETE_POWDER", "CONCRETE_POWDER:13"); - } else if (XMaterial.supports(13)) { + } else if (XMaterial.supports(1, 13)) { log("Black dye is " + XMaterial.BLACK_DYE.get() + " - " + XMaterial.BLACK_DYE.parseItem()); assertMaterial(XMaterial.CYAN_DYE, Material.CYAN_DYE); assertMaterial(XMaterial.GREEN_DYE, Material.valueOf("CACTUS_GREEN")); diff --git a/pom.xml b/pom.xml index 918ee863..f74db6ce 100644 --- a/pom.xml +++ b/pom.xml @@ -56,12 +56,12 @@ - 1.21.11-R0.1-20251210.073034-1 + 26.1-R0.1-20260325.170250-2 5.0.4 - 21 - 9.7.1 + 25 + 9.9.1 @@ -566,8 +566,16 @@ latest - 21_R0 - 21 + 26_R0 + 25 + + + + 26 + + 26_R0 + 26.1-R0.1-SNAPSHOT + 25