diff --git a/README.md b/README.md index 0a169de2..ed173668 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # XSeries -[![Bukkit Version](https://img.shields.io/badge/bukkit-1.18-dark_green.svg)](https://shields.io/) +[![Bukkit Version](https://img.shields.io/badge/bukkit-1.19-dark_green.svg)](https://shields.io/) [![Java](https://img.shields.io/badge/java-8-dark_green.svg)](https://shields.io/) [![Build Status](https://travis-ci.com/CryptoMorin/XSeries.svg?branch=master)](https://travis-ci.com/CryptoMorin/XSeries) ![maven-central](https://img.shields.io/maven-central/v/com.github.cryptomorin/XSeries) diff --git a/pom.xml b/pom.xml index 866541d5..24757fd0 100644 --- a/pom.xml +++ b/pom.xml @@ -63,7 +63,7 @@ - 1.19-R0.1-SNAPSHOT + 1.19.3-R0.1-SNAPSHOT diff --git a/src/main/java/com/cryptomorin/xseries/NMSExtras.java b/src/main/java/com/cryptomorin/xseries/NMSExtras.java index 9059c240..d9a702e2 100644 --- a/src/main/java/com/cryptomorin/xseries/NMSExtras.java +++ b/src/main/java/com/cryptomorin/xseries/NMSExtras.java @@ -44,7 +44,7 @@ * All the parameters are non-null. * * @author Crypto Morin - * @version 5.2.0 + * @version 5.2.1 */ public final class NMSExtras { public static final MethodHandle EXP_PACKET; @@ -205,7 +205,9 @@ public final class NMSExtras { MethodType.methodType(toArrayClass(IChatBaseComponent), String[].class)); tileEntitySign = lookup.findConstructor(TileEntitySign, MethodType.methodType(void.class, blockPos, BLOCK_DATA)); - tileEntitySign_getUpdatePacket = lookup.findVirtual(TileEntitySign, v(18, "c").orElse("getUpdatePacket"), MethodType.methodType(PacketPlayOutTileEntityData)); + tileEntitySign_getUpdatePacket = lookup.findVirtual(TileEntitySign, + v(19, "f").v(18, "c").orElse("getUpdatePacket"), + MethodType.methodType(PacketPlayOutTileEntityData)); tileEntitySign_setLine = lookup.findVirtual(TileEntitySign, "a", MethodType.methodType(void.class, int.class, IChatBaseComponent, IChatBaseComponent)); } } catch (NoSuchMethodException | IllegalAccessException | NoSuchFieldException ex) { diff --git a/src/main/java/com/cryptomorin/xseries/XMaterial.java b/src/main/java/com/cryptomorin/xseries/XMaterial.java index d40a61ea..627a0cf5 100644 --- a/src/main/java/com/cryptomorin/xseries/XMaterial.java +++ b/src/main/java/com/cryptomorin/xseries/XMaterial.java @@ -61,7 +61,7 @@ * /give @p minecraft:dirt 1 10 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 - * @version 11.2.0 + * @version 11.3.0 * @see Material * @see ItemStack */ @@ -72,6 +72,7 @@ public enum XMaterial { ACACIA_DOOR("ACACIA_DOOR", "ACACIA_DOOR_ITEM"), ACACIA_FENCE, ACACIA_FENCE_GATE, + ACACIA_HANGING_SIGN, ACACIA_LEAVES(0, "LEAVES_2"), ACACIA_LOG(0, "LOG_2"), ACACIA_PLANKS(4, "WOOD"), @@ -81,6 +82,7 @@ public enum XMaterial { ACACIA_SLAB(4, "WOOD_DOUBLE_STEP", "WOOD_STEP", "WOODEN_SLAB"), ACACIA_STAIRS, ACACIA_TRAPDOOR("TRAP_DOOR"), + ACACIA_WALL_HANGING_SIGN, ACACIA_WALL_SIGN("WALL_SIGN"), ACACIA_WOOD(0, "LOG_2"), ACTIVATOR_RAIL, @@ -115,7 +117,26 @@ public enum XMaterial { AZURE_BLUET(3, "RED_ROSE"), BAKED_POTATO, BAMBOO, + BAMBOO_BLOCK, + BAMBOO_BUTTON, + BAMBOO_CHEST_RAFT, + BAMBOO_DOOR, + BAMBOO_FENCE, + BAMBOO_FENCE_GATE, + BAMBOO_HANGING_SIGN, + BAMBOO_MOSAIC, + BAMBOO_MOSAIC_SLAB, + BAMBOO_MOSAIC_STAIRS, + BAMBOO_PLANKS, + BAMBOO_PRESSURE_PLATE, + BAMBOO_RAFT, BAMBOO_SAPLING, + BAMBOO_SIGN, + BAMBOO_SLAB, + BAMBOO_STAIRS, + BAMBOO_TRAPDOOR, + BAMBOO_WALL_HANGING_SIGN, + BAMBOO_WALL_SIGN, BARREL, BARRIER, BASALT, @@ -142,6 +163,7 @@ public enum XMaterial { BIRCH_DOOR("BIRCH_DOOR", "BIRCH_DOOR_ITEM"), BIRCH_FENCE, BIRCH_FENCE_GATE, + BIRCH_HANGING_SIGN, BIRCH_LEAVES(2, "LEAVES"), BIRCH_LOG(2, "LOG"), BIRCH_PLANKS(2, "WOOD"), @@ -151,6 +173,7 @@ public enum XMaterial { BIRCH_SLAB(2, "WOOD_DOUBLE_STEP", "WOOD_STEP", "WOODEN_SLAB"), BIRCH_STAIRS("BIRCH_WOOD_STAIRS"), BIRCH_TRAPDOOR("TRAP_DOOR"), + BIRCH_WALL_HANGING_SIGN, BIRCH_WALL_SIGN("WALL_SIGN"), BIRCH_WOOD(2, "LOG"), BLACKSTONE, @@ -242,6 +265,7 @@ public enum XMaterial { CACTUS, CAKE("CAKE_BLOCK"), CALCITE, + CAMEL_SPAWN_EGG, CAMPFIRE, CANDLE, CANDLE_CAKE, @@ -273,6 +297,7 @@ public enum XMaterial { CHICKEN("RAW_CHICKEN"), CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"), CHIPPED_ANVIL(1, "ANVIL"), + CHISELED_BOOKSHELF, CHISELED_DEEPSLATE, CHISELED_NETHER_BRICKS(1, "NETHER_BRICKS"), CHISELED_POLISHED_BLACKSTONE("POLISHED_BLACKSTONE"), @@ -345,6 +370,7 @@ public enum XMaterial { CRIMSON_FENCE, CRIMSON_FENCE_GATE, CRIMSON_FUNGUS, + CRIMSON_HANGING_SIGN, CRIMSON_HYPHAE, CRIMSON_NYLIUM, CRIMSON_PLANKS, @@ -355,6 +381,7 @@ public enum XMaterial { CRIMSON_STAIRS, CRIMSON_STEM, CRIMSON_TRAPDOOR, + CRIMSON_WALL_HANGING_SIGN, CRIMSON_WALL_SIGN("WALL_SIGN"), CROSSBOW, CRYING_OBSIDIAN, @@ -388,6 +415,7 @@ public enum XMaterial { DARK_OAK_DOOR("DARK_OAK_DOOR", "DARK_OAK_DOOR_ITEM"), DARK_OAK_FENCE, DARK_OAK_FENCE_GATE, + DARK_OAK_HANGING_SIGN, DARK_OAK_LEAVES(1, "LEAVES_2"), DARK_OAK_LOG(1, "LOG_2"), DARK_OAK_PLANKS(5, "WOOD"), @@ -397,6 +425,7 @@ public enum XMaterial { DARK_OAK_SLAB(5, "WOOD_DOUBLE_STEP", "WOOD_STEP", "WOODEN_SLAB"), DARK_OAK_STAIRS, DARK_OAK_TRAPDOOR("TRAP_DOOR"), + DARK_OAK_WALL_HANGING_SIGN, DARK_OAK_WALL_SIGN("WALL_SIGN"), DARK_OAK_WOOD(1, "LOG_2"), DARK_PRISMARINE(2, "PRISMARINE"), @@ -491,6 +520,7 @@ public enum XMaterial { ENDERMAN_SPAWN_EGG(58, "MONSTER_EGG"), ENDERMITE_SPAWN_EGG(67, "MONSTER_EGG"), ENDER_CHEST, + ENDER_DRAGON_SPAWN_EGG, ENDER_EYE("EYE_OF_ENDER"), ENDER_PEARL, END_CRYSTAL, @@ -659,6 +689,7 @@ public enum XMaterial { IRON_BOOTS, IRON_CHESTPLATE, IRON_DOOR("IRON_DOOR_BLOCK"), + IRON_GOLEM_SPAWN_EGG, IRON_HELMET, IRON_HOE, IRON_HORSE_ARMOR("IRON_BARDING"), @@ -680,6 +711,7 @@ public enum XMaterial { JUNGLE_DOOR("JUNGLE_DOOR", "JUNGLE_DOOR_ITEM"), JUNGLE_FENCE, JUNGLE_FENCE_GATE, + JUNGLE_HANGING_SIGN, JUNGLE_LEAVES(3, "LEAVES"), JUNGLE_LOG(3, "LOG"), JUNGLE_PLANKS(3, "WOOD"), @@ -689,6 +721,7 @@ public enum XMaterial { JUNGLE_SLAB(3, "WOOD_DOUBLE_STEP", "WOOD_STEP", "WOODEN_SLAB"), JUNGLE_STAIRS("JUNGLE_WOOD_STAIRS"), JUNGLE_TRAPDOOR("TRAP_DOOR"), + JUNGLE_WALL_HANGING_SIGN, JUNGLE_WALL_SIGN("WALL_SIGN"), JUNGLE_WOOD(3, "LOG"), KELP, @@ -796,6 +829,7 @@ public enum XMaterial { MANGROVE_DOOR, MANGROVE_FENCE, MANGROVE_FENCE_GATE, + MANGROVE_HANGING_SIGN, MANGROVE_LEAVES, MANGROVE_LOG, MANGROVE_PLANKS, @@ -806,6 +840,7 @@ public enum XMaterial { MANGROVE_SLAB, MANGROVE_STAIRS, MANGROVE_TRAPDOOR, + MANGROVE_WALL_HANGING_SIGN, MANGROVE_WALL_SIGN, MANGROVE_WOOD, /** @@ -902,6 +937,7 @@ public enum XMaterial { OAK_DOOR("WOODEN_DOOR", "WOOD_DOOR"), OAK_FENCE("FENCE"), OAK_FENCE_GATE("FENCE_GATE"), + OAK_HANGING_SIGN, OAK_LEAVES("LEAVES"), OAK_LOG("LOG"), OAK_PLANKS("WOOD"), @@ -911,6 +947,7 @@ public enum XMaterial { OAK_SLAB("WOOD_DOUBLE_STEP", "WOOD_STEP", "WOODEN_SLAB"), OAK_STAIRS("WOOD_STAIRS"), OAK_TRAPDOOR("TRAP_DOOR"), + OAK_WALL_HANGING_SIGN, OAK_WALL_SIGN("WALL_SIGN"), OAK_WOOD("LOG"), OBSERVER, @@ -951,7 +988,9 @@ public enum XMaterial { PHANTOM_SPAWN_EGG, PIGLIN_BANNER_PATTERN, PIGLIN_BRUTE_SPAWN_EGG, + PIGLIN_HEAD, PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"), + PIGLIN_WALL_HEAD, PIG_SPAWN_EGG(90, "MONSTER_EGG"), PILLAGER_SPAWN_EGG, PINK_BANNER(9, "STANDING_BANNER", "BANNER"), @@ -1212,6 +1251,7 @@ public enum XMaterial { SNOW, SNOWBALL("SNOW_BALL"), SNOW_BLOCK, + SNOW_GOLEM_SPAWN_EGG, SOUL_CAMPFIRE, SOUL_FIRE, SOUL_LANTERN, @@ -1232,6 +1272,7 @@ public enum XMaterial { SPRUCE_DOOR("SPRUCE_DOOR", "SPRUCE_DOOR_ITEM"), SPRUCE_FENCE, SPRUCE_FENCE_GATE, + SPRUCE_HANGING_SIGN, SPRUCE_LEAVES(1, "LEAVES"), SPRUCE_LOG(1, "LOG"), SPRUCE_PLANKS(1, "WOOD"), @@ -1241,6 +1282,7 @@ public enum XMaterial { SPRUCE_SLAB(1, "WOOD_DOUBLE_STEP", "WOOD_STEP", "WOODEN_SLAB"), SPRUCE_STAIRS("SPRUCE_WOOD_STAIRS"), SPRUCE_TRAPDOOR("TRAP_DOOR"), + SPRUCE_WALL_HANGING_SIGN, SPRUCE_WALL_SIGN("WALL_SIGN"), SPRUCE_WOOD(1, "LOG"), SPYGLASS, @@ -1267,6 +1309,7 @@ public enum XMaterial { STRING, STRIPPED_ACACIA_LOG, STRIPPED_ACACIA_WOOD, + STRIPPED_BAMBOO_BLOCK, STRIPPED_BIRCH_LOG, STRIPPED_BIRCH_WOOD, STRIPPED_CRIMSON_HYPHAE, @@ -1348,6 +1391,7 @@ public enum XMaterial { WARPED_FENCE_GATE, WARPED_FUNGUS, WARPED_FUNGUS_ON_A_STICK, + WARPED_HANGING_SIGN, WARPED_HYPHAE, WARPED_NYLIUM, WARPED_PLANKS, @@ -1358,6 +1402,7 @@ public enum XMaterial { WARPED_STAIRS, WARPED_STEM, WARPED_TRAPDOOR, + WARPED_WALL_HANGING_SIGN, WARPED_WALL_SIGN("WALL_SIGN"), WARPED_WART_BLOCK, /** @@ -1418,6 +1463,7 @@ public enum XMaterial { WITHER_SKELETON_SKULL(1, "SKULL", "SKULL_ITEM"), WITHER_SKELETON_SPAWN_EGG(5, "MONSTER_EGG"), WITHER_SKELETON_WALL_SKULL(1, "SKULL", "SKULL_ITEM"), + WITHER_SPAWN_EGG, WOLF_SPAWN_EGG(95, "MONSTER_EGG"), WOODEN_AXE("WOOD_AXE"), WOODEN_HOE("WOOD_HOE"), diff --git a/src/main/java/com/cryptomorin/xseries/XSound.java b/src/main/java/com/cryptomorin/xseries/XSound.java index 80aa80eb..66e2f800 100644 --- a/src/main/java/com/cryptomorin/xseries/XSound.java +++ b/src/main/java/com/cryptomorin/xseries/XSound.java @@ -55,7 +55,7 @@ * play command: https://minecraft.gamepedia.com/Commands/play * * @author Crypto Morin - * @version 8.0.1 + * @version 9.0.0 * @see Sound */ public enum XSound { @@ -123,6 +123,26 @@ public enum XSound { BLOCK_BAMBOO_SAPLING_HIT, BLOCK_BAMBOO_SAPLING_PLACE, BLOCK_BAMBOO_STEP, + BLOCK_BAMBOO_WOOD_BREAK, + BLOCK_BAMBOO_WOOD_BUTTON_CLICK_OFF, + BLOCK_BAMBOO_WOOD_BUTTON_CLICK_ON, + BLOCK_BAMBOO_WOOD_DOOR_CLOSE, + BLOCK_BAMBOO_WOOD_DOOR_OPEN, + BLOCK_BAMBOO_WOOD_FALL, + BLOCK_BAMBOO_WOOD_FENCE_GATE_CLOSE, + BLOCK_BAMBOO_WOOD_FENCE_GATE_OPEN, + BLOCK_BAMBOO_WOOD_HANGING_SIGN_BREAK, + BLOCK_BAMBOO_WOOD_HANGING_SIGN_FALL, + BLOCK_BAMBOO_WOOD_HANGING_SIGN_HIT, + BLOCK_BAMBOO_WOOD_HANGING_SIGN_PLACE, + BLOCK_BAMBOO_WOOD_HANGING_SIGN_STEP, + BLOCK_BAMBOO_WOOD_HIT, + BLOCK_BAMBOO_WOOD_PLACE, + BLOCK_BAMBOO_WOOD_PRESSURE_PLATE_CLICK_OFF, + BLOCK_BAMBOO_WOOD_PRESSURE_PLATE_CLICK_ON, + BLOCK_BAMBOO_WOOD_STEP, + BLOCK_BAMBOO_WOOD_TRAPDOOR_CLOSE, + BLOCK_BAMBOO_WOOD_TRAPDOOR_OPEN, BLOCK_BARREL_CLOSE, BLOCK_BARREL_OPEN, BLOCK_BASALT_BREAK, @@ -188,6 +208,15 @@ public enum XSound { BLOCK_CHEST_CLOSE("CHEST_CLOSE", "ENTITY_CHEST_CLOSE"), BLOCK_CHEST_LOCKED, BLOCK_CHEST_OPEN("CHEST_OPEN", "ENTITY_CHEST_OPEN"), + BLOCK_CHISELED_BOOKSHELF_BREAK, + BLOCK_CHISELED_BOOKSHELF_FALL, + BLOCK_CHISELED_BOOKSHELF_HIT, + BLOCK_CHISELED_BOOKSHELF_INSERT, + BLOCK_CHISELED_BOOKSHELF_INSERT_ENCHANTED, + BLOCK_CHISELED_BOOKSHELF_PICKUP, + BLOCK_CHISELED_BOOKSHELF_PICKUP_ENCHANTED, + BLOCK_CHISELED_BOOKSHELF_PLACE, + BLOCK_CHISELED_BOOKSHELF_STEP, BLOCK_CHORUS_FLOWER_DEATH, BLOCK_CHORUS_FLOWER_GROW, BLOCK_COMPARATOR_CLICK, @@ -293,6 +322,11 @@ public enum XSound { BLOCK_HANGING_ROOTS_HIT, BLOCK_HANGING_ROOTS_PLACE, BLOCK_HANGING_ROOTS_STEP, + BLOCK_HANGING_SIGN_BREAK, + BLOCK_HANGING_SIGN_FALL, + BLOCK_HANGING_SIGN_HIT, + BLOCK_HANGING_SIGN_PLACE, + BLOCK_HANGING_SIGN_STEP, BLOCK_HONEY_BLOCK_BREAK, BLOCK_HONEY_BLOCK_FALL, BLOCK_HONEY_BLOCK_HIT, @@ -395,6 +429,26 @@ public enum XSound { BLOCK_NETHER_SPROUTS_PLACE, BLOCK_NETHER_SPROUTS_STEP, BLOCK_NETHER_WART_BREAK, + BLOCK_NETHER_WOOD_BREAK, + BLOCK_NETHER_WOOD_BUTTON_CLICK_OFF, + BLOCK_NETHER_WOOD_BUTTON_CLICK_ON, + BLOCK_NETHER_WOOD_DOOR_CLOSE, + BLOCK_NETHER_WOOD_DOOR_OPEN, + BLOCK_NETHER_WOOD_FALL, + BLOCK_NETHER_WOOD_FENCE_GATE_CLOSE, + BLOCK_NETHER_WOOD_FENCE_GATE_OPEN, + BLOCK_NETHER_WOOD_HANGING_SIGN_BREAK, + BLOCK_NETHER_WOOD_HANGING_SIGN_FALL, + BLOCK_NETHER_WOOD_HANGING_SIGN_HIT, + BLOCK_NETHER_WOOD_HANGING_SIGN_PLACE, + BLOCK_NETHER_WOOD_HANGING_SIGN_STEP, + BLOCK_NETHER_WOOD_HIT, + BLOCK_NETHER_WOOD_PLACE, + BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_OFF, + BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_ON, + BLOCK_NETHER_WOOD_STEP, + BLOCK_NETHER_WOOD_TRAPDOOR_CLOSE, + BLOCK_NETHER_WOOD_TRAPDOOR_OPEN, BLOCK_NOTE_BLOCK_BANJO, BLOCK_NOTE_BLOCK_BASEDRUM("NOTE_BASS_DRUM", "BLOCK_NOTE_BASEDRUM"), BLOCK_NOTE_BLOCK_BASS("NOTE_BASS", "BLOCK_NOTE_BASS"), @@ -407,6 +461,12 @@ public enum XSound { BLOCK_NOTE_BLOCK_GUITAR("NOTE_BASS_GUITAR", "BLOCK_NOTE_GUITAR"), BLOCK_NOTE_BLOCK_HARP("NOTE_PIANO", "BLOCK_NOTE_HARP"), BLOCK_NOTE_BLOCK_HAT("NOTE_STICKS", "BLOCK_NOTE_HAT"), + BLOCK_NOTE_BLOCK_IMITATE_CREEPER, + BLOCK_NOTE_BLOCK_IMITATE_ENDER_DRAGON, + BLOCK_NOTE_BLOCK_IMITATE_PIGLIN, + BLOCK_NOTE_BLOCK_IMITATE_SKELETON, + BLOCK_NOTE_BLOCK_IMITATE_WITHER_SKELETON, + BLOCK_NOTE_BLOCK_IMITATE_ZOMBIE, BLOCK_NOTE_BLOCK_IRON_XYLOPHONE, BLOCK_NOTE_BLOCK_PLING("NOTE_PLING", "BLOCK_NOTE_PLING"), BLOCK_NOTE_BLOCK_SNARE("NOTE_SNARE_DRUM", "BLOCK_NOTE_SNARE"), @@ -649,6 +709,17 @@ public enum XSound { ENTITY_BLAZE_SHOOT, ENTITY_BOAT_PADDLE_LAND, ENTITY_BOAT_PADDLE_WATER, + ENTITY_CAMEL_AMBIENT, + ENTITY_CAMEL_DASH, + ENTITY_CAMEL_DASH_READY, + ENTITY_CAMEL_DEATH, + ENTITY_CAMEL_EAT, + ENTITY_CAMEL_HURT, + ENTITY_CAMEL_SADDLE, + ENTITY_CAMEL_SIT, + ENTITY_CAMEL_STAND, + ENTITY_CAMEL_STEP, + ENTITY_CAMEL_STEP_SAND, ENTITY_CAT_AMBIENT("CAT_MEOW"), ENTITY_CAT_BEG_FOR_FOOD, ENTITY_CAT_DEATH, diff --git a/src/main/java/com/cryptomorin/xseries/XTag.java b/src/main/java/com/cryptomorin/xseries/XTag.java index 4c91ad93..a0f72fd2 100644 --- a/src/main/java/com/cryptomorin/xseries/XTag.java +++ b/src/main/java/com/cryptomorin/xseries/XTag.java @@ -898,7 +898,7 @@ public final class XTag> { PORTALS = new XTag<>(XMaterial.END_GATEWAY, XMaterial.END_PORTAL, XMaterial.NETHER_PORTAL); FIRE = new XTag<>(XMaterial.FIRE, XMaterial.SOUL_FIRE); FLUID = new XTag<>(XMaterial.LAVA, XMaterial.WATER); - INVENTORY_NOT_DISPLAYABLE = new XTag<>(XMaterial.class, AIR, FIRE, FLUID, PORTALS); + INVENTORY_NOT_DISPLAYABLE = new XTag<>(XMaterial.class, AIR, FIRE, FLUID, PORTALS, new XTag<>(XMaterial.SWEET_BERRY_BUSH)); WALLS = new XTag<>(XMaterial.POLISHED_DEEPSLATE_WALL, XMaterial.NETHER_BRICK_WALL, diff --git a/src/test/DifferenceHelper.java b/src/test/DifferenceHelper.java index 8bae0301..a6a0273a 100644 --- a/src/test/DifferenceHelper.java +++ b/src/test/DifferenceHelper.java @@ -1,14 +1,19 @@ -import com.cryptomorin.xseries.XBiome; -import com.cryptomorin.xseries.XMaterial; -import com.cryptomorin.xseries.XSound; +import com.cryptomorin.xseries.*; import org.bukkit.Bukkit; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.potion.PotionEffectType; import java.io.BufferedWriter; import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; public class DifferenceHelper { /** @@ -18,11 +23,23 @@ public static void versionDifference() { Path serverFolder = Bukkit.getWorldContainer().toPath(); Path materials = serverFolder.resolve("XMaterial.txt"), sounds = serverFolder.resolve("XSound.txt"), + xPotion = serverFolder.resolve("XPotion.txt"), + xEnchant = serverFolder.resolve("XEnchantment.txt"), biomes = serverFolder.resolve("XBiome.txt"); writeDifference(materials, org.bukkit.Material.class, XMaterial.class, mat -> mat.startsWith("LEGACY_")); writeDifference(sounds, org.bukkit.Sound.class, XSound.class, null); writeDifference(biomes, org.bukkit.block.Biome.class, XBiome.class, null); + writeDifference(xPotion, getEnumLikeFields(PotionEffectType.class), XPotion.class, null); + writeDifference(xEnchant, getEnumLikeFields(Enchantment.class), XEnchantment.class, null); + } + + public static List getEnumLikeFields(Class clazz) { + return Arrays.stream(clazz.getDeclaredFields()) + .filter(x -> x.getType() == clazz) + .filter(x -> Modifier.isStatic(x.getModifiers())) + .map(Field::getName) + .collect(Collectors.toList()); } /** @@ -43,22 +60,28 @@ public static void versionDifference() { */ public static , E extends Enum> void writeDifference(Path path, Class system, Class custom, java.util.function.Predicate ignore) { + List enumNames = Arrays.stream(system.getEnumConstants()).map(Enum::name).collect(Collectors.toList()); + writeDifference(path, enumNames, custom, ignore); + } + + public static > + void writeDifference(Path path, List system, Class custom, java.util.function.Predicate ignore) { try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) { writer.write("------------------- Added -------------------"); writer.newLine(); - for (Enum systemConst : system.getEnumConstants()) { - if (ignore != null && ignore.test(systemConst.name())) continue; + for (String systemConst : system) { + if (ignore != null && ignore.test(systemConst)) continue; boolean exists = true; for (Enum customConst : custom.getEnumConstants()) { - if (systemConst.name().equals(customConst.name())) { + if (systemConst.equals(customConst.name())) { exists = false; break; } } if (exists) { - writer.write(systemConst.name() + ','); + writer.write(systemConst + ','); writer.newLine(); } } @@ -69,8 +92,8 @@ void writeDifference(Path path, Class system, Class custom, java.util.func for (Enum customConst : custom.getEnumConstants()) { boolean exists = true; - for (Enum systemConst : system.getEnumConstants()) { - if (systemConst.name().equals(customConst.name())) { + for (String systemConst : system) { + if (systemConst.equals(customConst.name())) { exists = false; break; } diff --git a/src/test/XSeriesTests.java b/src/test/XSeriesTests.java index 25aaf718..bc9eabb4 100644 --- a/src/test/XSeriesTests.java +++ b/src/test/XSeriesTests.java @@ -27,11 +27,11 @@ private static void err(String str) { @SuppressWarnings("deprecation") public static void test() { -// DifferenceHelper.versionDifference(); -// if (true) return; - print("\n\n\nTest begin..."); + print("Writing enum differences..."); + DifferenceHelper.versionDifference(); + print("Testing XMaterial..."); assertPresent(XMaterial.matchXMaterial("AIR")); assertMaterial("RED_BED", "RED_BED");