/** * Retrieve a read/write structure for the Difficulty enum in 1.7.2. * @return A modifier for Difficulty enum fields. */ public StructureModifier<Difficulty> getDifficulties() { // Convert to and from the wrapper return structureModifier.withType( EnumWrappers.getDifficultyClass(), EnumWrappers.getDifficultyConverter()); }
/** * Retrieve a read/write structure for the ChatType enum in 1.12. * @return A modifier for ChatType enum fields. */ public StructureModifier<ChatType> getChatTypes() { return structureModifier.withType( EnumWrappers.getChatTypeClass(), EnumWrappers.getChatTypeConverter()); }
/** * Retrieve a read/write structure for the ChatVisibility enum in 1.7.2. * @return A modifier for ChatVisibility enum fields. */ public StructureModifier<ChatVisibility> getChatVisibilities() { // Convert to and from the wrapper return structureModifier.withType( EnumWrappers.getChatVisibilityClass(), EnumWrappers.getChatVisibilityConverter()); }
/** * Retrieve a read/write structure for the CombatEventType enum in 1.8. * @return A modifier for CombatEventType enum fields. */ public StructureModifier<CombatEventType> getCombatEvents() { // Convert to and from the wrapper return structureModifier.withType( EnumWrappers.getCombatEventTypeClass(), EnumWrappers.getCombatEventTypeConverter()); }
PROTOCOL_CLASS = getEnum(PacketType.Handshake.Client.SET_PROTOCOL.getPacketClass(), 0); CLIENT_COMMAND_CLASS = getEnum(PacketType.Play.Client.CLIENT_COMMAND.getPacketClass(), 0); CHAT_VISIBILITY_CLASS = getEnum(PacketType.Play.Client.SETTINGS.getPacketClass(), 0); DIFFICULTY_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 1); ENTITY_USE_ACTION_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 0); GAMEMODE_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 0); RESOURCE_PACK_STATUS_CLASS = getEnum(PacketType.Play.Client.RESOURCE_PACK_STATUS.getPacketClass(), 0); PLAYER_INFO_ACTION_CLASS = getEnum(PacketType.Play.Server.PLAYER_INFO.getPacketClass(), 0); TITLE_ACTION_CLASS = getEnum(PacketType.Play.Server.TITLE.getPacketClass(), 0); WORLD_BORDER_ACTION_CLASS = getEnum(PacketType.Play.Server.WORLD_BORDER.getPacketClass(), 0); COMBAT_EVENT_TYPE_CLASS = getEnum(PacketType.Play.Server.COMBAT_EVENT.getPacketClass(), 0); PLAYER_DIG_TYPE_CLASS = getEnum(PacketType.Play.Client.BLOCK_DIG.getPacketClass(), 1); PLAYER_ACTION_CLASS = getEnum(PacketType.Play.Client.ENTITY_ACTION.getPacketClass(), 0); SCOREBOARD_ACTION_CLASS = getEnum(PacketType.Play.Server.SCOREBOARD_SCORE.getPacketClass(), 0); PARTICLE_CLASS = getEnum(PacketType.Play.Server.WORLD_PARTICLES.getPacketClass(), 0); SOUND_CATEGORY_CLASS = getEnum(PacketType.Play.Server.CUSTOM_SOUND_EFFECT.getPacketClass(), 0); ITEM_SLOT_CLASS = getEnum(PacketType.Play.Server.ENTITY_EQUIPMENT.getPacketClass(), 0); HAND_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 1); DIRECTION_CLASS = getEnum(PacketType.Play.Client.USE_ITEM.getPacketClass(), 0); CHAT_TYPE_CLASS = getEnum(PacketType.Play.Server.CHAT.getPacketClass(), 0); associate(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter()); associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter()); associate(CHAT_VISIBILITY_CLASS, ChatVisibility.class, getChatVisibilityConverter()); 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());
/** * Retrieve a read/write structure for the ClientCommand enum in 1.7.2. * @return A modifier for ClientCommand enum fields. */ public StructureModifier<ClientCommand> getClientCommands() { // Convert to and from the wrapper return structureModifier.withType( EnumWrappers.getClientCommandClass(), EnumWrappers.getClientCommandConverter()); }
private PacketContainer createRespawnPacket(NativeGameMode gamemode) throws ReflectiveOperationException { PacketContainer respawn = new PacketContainer(RESPAWN); Difficulty difficulty = EnumWrappers.getDifficultyConverter().getSpecific(receiver.getWorld().getDifficulty()); //<= 1.13.1 int dimensionId = receiver.getWorld().getEnvironment().getId(); respawn.getIntegers().writeSafely(0, dimensionId); //> 1.13.1 if (MinecraftVersion.getCurrentVersion().compareTo(MinecraftVersion.AQUATIC_UPDATE) > 0) { try { respawn.getDimensions().writeSafely(0, dimensionId); } catch (NoSuchMethodError noSuchMethodError) { throw new ReflectiveOperationException("Unable to find dimension setter. " + "Your ProtocolLib version is incompatible with this plugin version in combination with " + "Minecraft 1.13.1. " + "Try to download an update of ProtocolLib.", noSuchMethodError); } } respawn.getDifficulties().write(0, difficulty); respawn.getGameModes().write(0, gamemode); respawn.getWorldTypeModifier().write(0, receiver.getWorld().getWorldType()); return respawn; }
public static EquivalentConverter<ClientCommand> getClientCommandConverter() { return new EnumConverter<>(getClientCommandClass(), ClientCommand.class); }
public static EquivalentConverter<ChatType> getChatTypeConverter() { return new EnumConverter<>(getChatTypeClass(), ChatType.class); }
public static EquivalentConverter<ChatVisibility> getChatVisibilityConverter() { return new EnumConverter<>(getChatVisibilityClass(), ChatVisibility.class); }
public static EquivalentConverter<CombatEventType> getCombatEventTypeConverter() { return new EnumConverter<>(getCombatEventTypeClass(), CombatEventType.class); }