Java Code Examples for com.velocitypowered.api.network.ProtocolVersion#getProtocol()
The following examples show how to use
com.velocitypowered.api.network.ProtocolVersion#getProtocol() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScoreboardObjective.java From TAB with Apache License 2.0 | 6 votes |
@Override public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { name = ProtocolUtils.readString(buf); if (version.getProtocol() <= ProtocolVersion.MINECRAFT_1_7_6.getProtocol()) { value = ProtocolUtils.readString(buf); } action = buf.readByte(); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol() && (action == 0 || action == 2)) { value = ProtocolUtils.readString(buf); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_13.getProtocol()) { type = HealthDisplay.values()[ProtocolUtils.readVarInt(buf)]; } else { type = HealthDisplay.fromString(ProtocolUtils.readString(buf)); } } }
Example 2
Source File: ScoreboardObjective.java From TAB with Apache License 2.0 | 6 votes |
@Override public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { ProtocolUtils.writeString(buf, name); if (version.getProtocol() <= ProtocolVersion.MINECRAFT_1_7_6.getProtocol()) { ProtocolUtils.writeString(buf, value); } buf.writeByte(action); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol() && (action == 0 || action == 2)) { ProtocolUtils.writeString(buf, value); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_13.getProtocol()) { ProtocolUtils.writeVarInt(buf, type.ordinal()); } else { ProtocolUtils.writeString(buf, type.toString()); } } }
Example 3
Source File: Team.java From TAB with Apache License 2.0 | 5 votes |
@Override public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { name = ProtocolUtils.readString(buf); mode = buf.readByte(); if (mode == 0 || mode == 2) { displayName = ProtocolUtils.readString(buf); if (version.getProtocol() < ProtocolVersion.MINECRAFT_1_13.getProtocol()) { prefix = ProtocolUtils.readString(buf); suffix = ProtocolUtils.readString(buf); } friendlyFire = buf.readByte(); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol()) { nameTagVisibility = ProtocolUtils.readString(buf); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_9.getProtocol()) { collisionRule = ProtocolUtils.readString(buf); } color = ((version.getProtocol() >= ProtocolVersion.MINECRAFT_1_13.getProtocol()) ? ProtocolUtils.readVarInt(buf) : buf.readByte()); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_13.getProtocol()) { prefix = ProtocolUtils.readString(buf); suffix = ProtocolUtils.readString(buf); } } } if (mode == 0 || mode == 3 || mode == 4) { final int len = (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol()) ? ProtocolUtils.readVarInt(buf) : buf.readShort(); players = new String[len]; for (int i = 0; i < len; ++i) { players[i] = ProtocolUtils.readString(buf); } } }
Example 4
Source File: Team.java From TAB with Apache License 2.0 | 5 votes |
@Override public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { ProtocolUtils.writeString(buf, name); buf.writeByte(mode); if (mode == 0 || mode == 2) { ProtocolUtils.writeString(buf, displayName); if (version.getProtocol() < ProtocolVersion.MINECRAFT_1_13.getProtocol()) { ProtocolUtils.writeString(buf, prefix); ProtocolUtils.writeString(buf, suffix); } buf.writeByte(friendlyFire); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol()) { ProtocolUtils.writeString(buf, nameTagVisibility); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_9.getProtocol()) { ProtocolUtils.writeString(buf, collisionRule); } if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_13.getProtocol()) { ProtocolUtils.writeVarInt(buf, color); ProtocolUtils.writeString(buf, prefix); ProtocolUtils.writeString(buf, suffix); } else { buf.writeByte(color); } } } if (mode == 0 || mode == 3 || mode == 4) { if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol()) { ProtocolUtils.writeVarInt(buf, players.length); } else { buf.writeShort(players.length); } for (final String player : players) { ProtocolUtils.writeString(buf, player); } } }
Example 5
Source File: ScoreboardScore.java From TAB with Apache License 2.0 | 5 votes |
@Override public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { itemName = ProtocolUtils.readString(buf); action = buf.readByte(); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol()) { scoreName = ProtocolUtils.readString(buf); if (action != 1) { value = ProtocolUtils.readVarInt(buf); } } else if (action != 1) { scoreName = ProtocolUtils.readString(buf); value = buf.readInt(); } }
Example 6
Source File: ScoreboardScore.java From TAB with Apache License 2.0 | 5 votes |
@Override public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) { ProtocolUtils.writeString(buf, itemName); buf.writeByte(action); if (version.getProtocol() >= ProtocolVersion.MINECRAFT_1_8.getProtocol()) { ProtocolUtils.writeString(buf, scoreName); if (action != 1) { ProtocolUtils.writeVarInt(buf, value); } } else if (action != 1) { ProtocolUtils.writeString(buf, scoreName); buf.writeInt(value); } }
Example 7
Source File: StatusSessionHandler.java From Velocity with MIT License | 5 votes |
private ServerPing createInitialPing() { VelocityConfiguration configuration = server.getConfiguration(); ProtocolVersion shownVersion = ProtocolVersion.isSupported(connection.getProtocolVersion()) ? connection.getProtocolVersion() : ProtocolVersion.MAXIMUM_VERSION; return new ServerPing( new ServerPing.Version(shownVersion.getProtocol(), "Velocity " + ProtocolVersion.SUPPORTED_VERSION_STRING), new ServerPing.Players(server.getPlayerCount(), configuration.getShowMaxPlayers(), ImmutableList.of()), configuration.getMotdComponent(), configuration.getFavicon().orElse(null), configuration.isAnnounceForge() ? ModInfo.DEFAULT : null ); }