geforkt von Mirrors/Velocity
Clean up some Adventure support code, implement another sendMessage overload
Dieser Commit ist enthalten in:
Ursprung
5623baf1e7
Commit
26f3cb43c7
@ -1,12 +1,8 @@
|
|||||||
package com.velocitypowered.api.proxy;
|
package com.velocitypowered.api.proxy;
|
||||||
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.inventory.Book;
|
|
||||||
import net.kyori.adventure.sound.Sound;
|
|
||||||
import net.kyori.adventure.sound.SoundStop;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.title.Title;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,52 +19,7 @@ public interface ProxyAudience extends Audience {
|
|||||||
void sendMessage(@NonNull Component message);
|
void sendMessage(@NonNull Component message);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void sendActionBar(@NonNull Component message) {
|
default void sendMessage(@NonNull Component message, @NonNull MessageType type) {
|
||||||
|
sendMessage(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) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
import net.kyori.adventure.audience.MessageType;
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
@ -260,6 +261,16 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
connection.write(Chat.createClientbound(message, this.getProtocolVersion()));
|
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
|
@Override
|
||||||
public void sendActionBar(net.kyori.adventure.text.@NonNull Component message) {
|
public void sendActionBar(net.kyori.adventure.text.@NonNull Component message) {
|
||||||
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_11) >= 0) {
|
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_11) >= 0) {
|
||||||
|
@ -13,6 +13,8 @@ import java.util.UUID;
|
|||||||
public class Chat implements MinecraftPacket {
|
public class Chat implements MinecraftPacket {
|
||||||
|
|
||||||
public static final byte CHAT_TYPE = (byte) 0;
|
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 int MAX_SERVERBOUND_MESSAGE_LENGTH = 256;
|
||||||
public static final UUID EMPTY_SENDER = new UUID(0, 0);
|
public static final UUID EMPTY_SENDER = new UUID(0, 0);
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren