forked from BLOCKFANTASY/LOOHP-Limbo
Fixed chat packets
This commit is contained in:
parent
081776e4fe
commit
ca186938f4
|
|
@ -435,7 +435,7 @@ public final class Limbo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyedBossBar createBossBar(Key Key, Component name, float progress, BossBar.Color color, BossBar.Overlay overlay, BossBar.Flag... flags) {
|
public KeyedBossBar createBossBar(Key Key, Component name, float progress, BossBar.Color color, BossBar.Overlay overlay, BossBar.Flag... flags) {
|
||||||
KeyedBossBar keyedBossBar = new KeyedBossBar(Key, BossBar.bossBar(name, progress, color, overlay, new HashSet<>(Arrays.asList(flags))));
|
KeyedBossBar keyedBossBar = com.loohp.limbo.bossbar.Unsafe.create(Key, BossBar.bossBar(name, progress, color, overlay, new HashSet<>(Arrays.asList(flags))));
|
||||||
bossBars.put(Key, keyedBossBar);
|
bossBars.put(Key, keyedBossBar);
|
||||||
return keyedBossBar;
|
return keyedBossBar;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,7 @@ public class KeyedBossBar {
|
||||||
protected final AtomicBoolean valid;
|
protected final AtomicBoolean valid;
|
||||||
private final Unsafe unsafe;
|
private final Unsafe unsafe;
|
||||||
|
|
||||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
KeyedBossBar(Key key, BossBar properties) {
|
||||||
@Deprecated
|
|
||||||
public KeyedBossBar(Key key, BossBar properties) {
|
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,18 @@
|
||||||
|
|
||||||
package com.loohp.limbo.bossbar;
|
package com.loohp.limbo.bossbar;
|
||||||
|
|
||||||
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
|
||||||
@SuppressWarnings("DeprecatedIsStillUsed")
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class Unsafe {
|
public class Unsafe {
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static KeyedBossBar create(Key key, BossBar properties) {
|
||||||
|
return new KeyedBossBar(key, properties);
|
||||||
|
}
|
||||||
|
|
||||||
private final KeyedBossBar instance;
|
private final KeyedBossBar instance;
|
||||||
|
|
||||||
protected Unsafe(KeyedBossBar instance) {
|
protected Unsafe(KeyedBossBar instance) {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public enum EquipmentSlot {
|
||||||
|
|
||||||
MAINHAND,
|
MAINHAND,
|
||||||
OFFHAND,
|
OFFHAND,
|
||||||
HELMENT,
|
HELMET,
|
||||||
CHESTPLATE,
|
CHESTPLATE,
|
||||||
LEGGINGS,
|
LEGGINGS,
|
||||||
BOOTS;
|
BOOTS;
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,7 @@ import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -122,7 +123,6 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class ClientConnection extends Thread {
|
public class ClientConnection extends Thread {
|
||||||
|
|
||||||
|
|
@ -283,7 +283,7 @@ public class ClientConnection extends Thread {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Constructor<?>[] constructors = packetType.getConstructors();
|
Constructor<?>[] constructors = packetType.getConstructors();
|
||||||
Constructor<?> constructor = Stream.of(constructors).filter(each -> each.getParameterCount() > 0 && each.getParameterTypes()[0].equals(DataInputStream.class)).findFirst().orElse(null);
|
Constructor<?> constructor = Arrays.stream(constructors).filter(each -> each.getParameterCount() > 0 && each.getParameterTypes()[0].equals(DataInputStream.class)).findFirst().orElse(null);
|
||||||
if (constructor == null) {
|
if (constructor == null) {
|
||||||
throw new NoSuchMethodException(packetType + " has no valid constructors!");
|
throw new NoSuchMethodException(packetType + " has no valid constructors!");
|
||||||
} else if (constructor.getParameterCount() == 1) {
|
} else if (constructor.getParameterCount() == 1) {
|
||||||
|
|
|
||||||
|
|
@ -34,20 +34,18 @@ public class PacketPlayInChat extends PacketIn {
|
||||||
private Instant time;
|
private Instant time;
|
||||||
private long salt;
|
private long salt;
|
||||||
private MessageSignature signature;
|
private MessageSignature signature;
|
||||||
private boolean signedPreview;
|
|
||||||
private LastSeenMessages.b lastSeenMessages;
|
private LastSeenMessages.b lastSeenMessages;
|
||||||
|
|
||||||
public PacketPlayInChat(String message, Instant time, long salt, MessageSignature signature, boolean signedPreview, LastSeenMessages.b lastSeenMessages) {
|
public PacketPlayInChat(String message, Instant time, long salt, MessageSignature signature, LastSeenMessages.b lastSeenMessages) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.salt = salt;
|
this.salt = salt;
|
||||||
this.signature = signature;
|
this.signature = signature;
|
||||||
this.signedPreview = signedPreview;
|
|
||||||
this.lastSeenMessages = lastSeenMessages;
|
this.lastSeenMessages = lastSeenMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketPlayInChat(DataInputStream in) throws IOException {
|
public PacketPlayInChat(DataInputStream in) throws IOException {
|
||||||
this(DataTypeIO.readString(in, StandardCharsets.UTF_8), Instant.ofEpochMilli(in.readLong()), in.readLong(), new MessageSignature(in), in.readBoolean(), new LastSeenMessages.b(in));
|
this(DataTypeIO.readString(in, StandardCharsets.UTF_8), Instant.ofEpochMilli(in.readLong()), in.readLong(), in.readBoolean() ? new MessageSignature(in) : null, new LastSeenMessages.b(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
|
@ -62,10 +60,6 @@ public class PacketPlayInChat extends PacketIn {
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSignedPreview() {
|
|
||||||
return signedPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSalt() {
|
public long getSalt() {
|
||||||
return salt;
|
return salt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,13 @@ public class ServerboundChatCommandPacket extends PacketIn {
|
||||||
private Instant time;
|
private Instant time;
|
||||||
private long salt;
|
private long salt;
|
||||||
private ArgumentSignatures argumentSignatures;
|
private ArgumentSignatures argumentSignatures;
|
||||||
private boolean commandPreview;
|
|
||||||
private LastSeenMessages.b lastSeenMessages;
|
private LastSeenMessages.b lastSeenMessages;
|
||||||
|
|
||||||
public ServerboundChatCommandPacket(String command, Instant time, long salt, ArgumentSignatures argumentSignatures, boolean commandPreview, LastSeenMessages.b lastSeenMessages) {
|
public ServerboundChatCommandPacket(String command, Instant time, long salt, ArgumentSignatures argumentSignatures, LastSeenMessages.b lastSeenMessages) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.salt = salt;
|
this.salt = salt;
|
||||||
this.argumentSignatures = argumentSignatures;
|
this.argumentSignatures = argumentSignatures;
|
||||||
this.commandPreview = commandPreview;
|
|
||||||
this.lastSeenMessages = lastSeenMessages;
|
this.lastSeenMessages = lastSeenMessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +49,6 @@ public class ServerboundChatCommandPacket extends PacketIn {
|
||||||
this.time = Instant.ofEpochMilli(in.readLong());
|
this.time = Instant.ofEpochMilli(in.readLong());
|
||||||
this.salt = in.readLong();
|
this.salt = in.readLong();
|
||||||
this.argumentSignatures = new ArgumentSignatures(in);
|
this.argumentSignatures = new ArgumentSignatures(in);
|
||||||
this.commandPreview = in.readBoolean();
|
|
||||||
this.lastSeenMessages = new LastSeenMessages.b(in);
|
this.lastSeenMessages = new LastSeenMessages.b(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,10 +68,6 @@ public class ServerboundChatCommandPacket extends PacketIn {
|
||||||
return argumentSignatures;
|
return argumentSignatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCommandPreview() {
|
|
||||||
return commandPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LastSeenMessages.b getLastSeenMessages() {
|
public LastSeenMessages.b getLastSeenMessages() {
|
||||||
return lastSeenMessages;
|
return lastSeenMessages;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue