geforkt von Mirrors/Velocity
Implement sendTitlePart for Players
Dieser Commit ist enthalten in:
Ursprung
20914ca134
Commit
3f647e4eb2
@ -95,6 +95,8 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import net.kyori.adventure.title.Title.Times;
|
||||
import net.kyori.adventure.title.TitlePart;
|
||||
import net.kyori.adventure.translation.GlobalTranslator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -369,7 +371,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
|
||||
.getProtocolVersion());
|
||||
|
||||
GenericTitlePacket timesPkt = GenericTitlePacket.constructTitlePacket(
|
||||
GenericTitlePacket.ActionType.SET_TIMES, this.getProtocolVersion());
|
||||
net.kyori.adventure.title.Title.Times times = title.times();
|
||||
@ -394,6 +395,41 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void sendTitlePart(@NotNull TitlePart<T> part, @NotNull T value) {
|
||||
if (part == null) {
|
||||
throw new NullPointerException("part");
|
||||
}
|
||||
if (value == null) {
|
||||
throw new NullPointerException("value");
|
||||
}
|
||||
|
||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(this
|
||||
.getProtocolVersion());
|
||||
|
||||
if (part == TitlePart.TITLE) {
|
||||
GenericTitlePacket titlePkt = GenericTitlePacket.constructTitlePacket(
|
||||
GenericTitlePacket.ActionType.SET_TITLE, this.getProtocolVersion());
|
||||
titlePkt.setComponent(serializer.serialize(translateMessage((Component) value)));
|
||||
connection.write(titlePkt);
|
||||
} else if (part == TitlePart.SUBTITLE) {
|
||||
GenericTitlePacket titlePkt = GenericTitlePacket.constructTitlePacket(
|
||||
GenericTitlePacket.ActionType.SET_TITLE, this.getProtocolVersion());
|
||||
titlePkt.setComponent(serializer.serialize(translateMessage((Component) value)));
|
||||
connection.write(titlePkt);
|
||||
} else if (part == TitlePart.TIMES) {
|
||||
Times times = (Times) value;
|
||||
GenericTitlePacket timesPkt = GenericTitlePacket.constructTitlePacket(
|
||||
GenericTitlePacket.ActionType.SET_TIMES, this.getProtocolVersion());
|
||||
timesPkt.setFadeIn((int) DurationUtils.toTicks(times.fadeIn()));
|
||||
timesPkt.setStay((int) DurationUtils.toTicks(times.stay()));
|
||||
timesPkt.setFadeOut((int) DurationUtils.toTicks(times.fadeOut()));
|
||||
connection.write(timesPkt);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Title part " + part + " is not valid");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTitle() {
|
||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren