forked from BLOCKFANTASY/LOOHP-Limbo
Minecraft 1.19.1
This commit is contained in:
@@ -618,7 +618,7 @@ public class ClientConnection extends Thread {
|
||||
PacketPlayInTabComplete request = (PacketPlayInTabComplete) packetIn;
|
||||
String[] command = CustomStringUtils.splitStringToArgs(request.getText().substring(1));
|
||||
|
||||
List<TabCompleteMatches> matches = new ArrayList<TabCompleteMatches>(Limbo.getInstance().getPluginManager().getTabOptions(player, command).stream().map(each -> new TabCompleteMatches(each)).collect(Collectors.toList()));
|
||||
List<TabCompleteMatches> matches = new ArrayList<>(Limbo.getInstance().getPluginManager().getTabOptions(player, command).stream().map(each -> new TabCompleteMatches(each)).collect(Collectors.toList()));
|
||||
|
||||
int start = CustomStringUtils.getIndexOfArg(request.getText(), command.length - 1) + 1;
|
||||
int length = command[command.length - 1].length();
|
||||
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* This file is part of Limbo.
|
||||
*
|
||||
* Copyright (C) 2022. LoohpJames <jamesloohp@gmail.com>
|
||||
* Copyright (C) 2022. Contributors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
|
||||
import com.loohp.limbo.utils.NetworkEncryptionUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
public class ClientboundPlayerChatPacket extends PacketOut {
|
||||
|
||||
private Component signedContent;
|
||||
private Optional<Component> unsignedContent;
|
||||
private int position;
|
||||
private UUID sender;
|
||||
private Instant time;
|
||||
private NetworkEncryptionUtils.SignatureData saltSignature;
|
||||
|
||||
public ClientboundPlayerChatPacket(Component signedContent, Optional<Component> unsignedContent, int position, UUID sender, Instant time, NetworkEncryptionUtils.SignatureData saltSignature) {
|
||||
this.signedContent = signedContent;
|
||||
this.unsignedContent = unsignedContent;
|
||||
this.position = position;
|
||||
this.sender = sender;
|
||||
this.time = time;
|
||||
this.saltSignature = saltSignature;
|
||||
}
|
||||
|
||||
public Component getSignedContent() {
|
||||
return signedContent;
|
||||
}
|
||||
|
||||
public Optional<Component> getUnsignedContent() {
|
||||
return unsignedContent;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public UUID getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public Instant getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public NetworkEncryptionUtils.SignatureData getSaltSignature() {
|
||||
return saltSignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serializePacket() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(signedContent), StandardCharsets.UTF_8);
|
||||
if (unsignedContent.isPresent()) {
|
||||
output.writeBoolean(true);
|
||||
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(unsignedContent.get()), StandardCharsets.UTF_8);
|
||||
} else {
|
||||
output.writeBoolean(false);
|
||||
}
|
||||
DataTypeIO.writeVarInt(output, position);
|
||||
DataTypeIO.writeUUID(output, sender);
|
||||
output.writeLong(time.toEpochMilli());
|
||||
NetworkEncryptionUtils.SignatureData.write(output, saltSignature);
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
+7
-7
@@ -31,21 +31,21 @@ import java.nio.charset.StandardCharsets;
|
||||
public class ClientboundSystemChatPacket extends PacketOut {
|
||||
|
||||
private Component message;
|
||||
private int position;
|
||||
private boolean overlay;
|
||||
|
||||
public ClientboundSystemChatPacket(Component message, int position) {
|
||||
public ClientboundSystemChatPacket(Component message, boolean overlay) {
|
||||
this.message = message;
|
||||
this.position = position;
|
||||
this.overlay = overlay;
|
||||
}
|
||||
|
||||
public Component getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
public boolean isOverlay() {
|
||||
return overlay;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] serializePacket() throws IOException {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
@@ -53,7 +53,7 @@ public class ClientboundSystemChatPacket extends PacketOut {
|
||||
DataOutputStream output = new DataOutputStream(buffer);
|
||||
output.writeByte(Packet.getPlayOut().get(getClass()));
|
||||
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(message), StandardCharsets.UTF_8);
|
||||
DataTypeIO.writeVarInt(output, position);
|
||||
output.writeBoolean(overlay);
|
||||
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
|
||||
@@ -25,25 +25,29 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.NetworkEncryptionUtils;
|
||||
import com.loohp.limbo.utils.NetworkEncryptionUtils.SignatureData;
|
||||
import com.loohp.limbo.utils.LastSeenMessages;
|
||||
import com.loohp.limbo.utils.MessageSignature;
|
||||
|
||||
public class PacketPlayInChat extends PacketIn {
|
||||
|
||||
private String message;
|
||||
private Instant time;
|
||||
private NetworkEncryptionUtils.SignatureData signature;
|
||||
private boolean previewed;
|
||||
private long salt;
|
||||
private MessageSignature signature;
|
||||
private boolean signedPreview;
|
||||
private LastSeenMessages.b lastSeenMessages;
|
||||
|
||||
public PacketPlayInChat(String message, Instant time, SignatureData signature, boolean previewed) {
|
||||
public PacketPlayInChat(String message, Instant time, long salt, MessageSignature signature, boolean signedPreview, LastSeenMessages.b lastSeenMessages) {
|
||||
this.message = message;
|
||||
this.time = time;
|
||||
this.salt = salt;
|
||||
this.signature = signature;
|
||||
this.previewed = previewed;
|
||||
this.signedPreview = signedPreview;
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
}
|
||||
|
||||
public PacketPlayInChat(DataInputStream in) throws IOException {
|
||||
this(DataTypeIO.readString(in, StandardCharsets.UTF_8), Instant.ofEpochMilli(in.readLong()), new NetworkEncryptionUtils.SignatureData(in), in.readBoolean());
|
||||
this(DataTypeIO.readString(in, StandardCharsets.UTF_8), Instant.ofEpochMilli(in.readLong()), in.readLong(), new MessageSignature(in), in.readBoolean(), new LastSeenMessages.b(in));
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
@@ -54,12 +58,19 @@ public class PacketPlayInChat extends PacketIn {
|
||||
return time;
|
||||
}
|
||||
|
||||
public SignatureData getSignature() {
|
||||
public MessageSignature getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public boolean isPreviewed() {
|
||||
return previewed;
|
||||
public boolean isSignedPreview() {
|
||||
return signedPreview;
|
||||
}
|
||||
|
||||
public long getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public LastSeenMessages.b getLastSeenMessages() {
|
||||
return lastSeenMessages;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-15
@@ -19,45 +19,40 @@
|
||||
|
||||
package com.loohp.limbo.network.protocol.packets;
|
||||
|
||||
import com.loohp.limbo.utils.ArgumentSignatures;
|
||||
import com.loohp.limbo.utils.DataTypeIO;
|
||||
import com.loohp.limbo.utils.NetworkEncryptionUtils.ArgumentSignatures;
|
||||
import com.loohp.limbo.utils.LastSeenMessages;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ServerboundChatCommandPacket extends PacketIn {
|
||||
|
||||
private String command;
|
||||
private Instant time;
|
||||
private long salt;
|
||||
private ArgumentSignatures argumentSignatures;
|
||||
private boolean commandPreview;
|
||||
private LastSeenMessages.b lastSeenMessages;
|
||||
|
||||
public ServerboundChatCommandPacket(String command, Instant time, ArgumentSignatures argumentSignatures, boolean commandPreview) {
|
||||
public ServerboundChatCommandPacket(String command, Instant time, long salt, ArgumentSignatures argumentSignatures, boolean commandPreview, LastSeenMessages.b lastSeenMessages) {
|
||||
this.command = command;
|
||||
this.time = time;
|
||||
this.salt = salt;
|
||||
this.argumentSignatures = argumentSignatures;
|
||||
this.commandPreview = commandPreview;
|
||||
this.lastSeenMessages = lastSeenMessages;
|
||||
}
|
||||
|
||||
public ServerboundChatCommandPacket(DataInputStream in) throws IOException {
|
||||
this.command = DataTypeIO.readString(in, StandardCharsets.UTF_8);
|
||||
this.time = Instant.ofEpochMilli(in.readLong());
|
||||
long salt = in.readLong();
|
||||
int size = DataTypeIO.readVarInt(in);
|
||||
Map<String, byte[]> signatures = new HashMap<>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String key = DataTypeIO.readString(in, StandardCharsets.UTF_8);
|
||||
int arraySize = DataTypeIO.readVarInt(in);
|
||||
byte[] value = new byte[arraySize];
|
||||
in.readFully(value);
|
||||
signatures.put(key, value);
|
||||
}
|
||||
this.argumentSignatures = new ArgumentSignatures(salt, signatures);
|
||||
this.salt = in.readLong();
|
||||
this.argumentSignatures = new ArgumentSignatures(in);
|
||||
this.commandPreview = in.readBoolean();
|
||||
this.lastSeenMessages = new LastSeenMessages.b(in);
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
@@ -68,6 +63,10 @@ public class ServerboundChatCommandPacket extends PacketIn {
|
||||
return time;
|
||||
}
|
||||
|
||||
public long getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
public ArgumentSignatures getArgumentSignatures() {
|
||||
return argumentSignatures;
|
||||
}
|
||||
@@ -76,4 +75,7 @@ public class ServerboundChatCommandPacket extends PacketIn {
|
||||
return commandPreview;
|
||||
}
|
||||
|
||||
public LastSeenMessages.b getLastSeenMessages() {
|
||||
return lastSeenMessages;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user