mirror of
https://github.com/PaperMC/Velocity.git
synced 2024-11-27 06:30:35 +08:00
Clean up some Adventure support code, implement another sendMessage overload
This commit is contained in:
parent
5623baf1e7
commit
26f3cb43c7
@ -1,12 +1,8 @@
|
||||
package com.velocitypowered.api.proxy;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.inventory.Book;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.sound.SoundStop;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
@ -23,52 +19,7 @@ public interface ProxyAudience extends Audience {
|
||||
void sendMessage(@NonNull Component message);
|
||||
|
||||
@Override
|
||||
default void sendActionBar(@NonNull Component message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void showTitle(@NonNull Title title) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void clearTitle() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void resetTitle() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void showBossBar(@NonNull BossBar bar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void hideBossBar(@NonNull BossBar bar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void playSound(@NonNull Sound sound) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void playSound(@NonNull Sound sound, double x, double y, double z) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void stopSound(@NonNull SoundStop stop) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void openBook(@NonNull Book book) {
|
||||
|
||||
default void sendMessage(@NonNull Component message, @NonNull MessageType type) {
|
||||
sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@ -260,6 +261,16 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
connection.write(Chat.createClientbound(message, this.getProtocolVersion()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull Component message, @NonNull MessageType type) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
Preconditions.checkNotNull(type, "type");
|
||||
|
||||
Chat packet = Chat.createClientbound(message, this.getProtocolVersion());
|
||||
packet.setType(type == MessageType.CHAT ? Chat.CHAT_TYPE : Chat.SYSTEM_TYPE);
|
||||
connection.write(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(net.kyori.adventure.text.@NonNull Component message) {
|
||||
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_11) >= 0) {
|
||||
|
@ -13,6 +13,8 @@ import java.util.UUID;
|
||||
public class Chat implements MinecraftPacket {
|
||||
|
||||
public static final byte CHAT_TYPE = (byte) 0;
|
||||
public static final byte SYSTEM_TYPE = (byte) 1;
|
||||
|
||||
public static final int MAX_SERVERBOUND_MESSAGE_LENGTH = 256;
|
||||
public static final UUID EMPTY_SENDER = new UUID(0, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user