Minecraft 1.19.1

This commit is contained in:
LOOHP 2022-07-28 18:07:31 +08:00
parent 42559d83f0
commit ace420a017
15 changed files with 1556 additions and 1387 deletions

View File

@ -24,7 +24,7 @@
<groupId>com.loohp</groupId> <groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId> <artifactId>Limbo</artifactId>
<name>Limbo</name> <name>Limbo</name>
<version>0.6.16-ALPHA</version> <version>0.6.17-ALPHA</version>
<description>Standalone Limbo Minecraft Server.</description> <description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url> <url>https://github.com/LOOHP/Limbo</url>
@ -136,7 +136,7 @@
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<finalName>${project.artifactId}-${project.version}-1.19</finalName> <finalName>${project.artifactId}-${project.version}-1.19.1</finalName>
</build> </build>
<profiles> <profiles>

View File

@ -131,8 +131,8 @@ public class Limbo {
//=========================== //===========================
public final String SERVER_IMPLEMENTATION_VERSION = "1.19"; public final String SERVER_IMPLEMENTATION_VERSION = "1.19.1";
public final int SERVER_IMPLEMENTATION_PROTOCOL = 759; public final int SERVER_IMPLEMENTATION_PROTOCOL = 760;
public final String LIMBO_IMPLEMENTATION_VERSION; public final String LIMBO_IMPLEMENTATION_VERSION;
private AtomicBoolean isRunning; private AtomicBoolean isRunning;

View File

@ -618,7 +618,7 @@ public class ClientConnection extends Thread {
PacketPlayInTabComplete request = (PacketPlayInTabComplete) packetIn; PacketPlayInTabComplete request = (PacketPlayInTabComplete) packetIn;
String[] command = CustomStringUtils.splitStringToArgs(request.getText().substring(1)); 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 start = CustomStringUtils.getIndexOfArg(request.getText(), command.length - 1) + 1;
int length = command[command.length - 1].length(); int length = command[command.length - 1].length();

View File

@ -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();
}
}

View File

@ -31,21 +31,21 @@ import java.nio.charset.StandardCharsets;
public class ClientboundSystemChatPacket extends PacketOut { public class ClientboundSystemChatPacket extends PacketOut {
private Component message; 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.message = message;
this.position = position; this.overlay = overlay;
} }
public Component getMessage() { public Component getMessage() {
return message; return message;
} }
public int getPosition() { public boolean isOverlay() {
return position; return overlay;
} }
@Override @Override
public byte[] serializePacket() throws IOException { public byte[] serializePacket() throws IOException {
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream();
@ -53,7 +53,7 @@ public class ClientboundSystemChatPacket extends PacketOut {
DataOutputStream output = new DataOutputStream(buffer); DataOutputStream output = new DataOutputStream(buffer);
output.writeByte(Packet.getPlayOut().get(getClass())); output.writeByte(Packet.getPlayOut().get(getClass()));
DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(message), StandardCharsets.UTF_8); DataTypeIO.writeString(output, GsonComponentSerializer.gson().serialize(message), StandardCharsets.UTF_8);
DataTypeIO.writeVarInt(output, position); output.writeBoolean(overlay);
return buffer.toByteArray(); return buffer.toByteArray();
} }

View File

@ -25,25 +25,29 @@ import java.nio.charset.StandardCharsets;
import java.time.Instant; import java.time.Instant;
import com.loohp.limbo.utils.DataTypeIO; import com.loohp.limbo.utils.DataTypeIO;
import com.loohp.limbo.utils.NetworkEncryptionUtils; import com.loohp.limbo.utils.LastSeenMessages;
import com.loohp.limbo.utils.NetworkEncryptionUtils.SignatureData; import com.loohp.limbo.utils.MessageSignature;
public class PacketPlayInChat extends PacketIn { public class PacketPlayInChat extends PacketIn {
private String message; private String message;
private Instant time; private Instant time;
private NetworkEncryptionUtils.SignatureData signature; private long salt;
private boolean previewed; 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.message = message;
this.time = time; this.time = time;
this.salt = salt;
this.signature = signature; this.signature = signature;
this.previewed = previewed; this.signedPreview = signedPreview;
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()), 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() { public String getMessage() {
@ -54,12 +58,19 @@ public class PacketPlayInChat extends PacketIn {
return time; return time;
} }
public SignatureData getSignature() { public MessageSignature getSignature() {
return signature; return signature;
} }
public boolean isPreviewed() { public boolean isSignedPreview() {
return previewed; return signedPreview;
} }
public long getSalt() {
return salt;
}
public LastSeenMessages.b getLastSeenMessages() {
return lastSeenMessages;
}
} }

View File

@ -19,45 +19,40 @@
package com.loohp.limbo.network.protocol.packets; package com.loohp.limbo.network.protocol.packets;
import com.loohp.limbo.utils.ArgumentSignatures;
import com.loohp.limbo.utils.DataTypeIO; 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.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Instant; import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
public class ServerboundChatCommandPacket extends PacketIn { public class ServerboundChatCommandPacket extends PacketIn {
private String command; private String command;
private Instant time; private Instant time;
private long salt;
private ArgumentSignatures argumentSignatures; private ArgumentSignatures argumentSignatures;
private boolean commandPreview; 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.command = command;
this.time = time; this.time = time;
this.salt = salt;
this.argumentSignatures = argumentSignatures; this.argumentSignatures = argumentSignatures;
this.commandPreview = commandPreview; this.commandPreview = commandPreview;
this.lastSeenMessages = lastSeenMessages;
} }
public ServerboundChatCommandPacket(DataInputStream in) throws IOException { public ServerboundChatCommandPacket(DataInputStream in) throws IOException {
this.command = DataTypeIO.readString(in, StandardCharsets.UTF_8); this.command = DataTypeIO.readString(in, StandardCharsets.UTF_8);
this.time = Instant.ofEpochMilli(in.readLong()); this.time = Instant.ofEpochMilli(in.readLong());
long salt = in.readLong(); this.salt = in.readLong();
int size = DataTypeIO.readVarInt(in); this.argumentSignatures = new ArgumentSignatures(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.commandPreview = in.readBoolean(); this.commandPreview = in.readBoolean();
this.lastSeenMessages = new LastSeenMessages.b(in);
} }
public String getCommand() { public String getCommand() {
@ -68,6 +63,10 @@ public class ServerboundChatCommandPacket extends PacketIn {
return time; return time;
} }
public long getSalt() {
return salt;
}
public ArgumentSignatures getArgumentSignatures() { public ArgumentSignatures getArgumentSignatures() {
return argumentSignatures; return argumentSignatures;
} }
@ -76,4 +75,7 @@ public class ServerboundChatCommandPacket extends PacketIn {
return commandPreview; return commandPreview;
} }
public LastSeenMessages.b getLastSeenMessages() {
return lastSeenMessages;
}
} }

View File

@ -44,8 +44,8 @@ import com.loohp.limbo.network.protocol.packets.PacketPlayOutResourcePackSend;
import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn; import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn;
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils; import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
import com.loohp.limbo.utils.GameMode; import com.loohp.limbo.utils.GameMode;
import com.loohp.limbo.utils.MessageSignature;
import com.loohp.limbo.utils.NamespacedKey; import com.loohp.limbo.utils.NamespacedKey;
import com.loohp.limbo.utils.NetworkEncryptionUtils;
import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.identity.Identity; import net.kyori.adventure.identity.Identity;
@ -304,7 +304,7 @@ public class Player extends LivingEntity implements CommandSender {
chat(message, verbose, null, Instant.now()); chat(message, verbose, null, Instant.now());
} }
public void chat(String message, boolean verbose, NetworkEncryptionUtils.SignatureData saltSignature, Instant time) { public void chat(String message, boolean verbose, MessageSignature saltSignature, Instant time) {
if (Limbo.getInstance().getServerProperties().isAllowChat()) { if (Limbo.getInstance().getServerProperties().isAllowChat()) {
PlayerChatEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false)); PlayerChatEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false));
if (!event.isCancelled()) { if (!event.isCancelled()) {
@ -393,7 +393,7 @@ public class Player extends LivingEntity implements CommandSender {
} }
public void setTitleTimer(int fadeIn, int stay, int fadeOut) { public void setTitleTimer(int fadeIn, int stay, int fadeOut) {
sendTitlePart(TitlePart.TIMES, Title.Times.of(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50))); sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
} }
@Deprecated @Deprecated
@ -409,7 +409,7 @@ public class Player extends LivingEntity implements CommandSender {
} }
public void setTitleSubTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut) { public void setTitleSubTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut) {
sendTitlePart(TitlePart.TIMES, Title.Times.of(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50))); sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)));
sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle)); sendTitlePart(TitlePart.SUBTITLE, LegacyComponentSerializer.legacySection().deserialize(subTitle));
sendTitlePart(TitlePart.TITLE, LegacyComponentSerializer.legacySection().deserialize(title)); sendTitlePart(TitlePart.TITLE, LegacyComponentSerializer.legacySection().deserialize(title));
} }
@ -419,7 +419,7 @@ public class Player extends LivingEntity implements CommandSender {
sendMessage(source, message, type, null, Instant.now()); sendMessage(source, message, type, null, Instant.now());
} }
public void sendMessage(Identity source, Component message, MessageType type, NetworkEncryptionUtils.SignatureData signature, Instant time) { public void sendMessage(Identity source, Component message, MessageType type, MessageSignature signature, Instant time) {
try { try {
PacketOut chat; PacketOut chat;
switch (type) { switch (type) {
@ -434,7 +434,7 @@ public class Player extends LivingEntity implements CommandSender {
*/ */
case SYSTEM: case SYSTEM:
default: default:
chat = new ClientboundSystemChatPacket(message, 1); chat = new ClientboundSystemChatPacket(message, false);
break; break;
} }
clientConnection.sendPacket(chat); clientConnection.sendPacket(chat);
@ -469,7 +469,7 @@ public class Player extends LivingEntity implements CommandSender {
@Override @Override
public void sendActionBar(Component message) { public void sendActionBar(Component message) {
try { try {
ClientboundSystemChatPacket chat = new ClientboundSystemChatPacket(message, 2); ClientboundSystemChatPacket chat = new ClientboundSystemChatPacket(message, true);
clientConnection.sendPacket(chat); clientConnection.sendPacket(chat);
} catch (IOException ignored) {} } catch (IOException ignored) {}
} }

View File

@ -0,0 +1,112 @@
/*
* 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.utils;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class ArgumentSignatures {
public static final ArgumentSignatures EMPTY = new ArgumentSignatures(Collections.emptyList());
private static final int MAX_ARGUMENT_COUNT = 8;
private static final int MAX_ARGUMENT_NAME_LENGTH = 16;
private List<a> entries;
public ArgumentSignatures(List<a> entries) {
this.entries = entries;
}
public ArgumentSignatures(DataInputStream in) throws IOException {
int size = DataTypeIO.readVarInt(in);
entries = new ArrayList<>(8);
for (int i = 0; i < size; i++) {
entries.add(new ArgumentSignatures.a(in));
}
}
public List<a> getEntries() {
return entries;
}
public MessageSignature get(String s) {
Iterator<ArgumentSignatures.a> iterator = this.entries.iterator();
ArgumentSignatures.a argumentsignatures_a;
do {
if (!iterator.hasNext()) {
return MessageSignature.EMPTY;
}
argumentsignatures_a = iterator.next();
} while (!argumentsignatures_a.name.equals(s));
return argumentsignatures_a.signature;
}
public void write(DataOutputStream out) throws IOException {
DataTypeIO.writeVarInt(out, entries.size());
for (ArgumentSignatures.a argumentsignatures_a : entries) {
argumentsignatures_a.write(out);
}
}
public static class a {
private String name;
private MessageSignature signature;
public a(String name, MessageSignature signature) {
this.name = name;
this.signature = signature;
}
public String getName() {
return name;
}
public MessageSignature getSignature() {
return signature;
}
public a(DataInputStream in) throws IOException {
this(DataTypeIO.readString(in, StandardCharsets.UTF_8), new MessageSignature(in));
}
public void write(DataOutputStream out) throws IOException {
DataTypeIO.writeString(out, name, StandardCharsets.UTF_8);
this.signature.write(out);
}
}
@FunctionalInterface
public interface b {
MessageSignature sign(String s, String s1);
}
}

View File

@ -0,0 +1,140 @@
/*
* 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.utils;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
public class LastSeenMessages {
public static LastSeenMessages EMPTY = new LastSeenMessages(Collections.emptyList());
public static final int LAST_SEEN_MESSAGES_MAX_LENGTH = 5;
private List<a> entries;
public LastSeenMessages(List<LastSeenMessages.a> entries) {
this.entries = entries;
}
public LastSeenMessages(DataInputStream in) throws IOException {
int size = DataTypeIO.readVarInt(in);
entries = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
entries.add(new LastSeenMessages.a(in));
}
}
public void write(DataOutputStream out) throws IOException {
DataTypeIO.writeVarInt(out, entries.size());
for (LastSeenMessages.a lastseenmessages_a : entries) {
lastseenmessages_a.write(out);
}
}
public void updateHash(DataOutputStream dataoutput) throws IOException {
Iterator<a> iterator = this.entries.iterator();
while (iterator.hasNext()) {
LastSeenMessages.a lastseenmessages_a = iterator.next();
UUID uuid = lastseenmessages_a.getProfileId();
MessageSignature messagesignature = lastseenmessages_a.getLastSignature();
dataoutput.writeByte(70);
dataoutput.writeLong(uuid.getMostSignificantBits());
dataoutput.writeLong(uuid.getLeastSignificantBits());
dataoutput.write(messagesignature.getBytes());
}
}
public static class a {
private UUID profileId;
private MessageSignature lastSignature;
public UUID getProfileId() {
return profileId;
}
public MessageSignature getLastSignature() {
return lastSignature;
}
public a(UUID profileId, MessageSignature lastSignature) {
this.profileId = profileId;
this.lastSignature = lastSignature;
}
public a(DataInputStream in) throws IOException {
this(DataTypeIO.readUUID(in), new MessageSignature(in));
}
public void write(DataOutputStream out) throws IOException {
DataTypeIO.writeUUID(out, this.profileId);
this.lastSignature.write(out);
}
}
public static class b {
private LastSeenMessages lastSeen;
private Optional<a> lastReceived;
public b(LastSeenMessages lastSeen, Optional<LastSeenMessages.a> lastReceived) {
this.lastSeen = lastSeen;
this.lastReceived = lastReceived;
}
public b(DataInputStream in) throws IOException {
this.lastSeen = new LastSeenMessages(in);
if (in.readBoolean()) {
this.lastReceived = Optional.of(new LastSeenMessages.a(in));
} else {
this.lastReceived = Optional.empty();
}
}
public void write(DataOutputStream out) throws IOException {
this.lastSeen.write(out);
if (lastReceived.isPresent()) {
out.writeBoolean(true);
lastReceived.get().write(out);
} else {
out.writeBoolean(false);
}
}
public LastSeenMessages getLastSeen() {
return lastSeen;
}
public Optional<a> getLastReceived() {
return lastReceived;
}
}
}

View File

@ -0,0 +1,92 @@
/*
* 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.utils;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Base64;
public class MessageSignature {
public static final MessageSignature EMPTY = new MessageSignature(new byte[0]);
private byte[] bytes;
public MessageSignature(byte[] bytes) {
this.bytes = bytes;
}
public byte[] getBytes() {
return bytes;
}
public MessageSignature(DataInputStream in) throws IOException {
this.bytes = new byte[DataTypeIO.readVarInt(in)];
in.readFully(bytes);
}
public void write(DataOutputStream out) throws IOException {
out.write(this.bytes.length);
out.write(this.bytes);
}
public boolean isEmpty() {
return this.bytes.length == 0;
}
public ByteBuffer asByteBuffer() {
return !this.isEmpty() ? ByteBuffer.wrap(this.bytes) : null;
}
public boolean equals(Object object) {
boolean flag;
if (this != object) {
label22:
{
if (object instanceof MessageSignature) {
MessageSignature messagesignature = (MessageSignature) object;
if (Arrays.equals(this.bytes, messagesignature.bytes)) {
break label22;
}
}
flag = false;
return flag;
}
}
flag = true;
return flag;
}
public int hashCode() {
return Arrays.hashCode(this.bytes);
}
public String toString() {
return !this.isEmpty() ? Base64.getEncoder().encodeToString(this.bytes) : "empty";
}
}

View File

@ -1,84 +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.utils;
import com.google.common.primitives.Longs;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Map;
public class NetworkEncryptionUtils {
public static class SignatureData {
public static final SignatureData NONE = new SignatureData(0L, new byte[0]);
private long salt;
private byte[] signature;
public SignatureData(long salt, byte[] signature) {
this.salt = salt;
this.signature = signature;
}
public SignatureData(DataInputStream in) throws IOException {
this.salt = in.readLong();
int length = DataTypeIO.readVarInt(in);
this.signature = new byte[length];
in.readFully(this.signature);
}
public boolean isSignaturePresent() {
return this.signature.length > 0;
}
public static void write(DataOutputStream out, SignatureData signatureData) throws IOException {
out.writeLong(signatureData.salt);
DataTypeIO.writeVarInt(out, signatureData.signature.length);
out.write(signatureData.signature);
}
public byte[] getSalt() {
return Longs.toByteArray(this.salt);
}
}
public static class ArgumentSignatures {
private long salt;
private Map<String, byte[]> signatures;
public ArgumentSignatures(long salt, Map<String, byte[]> signatures) {
this.salt = salt;
this.signatures = signatures;
}
public long getSalt() {
return salt;
}
public Map<String, byte[]> getSignatures() {
return signatures;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -12,44 +12,43 @@
"PacketLoginOutPluginMessaging": "0x04" "PacketLoginOutPluginMessaging": "0x04"
}, },
"PlayIn": { "PlayIn": {
"0x11": "PacketPlayInKeepAlive", "0x12": "PacketPlayInKeepAlive",
"0x03": "ServerboundChatCommandPacket", "0x04": "ServerboundChatCommandPacket",
"0x04": "PacketPlayInChat", "0x05": "PacketPlayInChat",
"0x14": "PacketPlayInPositionAndLook", "0x15": "PacketPlayInPositionAndLook",
"0x13": "PacketPlayInPosition", "0x14": "PacketPlayInPosition",
"0x15": "PacketPlayInRotation", "0x16": "PacketPlayInRotation",
"0x0C": "PacketPlayInPluginMessaging", "0x0D": "PacketPlayInPluginMessaging",
"0x08": "PacketPlayInTabComplete", "0x09": "PacketPlayInTabComplete",
"0x27": "PacketPlayInHeldItemChange", "0x28": "PacketPlayInHeldItemChange",
"0x23": "PacketPlayInResourcePackStatus" "0x24": "PacketPlayInResourcePackStatus"
}, },
"PlayOut": { "PlayOut": {
"PacketPlayOutLogin": "0x23", "PacketPlayOutLogin": "0x25",
"PacketPlayOutPositionAndLook": "0x36", "PacketPlayOutPositionAndLook": "0x39",
"PacketPlayOutSpawnPosition": "0x4A", "PacketPlayOutSpawnPosition": "0x4D",
"ClientboundPlayerChatPacket": "0x30", "ClientboundSystemChatPacket": "0x62",
"ClientboundSystemChatPacket": "0x5F", "PacketPlayOutPlayerAbilities": "0x31",
"PacketPlayOutPlayerAbilities": "0x2F", "ClientboundLevelChunkWithLightPacket": "0x21",
"ClientboundLevelChunkWithLightPacket": "0x1F", "PacketPlayOutUnloadChunk": "0x1C",
"PacketPlayOutUnloadChunk": "0x1A", "PacketPlayOutKeepAlive": "0x20",
"PacketPlayOutKeepAlive": "0x1E", "PacketPlayOutPlayerInfo": "0x37",
"PacketPlayOutPlayerInfo": "0x34", "PacketPlayOutUpdateViewPosition": "0x4B",
"PacketPlayOutUpdateViewPosition": "0x48", "PacketPlayOutDisconnect": "0x19",
"PacketPlayOutDisconnect": "0x17", "PacketPlayOutPluginMessaging": "0x16",
"PacketPlayOutPluginMessaging": "0x15",
"PacketPlayOutTabComplete": "0x0E", "PacketPlayOutTabComplete": "0x0E",
"PacketPlayOutDeclareCommands": "0x0F", "PacketPlayOutDeclareCommands": "0x0F",
"PacketPlayOutRespawn": "0x3B", "PacketPlayOutRespawn": "0x3E",
"PacketPlayOutGameState": "0x1B", "PacketPlayOutGameState": "0x1D",
"PacketPlayOutEntityDestroy": "0x38", "PacketPlayOutEntityDestroy": "0x3B",
"PacketPlayOutEntityMetadata": "0x4D", "PacketPlayOutEntityMetadata": "0x50",
"PacketPlayOutSpawnEntity": "0x00", "PacketPlayOutSpawnEntity": "0x00",
"PacketPlayOutHeldItemChange": "0x47", "PacketPlayOutHeldItemChange": "0x4A",
"PacketPlayOutPlayerListHeaderFooter": "0x60", "PacketPlayOutPlayerListHeaderFooter": "0x63",
"PacketPlayOutResourcePackSend": "0x3A", "PacketPlayOutResourcePackSend": "0x3D",
"ClientboundSetTitlesAnimationPacket": "0x5B", "ClientboundSetTitlesAnimationPacket": "0x5E",
"ClientboundSetTitleTextPacket": "0x5A", "ClientboundSetTitleTextPacket": "0x5D",
"ClientboundSetSubtitleTextPacket": "0x58", "ClientboundSetSubtitleTextPacket": "0x5B",
"ClientboundClearTitlesPacket": "0x0D" "ClientboundClearTitlesPacket": "0x0D"
}, },
"StatusIn": { "StatusIn": {

View File

@ -4302,47 +4302,53 @@
"minecraft:item_interact_start": { "minecraft:item_interact_start": {
"protocol_id": 29 "protocol_id": 29
}, },
"minecraft:lightning_strike": { "minecraft:jukebox_play": {
"protocol_id": 30 "protocol_id": 30
}, },
"minecraft:note_block_play": { "minecraft:jukebox_stop_play": {
"protocol_id": 31 "protocol_id": 31
}, },
"minecraft:piston_contract": { "minecraft:lightning_strike": {
"protocol_id": 32 "protocol_id": 32
}, },
"minecraft:piston_extend": { "minecraft:note_block_play": {
"protocol_id": 33 "protocol_id": 33
}, },
"minecraft:prime_fuse": { "minecraft:piston_contract": {
"protocol_id": 34 "protocol_id": 34
}, },
"minecraft:projectile_land": { "minecraft:piston_extend": {
"protocol_id": 35 "protocol_id": 35
}, },
"minecraft:projectile_shoot": { "minecraft:prime_fuse": {
"protocol_id": 36 "protocol_id": 36
}, },
"minecraft:sculk_sensor_tendrils_clicking": { "minecraft:projectile_land": {
"protocol_id": 37 "protocol_id": 37
}, },
"minecraft:shear": { "minecraft:projectile_shoot": {
"protocol_id": 38 "protocol_id": 38
}, },
"minecraft:shriek": { "minecraft:sculk_sensor_tendrils_clicking": {
"protocol_id": 39 "protocol_id": 39
}, },
"minecraft:splash": { "minecraft:shear": {
"protocol_id": 40 "protocol_id": 40
}, },
"minecraft:step": { "minecraft:shriek": {
"protocol_id": 41 "protocol_id": 41
}, },
"minecraft:swim": { "minecraft:splash": {
"protocol_id": 42 "protocol_id": 42
}, },
"minecraft:teleport": { "minecraft:step": {
"protocol_id": 43 "protocol_id": 43
},
"minecraft:swim": {
"protocol_id": 44
},
"minecraft:teleport": {
"protocol_id": 45
} }
}, },
"protocol_id": 0 "protocol_id": 0