Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement workaround for out of order StartGame packet #714

Closed
wants to merge 64 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2dc755c
Rename Geyser-Bukkit to Geyser-Spigot
Camotoy May 26, 2020
af669f2
Rename internal ping passthrough variable
Camotoy May 26, 2020
cae888e
Include PlatformType.java
Camotoy May 26, 2020
ccf9eff
Update workflow
Camotoy May 26, 2020
88129b1
Implement workaround for out of order StartGame packet
bundabrg Jun 1, 2020
86094c3
Update to use Thread Pool
Jun 2, 2020
cc3b4c3
Merge latest master; copy over old Geyser-Bukkit configs
Camotoy Jun 11, 2020
d611937
(Incomplete) Update MCProtocolLib
Camotoy Jun 19, 2020
ad4c1ff
Update Message system
rtm516 Jun 19, 2020
65f61ec
Finish block state changes
Camotoy Jun 19, 2020
5327610
Don't forget about Bukkit
Camotoy Jun 19, 2020
47cadc7
Fix json data in chat
rtm516 Jun 19, 2020
8c5f582
Merge branch 'mcprotocollibupdate' of https://github.com/DoctorMacc/G…
rtm516 Jun 19, 2020
1015b83
Merge branch 'master' of https://github.com/GeyserMC/Geyser into mcpr…
Camotoy Jun 20, 2020
dbe1755
Update mappings repository
Camotoy Jun 20, 2020
77873b6
Update ViaVersion integration
Camotoy Jun 21, 2020
117cdf2
Begin updating Geyser. Requires manual MCProtocolLib compile
Camotoy Jun 21, 2020
b9ccabb
According to all known laws of aviation, bees exist
Camotoy Jun 21, 2020
427f4ef
Merge master into Spigot rename
Camotoy Jun 21, 2020
63244ad
Rename Geyser-Bukkit to Geyser-Spigot
Camotoy Jun 21, 2020
56f9330
Remove ServerSpawnWeatherEntityPacket
Camotoy Jun 21, 2020
ea1a9e5
Bedrock 1.16 updating part 1
Camotoy Jun 23, 2020
0471fa8
Bedrock 1.16 updating part 2 (Doesn't work)
Camotoy Jun 23, 2020
3ea1059
Update for 1.16
Camotoy Jun 23, 2020
ca7484a
Relocate Reflections Dependency (#802)
williamjohnstone Jun 23, 2020
78df56c
Update for 1.16.1
Camotoy Jun 24, 2020
2b874b4
Merge branch 'feature/1.16' of https://github.com/GeyserMC/Geyser int…
Camotoy Jun 24, 2020
b34dc05
Uncomment JavaDeclareCommandsTranslator and update
Camotoy Jun 24, 2020
60fa43c
Update Bedrock resources dumped by @bundabrg
Camotoy Jun 24, 2020
8be0c4b
Update some entity properties based on wiki.vg
Camotoy Jun 24, 2020
1490d6d
Update ViaVersion dependency
Camotoy Jun 24, 2020
1572ac2
Update mappings repository
Camotoy Jun 24, 2020
f0aaebc
Bump block state version
AJ-Ferguson Jun 24, 2020
a964bef
Merge branch 'feature/1.16' of https://github.com/GeyserMC/Geyser int…
Camotoy Jun 24, 2020
e4d9903
Bump action versions (#810)
basaigh Jun 24, 2020
71aada1
Fix dimension switching; add static references to new Java dimensions
Camotoy Jun 25, 2020
bd16925
Update mappings repository
Camotoy Jun 25, 2020
06fa0de
Add translator for PacketViolationWarningPacket
Camotoy Jun 25, 2020
bb630dc
Update PotionMixData
Camotoy Jun 25, 2020
6f2bf65
Update JavaEntityEquipmentTranslator for Java 1.16
Camotoy Jun 26, 2020
409293f
Add new 1.16 entities
Camotoy Jun 26, 2020
e60f47f
Fix zombified piglins
Camotoy Jun 26, 2020
54f6fad
Remove try/catch from BlockTranslator and ItemTranslator
Camotoy Jun 26, 2020
17a1e82
Add closest color mapping for RGB chat colors
rtm516 Jun 26, 2020
ba91291
Quick inventory fixes. WIP
AJ-Ferguson Jun 27, 2020
d516dc5
Update Mappings (#816)
williamjohnstone Jun 27, 2020
5b147f8
Fix en_us locale downloading (#809)
rtm516 Jun 27, 2020
75f470c
Fix creative items
Camotoy Jun 27, 2020
7743f6d
Add dump command (#808)
rtm516 Jun 27, 2020
3cd85ed
Update README.md (#811)
toinouH Jun 27, 2020
dd1747c
Updated the mappings and fixed building
Tim203 Jun 27, 2020
8f763df
Move common stuff used only by connector and bootstrap to connector
Tim203 Jun 27, 2020
2e0eb6d
Fix creative item list
AJ-Ferguson Jun 27, 2020
e3e8bb2
Fix first item of creative inventory not showing
AJ-Ferguson Jun 28, 2020
6e94428
Non-working smithing table inventory support
Jun 28, 2020
1410b67
Update mappings submodule
AJ-Ferguson Jun 28, 2020
9569416
Fix chat formatting and team colors
rtm516 Jun 28, 2020
2df3d4c
Update to the latest MCProtocolLib commit
Tim203 Jun 28, 2020
980e82a
Replace Bukkit with Spigot (#831)
basaigh Jun 28, 2020
8e8bc28
Return if sound is null and update mappings
Redned235 Jun 28, 2020
c2c64fd
Fix some recipes with multiple ingredient options
AJ-Ferguson Jun 28, 2020
f5da962
Fix disconnect message formatting
rtm516 Jun 28, 2020
12d5982
Anvil fixes
AJ-Ferguson Jun 29, 2020
935ad17
Merge branch 'feature/1.16' into fix/first-login-issue-1.16
bundabrg Jun 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Message system
rtm516 committed Jun 19, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit ad4c1ff0c730ce7563d1a1c3f5f179c4967c464e
Original file line number Diff line number Diff line change
@@ -25,15 +25,17 @@

package org.geysermc.connector.network;

import com.github.steveice10.mc.protocol.data.message.Message;
import com.nukkitx.protocol.bedrock.*;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.nukkitx.protocol.bedrock.BedrockPong;
import com.nukkitx.protocol.bedrock.BedrockServerEventHandler;
import com.nukkitx.protocol.bedrock.BedrockServerSession;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.socket.DatagramPacket;
import org.geysermc.common.ping.GeyserPingInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import org.geysermc.connector.configuration.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.configuration.GeyserConfiguration;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import org.geysermc.connector.utils.MessageUtils;

import java.net.InetSocketAddress;
@@ -73,7 +75,7 @@ public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
pong.setIpv4Port(config.getBedrock().getPort());

if (config.isPassthroughMotd() && pingInfo != null && pingInfo.motd != null) {
String[] motd = MessageUtils.getBedrockMessage(Message.fromString(pingInfo.motd)).split("\n");
String[] motd = MessageUtils.getBedrockMessage(MessageSerializer.fromString(pingInfo.motd)).split("\n");
String mainMotd = motd[0]; // First line of the motd.
String subMotd = (motd.length != 1) ? motd[1] : ""; // Second line of the motd if present, otherwise blank.

Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@

package org.geysermc.connector.network;

import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import org.geysermc.common.ping.GeyserPingInfo;
@@ -148,7 +148,7 @@ private byte[] getGameData() {
}

if (connector.getConfig().isPassthroughMotd() && pingInfo != null) {
String[] javaMotd = MessageUtils.getBedrockMessage(Message.fromString(pingInfo.motd)).split("\n");
String[] javaMotd = MessageUtils.getBedrockMessage(MessageSerializer.fromString(pingInfo.motd)).split("\n");
motd = javaMotd[0].trim(); // First line of the motd.
} else {
motd = connector.getConfig().getBedrock().getMotd1();
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@

import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.protocol.bedrock.data.ContainerId;
@@ -129,8 +130,8 @@ public void updateSlot(GeyserSession session, Inventory inventory, int slot) {
CompoundTag displayTag = tag.get("display");
if (displayTag != null) {
String itemName = displayTag.get("Name").getValue().toString();
Message message = Message.fromString(itemName);
rename = message.getText();
Message message = MessageSerializer.fromString(itemName);
rename = message.toString();
} else {
rename = "";
}
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
package org.geysermc.connector.network.translators.item;

import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.CompoundTag;
@@ -159,7 +159,7 @@ public static ItemData translateToBedrock(GeyserSession session, ItemStack stack
// Check if its a message to translate
if (MessageUtils.isMessage(name)) {
// Get the translated name
name = MessageUtils.getTranslatedBedrockMessage(Message.fromString(name), session.getClientData().getLanguageCode());
name = MessageUtils.getTranslatedBedrockMessage(MessageSerializer.fromString(name), session.getClientData().getLanguageCode());

// Build the new display tag
CompoundTagBuilder displayBuilder = display.toBuilder();
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ public void translate(ServerChatPacket packet, GeyserSession session) {
textPacket.setType(TextPacket.Type.TRANSLATION);
textPacket.setNeedsTranslation(true);

List<String> paramsTranslated = MessageUtils.getTranslationParams(((TranslationMessage) packet.getMessage()).getTranslationParams(), locale);
List<String> paramsTranslated = MessageUtils.getTranslationParams(((TranslationMessage) packet.getMessage()).getWith(), locale);
textPacket.setParameters(paramsTranslated);

textPacket.setMessage(MessageUtils.insertParams(MessageUtils.getTranslatedBedrockMessage(packet.getMessage(), locale, true), paramsTranslated));
Original file line number Diff line number Diff line change
@@ -25,12 +25,11 @@

package org.geysermc.connector.network.translators.world.block.entity;

import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.StringTag;
import com.nukkitx.nbt.tag.Tag;
import io.netty.util.internal.StringUtil;
import org.geysermc.connector.utils.MessageUtils;

import java.util.ArrayList;
@@ -47,7 +46,7 @@ public List<Tag<?>> translateTag(CompoundTag tag, int blockState) {
for(int i = 0; i < 4; i++) {
int currentLine = i+1;
String signLine = getOrDefault(tag.getValue().get("Text" + currentLine), "");
signLine = MessageUtils.getBedrockMessage(Message.fromString(signLine));
signLine = MessageUtils.getBedrockMessage(MessageSerializer.fromString(signLine));

//Java allows up to 16+ characters on certain symbols.
if(signLine.length() >= 15 && (signLine.contains("-") || signLine.contains("="))) {
@@ -58,7 +57,7 @@ public List<Tag<?>> translateTag(CompoundTag tag, int blockState) {
signText.append("\n");
}

tags.add(new StringTag("Text", MessageUtils.getBedrockMessage(Message.fromString(signText.toString()))));
tags.add(new StringTag("Text", MessageUtils.getBedrockMessage(MessageSerializer.fromString(signText.toString()))));
return tags;
}

Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ public void run() {
try {
this.client = new Client(connector.getConfig().getRemote().getAddress(), connector.getConfig().getRemote().getPort(), new MinecraftProtocol(SubProtocol.STATUS), new TcpSessionFactory());
this.client.getSession().setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY, (ServerInfoHandler) (session, info) -> {
this.pingInfo = new GeyserPingInfo(info.getDescription().getFullText(), info.getPlayerInfo().getOnlinePlayers(), info.getPlayerInfo().getMaxPlayers());
this.pingInfo = new GeyserPingInfo(info.getDescription().toString(), info.getPlayerInfo().getOnlinePlayers(), info.getPlayerInfo().getMaxPlayers());
this.client.getSession().disconnect(null);
});

Original file line number Diff line number Diff line change
@@ -26,7 +26,12 @@
package org.geysermc.connector.utils;

import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
import com.github.steveice10.mc.protocol.data.message.*;
import com.github.steveice10.mc.protocol.data.message.Message;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
import com.github.steveice10.mc.protocol.data.message.style.ChatColor;
import com.github.steveice10.mc.protocol.data.message.style.ChatFormat;
import com.github.steveice10.mc.protocol.data.message.style.MessageStyle;
import com.google.gson.*;
import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer;
@@ -41,28 +46,28 @@

public class MessageUtils {

public static List<String> getTranslationParams(Message[] messages, String locale) {
public static List<String> getTranslationParams(List<Message> messages, String locale) {
List<String> strings = new ArrayList<>();
for (Message message : messages) {
if (message instanceof TranslationMessage) {
TranslationMessage translation = (TranslationMessage) message;

if (locale == null) {
String builder = "%" + translation.getTranslationKey();
String builder = "%" + translation.getKey();
strings.add(builder);
}

if (translation.getTranslationKey().equals("commands.gamemode.success.other")) {
if (translation.getKey().equals("commands.gamemode.success.other")) {
strings.add("");
}

if (translation.getTranslationKey().equals("command.context.here")) {
if (translation.getKey().equals("command.context.here")) {
strings.add(" - no permission or invalid command!");
}

List<String> furtherParams = getTranslationParams(translation.getTranslationParams(), locale);
List<String> furtherParams = getTranslationParams(translation.getWith(), locale);
if (locale != null) {
strings.add(insertParams(LocaleUtils.getLocaleString(translation.getTranslationKey(), locale), furtherParams));
strings.add(insertParams(LocaleUtils.getLocaleString(translation.getKey(), locale), furtherParams));
} else {
strings.addAll(furtherParams);
}
@@ -77,23 +82,23 @@ public static List<String> getTranslationParams(Message[] messages, String local
return strings;
}

public static List<String> getTranslationParams(Message[] messages) {
public static List<String> getTranslationParams(List<Message> messages) {
return getTranslationParams(messages, null);
}

public static String getTranslationText(TranslationMessage message) {
return getFormat(message.getStyle().getFormats()) + getColorOrParent(message.getStyle())
+ "%" + message.getTranslationKey();
+ "%" + message.getKey();
}

public static String getTranslatedBedrockMessage(Message message, String locale, boolean shouldTranslate) {
JsonParser parser = new JsonParser();
if (isMessage(message.getText())) {
JsonObject object = parser.parse(message.getText()).getAsJsonObject();
message = Message.fromJson(formatJson(object));
if (isMessage(message.toString())) {
JsonObject object = parser.parse(message.toString()).getAsJsonObject();
message = MessageSerializer.fromJson(formatJson(object));
}

String messageText = message.getText();
String messageText = message.toString();
if (locale != null && shouldTranslate) {
messageText = LocaleUtils.getLocaleString(messageText, locale);
}
@@ -106,12 +111,12 @@ public static String getTranslatedBedrockMessage(Message message, String locale,
for (Message msg : message.getExtra()) {
builder.append(getFormat(msg.getStyle().getFormats()));
builder.append(getColorOrParent(msg.getStyle()));
if (!(msg.getText() == null)) {
if (!(msg.toString() == null)) {
boolean isTranslationMessage = (msg instanceof TranslationMessage);
String extraText = "";

if (isTranslationMessage) {
List<String> paramsTranslated = getTranslationParams(((TranslationMessage) msg).getTranslationParams(), locale);
List<String> paramsTranslated = getTranslationParams(((TranslationMessage) msg).getWith(), locale);
extraText = insertParams(getTranslatedBedrockMessage(msg, locale, isTranslationMessage), paramsTranslated);
} else {
extraText = getTranslatedBedrockMessage(msg, locale, isTranslationMessage);
@@ -130,10 +135,10 @@ public static String getTranslatedBedrockMessage(Message message, String locale)
}

public static String getBedrockMessage(Message message) {
if (isMessage(message.getText())) {
return getBedrockMessage(message.getText());
if (isMessage(message.toString())) {
return getBedrockMessage(message.toString());
} else {
return getBedrockMessage(message.toJsonString());
return getBedrockMessage(MessageSerializer.toJsonString(message));
}
}

@@ -206,9 +211,9 @@ public static String insertParams(String message, List<String> params) {
private static String getColorOrParent(MessageStyle style) {
ChatColor chatColor = style.getColor();

if (chatColor == ChatColor.NONE && style.getParent() != null) {
/*if (chatColor == ChatColor.NONE && style.getParent() != null) {
return getColorOrParent(style.getParent());
}
}*/

return getColor(chatColor);
}
@@ -328,7 +333,7 @@ public static boolean isMessage(String text) {
try {
JsonObject object = parser.parse(text).getAsJsonObject();
try {
Message.fromJson(formatJson(object));
MessageSerializer.fromJson(formatJson(object));
} catch (Exception ex) {
return false;
}