public static EquivalentConverter<NativeGameMode> getGameModeConverter() { return new EnumConverter<>(getGameModeClass(), NativeGameMode.class); }
/** * 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()); }
MinecraftReflection.getGameProfileClass(), int.class, EnumWrappers.getGameModeClass(), MinecraftReflection.getIChatBaseComponentClass() );
@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; }