Skip to content

Commit

Permalink
Minecraft 1.19.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Jul 28, 2022
1 parent 42559d8 commit ace420a
Show file tree
Hide file tree
Showing 15 changed files with 1,512 additions and 1,343 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<groupId>com.loohp</groupId>
<artifactId>Limbo</artifactId>
<name>Limbo</name>
<version>0.6.16-ALPHA</version>
<version>0.6.17-ALPHA</version>

<description>Standalone Limbo Minecraft Server.</description>
<url>https://github.com/LOOHP/Limbo</url>
Expand Down Expand Up @@ -136,7 +136,7 @@
</executions>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}-1.19</finalName>
<finalName>${project.artifactId}-${project.version}-1.19.1</finalName>
</build>

<profiles>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/loohp/limbo/Limbo.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public static Limbo getInstance() {

//===========================

public final String SERVER_IMPLEMENTATION_VERSION = "1.19";
public final int SERVER_IMPLEMENTATION_PROTOCOL = 759;
public final String SERVER_IMPLEMENTATION_VERSION = "1.19.1";
public final int SERVER_IMPLEMENTATION_PROTOCOL = 760;
public final String LIMBO_IMPLEMENTATION_VERSION;

private AtomicBoolean isRunning;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public void run() {
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();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@
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();

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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,29 @@
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() {
Expand All @@ -54,12 +58,19 @@ public Instant getTime() {
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -68,6 +63,10 @@ public Instant getTime() {
return time;
}

public long getSalt() {
return salt;
}

public ArgumentSignatures getArgumentSignatures() {
return argumentSignatures;
}
Expand All @@ -76,4 +75,7 @@ public boolean isCommandPreview() {
return commandPreview;
}

public LastSeenMessages.b getLastSeenMessages() {
return lastSeenMessages;
}
}
14 changes: 7 additions & 7 deletions src/main/java/com/loohp/limbo/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import com.loohp.limbo.network.protocol.packets.PacketPlayOutRespawn;
import com.loohp.limbo.utils.BungeecordAdventureConversionUtils;
import com.loohp.limbo.utils.GameMode;
import com.loohp.limbo.utils.MessageSignature;
import com.loohp.limbo.utils.NamespacedKey;
import com.loohp.limbo.utils.NetworkEncryptionUtils;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.identity.Identity;
Expand Down Expand Up @@ -304,7 +304,7 @@ public void chat(String message, boolean verbose) {
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()) {
PlayerChatEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false));
if (!event.isCancelled()) {
Expand Down Expand Up @@ -393,7 +393,7 @@ public void setSubTitle(String subTitle) {
}

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
Expand All @@ -409,7 +409,7 @@ public void setTitleSubTitle(BaseComponent title, BaseComponent subTitle, int fa
}

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.TITLE, LegacyComponentSerializer.legacySection().deserialize(title));
}
Expand All @@ -419,7 +419,7 @@ public void sendMessage(Identity source, Component message, MessageType type) {
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 {
PacketOut chat;
switch (type) {
Expand All @@ -434,7 +434,7 @@ public void sendMessage(Identity source, Component message, MessageType type, Ne
*/
case SYSTEM:
default:
chat = new ClientboundSystemChatPacket(message, 1);
chat = new ClientboundSystemChatPacket(message, false);
break;
}
clientConnection.sendPacket(chat);
Expand Down Expand Up @@ -469,7 +469,7 @@ public void playSound(Sound sound) {
@Override
public void sendActionBar(Component message) {
try {
ClientboundSystemChatPacket chat = new ClientboundSystemChatPacket(message, 2);
ClientboundSystemChatPacket chat = new ClientboundSystemChatPacket(message, true);
clientConnection.sendPacket(chat);
} catch (IOException ignored) {}
}
Expand Down
Loading

0 comments on commit ace420a

Please sign in to comment.