/** * Retrieves a read/write structure for chat components in Minecraft 1.7.2. * <p> * This modifier will automatically marshal between WrappedChatComponent and the * internal Minecraft IChatBaseComponent. * @return A modifier for ChatComponent fields. */ public StructureModifier<WrappedChatComponent> getChatComponents() { // Convert to and from the Bukkit wrapper return structureModifier.withType( MinecraftReflection.getIChatBaseComponentClass(), BukkitConverters.getWrappedChatComponentConverter()); }
builder.put(MinecraftReflection.getBlockClass(), (EquivalentConverter) getBlockConverter()); builder.put(MinecraftReflection.getGameProfileClass(), (EquivalentConverter) getWrappedGameProfileConverter()); builder.put(MinecraftReflection.getIChatBaseComponentClass(), (EquivalentConverter) getWrappedChatComponentConverter()); builder.put(MinecraftReflection.getServerPingClass(), (EquivalentConverter) getWrappedServerPingConverter()); builder.put(MinecraftReflection.getStatisticClass(), (EquivalentConverter) getWrappedStatisticConverter());
@Override public PlayerInfoData getSpecific(Object generic) { if (MinecraftReflection.isPlayerInfoData(generic)) { StructureModifier<Object> modifier = new StructureModifier<>(generic.getClass(), null, false) .withTarget(generic); StructureModifier<WrappedGameProfile> gameProfiles = modifier.withType( MinecraftReflection.getGameProfileClass(), BukkitConverters.getWrappedGameProfileConverter()); WrappedGameProfile gameProfile = gameProfiles.read(0); StructureModifier<Integer> ints = modifier.withType(int.class); int latency = ints.read(0); StructureModifier<NativeGameMode> gameModes = modifier.withType( EnumWrappers.getGameModeClass(), EnumWrappers.getGameModeConverter()); NativeGameMode gameMode = gameModes.read(0); StructureModifier<WrappedChatComponent> displayNames = modifier.withType( MinecraftReflection.getIChatBaseComponentClass(), BukkitConverters.getWrappedChatComponentConverter()); WrappedChatComponent displayName = displayNames.read(0); return new PlayerInfoData(gameProfile, latency, gameMode, displayName); } // Otherwise, return null return null; }