Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Turn some APIs into no-ops if they apply to clients without the relevant client functionality.
Dieser Commit ist enthalten in:
Ursprung
b88c573eb1
Commit
7e42c5b2e7
@ -330,11 +330,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
public void sendPlayerListHeaderAndFooter(final Component header, final Component footer) {
|
||||
this.playerListHeader = Objects.requireNonNull(header, "header");
|
||||
this.playerListFooter = Objects.requireNonNull(footer, "footer");
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
this.connection.write(HeaderAndFooter.create(header, footer, this.getProtocolVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTitle(net.kyori.adventure.title.@NonNull Title title) {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
|
||||
.getProtocolVersion());
|
||||
|
||||
@ -359,26 +362,35 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
|
||||
connection.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTitle() {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
connection.write(TitlePacket.hideForProtocolVersion(this.getProtocolVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTitle() {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
connection.write(TitlePacket.resetForProtocolVersion(this.getProtocolVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideBossBar(@NonNull BossBar bar) {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_9) >= 0) {
|
||||
this.server.getBossBarManager().removeBossBar(this, bar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBossBar(@NonNull BossBar bar) {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_9) >= 0) {
|
||||
this.server.getBossBarManager().addBossBar(this, bar);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionRequestBuilder createConnectionRequest(RegisteredServer server) {
|
||||
@ -835,11 +847,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
public void sendResourcePack(String url) {
|
||||
Preconditions.checkNotNull(url, "url");
|
||||
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
ResourcePackRequest request = new ResourcePackRequest();
|
||||
request.setUrl(url);
|
||||
request.setHash("");
|
||||
connection.write(request);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendResourcePack(String url, byte[] hash) {
|
||||
@ -847,11 +861,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
Preconditions.checkNotNull(hash, "hash");
|
||||
Preconditions.checkArgument(hash.length == 20, "Hash length is not 20");
|
||||
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
ResourcePackRequest request = new ResourcePackRequest();
|
||||
request.setUrl(url);
|
||||
request.setHash(ByteBufUtil.hexDump(hash));
|
||||
connection.write(request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a {@link KeepAlive} packet to the player with a random ID.
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren