/** * Retrieve a read/write structure for the NativeGameMode enum in 1.7.2. * @return A modifier for NativeGameMode enum fields. */ public StructureModifier<NativeGameMode> getGameModes() { // Convert to and from the wrapper return structureModifier.withType( EnumWrappers.getGameModeClass(), EnumWrappers.getGameModeConverter()); }
specific.profile.handle, specific.latency, EnumWrappers.getGameModeConverter().getGeneric(specific.gameMode), specific.displayName != null ? specific.displayName.handle : null );
@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; }
associate(DIFFICULTY_CLASS, Difficulty.class, getDifficultyConverter()); associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter()); associate(GAMEMODE_CLASS, NativeGameMode.class, getGameModeConverter()); associate(RESOURCE_PACK_STATUS_CLASS, ResourcePackStatus.class, getResourcePackStatusConverter()); associate(PLAYER_INFO_ACTION_CLASS, PlayerInfoAction.class, getPlayerInfoActionConverter());