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

h #2

Open
wants to merge 49 commits into
base: floodgate2.0+serverinventory
Choose a base branch
from
Open

h #2

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
23e5709
Add world border translation
Camotoy Jan 14, 2021
1d4ebe7
Fix world borders with mounted entities
Camotoy Jan 14, 2021
7b68bb7
Touchups and MCProtocolLib dependency change
Camotoy Jan 14, 2021
a25921c
Merge from Upstream
bundabrg Feb 2, 2021
c71c922
Merge pull request #311 from bundabrg/feature/plugins
Hellohi3654 Feb 5, 2021
de1a0ce
Merge branch 'pr/312' into new-geyser
Hellohi3654 Feb 5, 2021
5557ed1
Update mappings
Hellohi3654 Feb 5, 2021
d958fd6
Update .gitmodules
Hellohi3654 Feb 5, 2021
9e0ecd0
Merge branch 'pr/314' into new-geyser
Hellohi3654 Feb 5, 2021
2a26c65
Merge branch 'pr/313' into new-geyser
Hellohi3654 Feb 5, 2021
f8b68eb
fix
Hellohi3654 Feb 5, 2021
6511397
Update README.md
Hellohi3654 Feb 5, 2021
7d2d417
Workflows
Hellohi3654 Feb 5, 2021
cf62b74
Merge branch 'new-geyser' of https://github.com/Hellohi3654/Geyser in…
Hellohi3654 Feb 5, 2021
02fbba1
Update geyserbuildbranch.yml
Hellohi3654 Feb 5, 2021
92436f9
Update pom.xml
Hellohi3654 Feb 5, 2021
5e4a4a3
Merge branch 'master' into smoothpistons
davchoo Feb 7, 2021
66fcd87
Remove extra bracket from BOUYANCY_DATA (#1903)
bundabrg Feb 8, 2021
3140d3c
Allow Geyser to boot if it cannot download en_US file (#1907)
Camotoy Feb 8, 2021
1ec589f
Enable debug property in Log4J config if applicable (#1906)
Camotoy Feb 8, 2021
5bbeb4a
Merge branch 'master' into new-geyser
Hellohi3654 Feb 10, 2021
b16e1d6
Threading and ping improvements (#1870)
Camotoy Feb 10, 2021
25dd651
Update Adventure to 4.5.0 (#1920)
Feb 12, 2021
98b2a0e
Fix NPE with MOTD (#1921)
Camotoy Feb 12, 2021
a594904
Merge branch 'master' into new-geyser
Hellohi3654 Feb 14, 2021
f2550de
Ping/MOTD changes required for 1.16.210.59 (#1931)
Camotoy Feb 15, 2021
93a74d6
Skin and skull fixes (#1923)
Camotoy Feb 15, 2021
1f1d94a
Don't allow the sub-MOTD to be empty (#1933)
Camotoy Feb 16, 2021
e0bd5a6
Fix up some SpotBugs suggestions (#1911)
Camotoy Feb 16, 2021
62cbdb8
[ci skip] Fixed if spacing (#1941)
YHDiamond Feb 17, 2021
fc712ea
Fix NPE in ServerEntityAnimationPacket (#1942)
bundabrg Feb 17, 2021
15027c2
Fix NPE when a TitlePacket of type TIMES is sent (#1944)
bundabrg Feb 17, 2021
a2c12b7
Merge pull request #320 from GeyserMC/master
Hellohi3654 Feb 17, 2021
d9f8e9e
Improve command freezing and fix up command suggestion translation (#…
Camotoy Feb 17, 2021
9208943
Bump Network and Netty dependencies (#1775)
Camotoy Feb 17, 2021
c4573bb
HAProxy PROXY protocol support for upstream connections (#1713)
mikroskeem Feb 17, 2021
b782826
Projectile Movement (#1929)
davchoo Feb 19, 2021
a2a9398
Merge branch 'master' into new-geyser
Hellohi3654 Feb 19, 2021
3338edf
Update mappings
Hellohi3654 Feb 19, 2021
f891d39
Update mappings
Hellohi3654 Feb 19, 2021
fa5245e
Update languages
Hellohi3654 Feb 19, 2021
b2d3c38
Merge branch 'pr/326' into new-geyser
Hellohi3654 Feb 19, 2021
0492a10
Update README.md
Hellohi3654 Feb 20, 2021
f480fbf
More changes to allow Geyser to cooperate better with bad internet (#…
Camotoy Feb 21, 2021
58e2c7d
Use the new form issue templates (#1973)
Tim203 Feb 23, 2021
9f5a356
Armor stand fixes (#1270)
Camotoy Feb 25, 2021
325b8ab
Fix rowing from Java to Bedrock (#1943)
Camotoy Feb 25, 2021
ae3f50a
Firework star item translation (#1968)
Camotoy Feb 25, 2021
8f8029b
Merge pull request #332 from GeyserMC/master
Hellohi3654 Feb 27, 2021
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
Don't allow the sub-MOTD to be empty (GeyserMC#1933)
As of 1.16.210.59, the sub-MOTD cannot be blank: https://bugs.mojang.com/browse/MCPE-117979

This workaround will be implemented now so the widest range of Geyser versions will properly show a ping in 1.16.210 - better an 'outdated server' message than 'unable to connect to world.'
  • Loading branch information
Camotoy authored Feb 16, 2021
commit 1f1d94aa811cf9b35677a6783a035bf6be0b02d7
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
import java.nio.charset.StandardCharsets;

public class ConnectorServerEventHandler implements BedrockServerEventHandler {
/*
The following constants are all used to ensure the ping does not reach a length where it is unparsable by the Bedrock client
*/
private static final int MINECRAFT_VERSION_BYTES_LENGTH = BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion().getBytes(StandardCharsets.UTF_8).length;
private static final int BRAND_BYTES_LENGTH = GeyserConnector.NAME.getBytes(StandardCharsets.UTF_8).length;
/**
* The MOTD, sub-MOTD and Minecraft version ({@link #MINECRAFT_VERSION_BYTES_LENGTH}) combined cannot reach this length.
*/
private static final int MAGIC_RAKNET_LENGTH = 338;

private final GeyserConnector connector;

Expand Down Expand Up @@ -72,13 +81,13 @@ public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
pong.setGameType("Survival"); // Can only be Survival or Creative as of 1.16.210.59
pong.setNintendoLimited(false);
pong.setProtocolVersion(BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion());
pong.setVersion(BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()); // Required to not be empty as of 1.16.210.59
pong.setVersion(BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()); // Required to not be empty as of 1.16.210.59. Can only contain . and numbers.
pong.setIpv4Port(config.getBedrock().getPort());

if (config.isPassthroughMotd() && pingInfo != null && pingInfo.getDescription() != null) {
String[] motd = MessageTranslator.convertMessageLenient(pingInfo.getDescription()).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.
String subMotd = (motd.length != 1) ? motd[1] : GeyserConnector.NAME; // Second line of the motd if present, otherwise default.

pong.setMotd(mainMotd.trim());
pong.setSubMotd(subMotd.trim()); // Trimmed to shift it to the left, prevents the universe from collapsing on us just because we went 2 characters over the text box's limit.
Expand All @@ -95,22 +104,28 @@ public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
pong.setMaximumPlayerCount(config.getMaxPlayers());
}

if (pong.getMotd() == null) {
pong.setMotd("");
// Fallbacks to prevent errors and allow Bedrock to see the server
if (pong.getMotd() == null || pong.getMotd().trim().isEmpty()) {
pong.setMotd(GeyserConnector.NAME);
}
if (pong.getSubMotd() == null) {
pong.setSubMotd("");
if (pong.getSubMotd() == null || pong.getSubMotd().trim().isEmpty()) {
// Sub-MOTD cannot be empty as of 1.16.210.59
pong.setSubMotd(GeyserConnector.NAME);
}

// The ping will not appear if the MOTD + sub-MOTD is of a certain length.
// We don't know why, though
byte[] motdArray = pong.getMotd().getBytes(StandardCharsets.UTF_8);
if (motdArray.length + pong.getSubMotd().getBytes(StandardCharsets.UTF_8).length > 338) {
// Remove the sub-MOTD first since that only appears locally
pong.setSubMotd("");
if (motdArray.length > 338) {
int subMotdLength = pong.getSubMotd().getBytes(StandardCharsets.UTF_8).length;
if (motdArray.length + subMotdLength > (MAGIC_RAKNET_LENGTH - MINECRAFT_VERSION_BYTES_LENGTH)) {
// Shorten the sub-MOTD first since that only appears locally
if (subMotdLength > BRAND_BYTES_LENGTH) {
pong.setSubMotd(GeyserConnector.NAME);
subMotdLength = BRAND_BYTES_LENGTH;
}
if (motdArray.length > (MAGIC_RAKNET_LENGTH - MINECRAFT_VERSION_BYTES_LENGTH - subMotdLength)) {
// If the top MOTD is still too long, we chop it down
byte[] newMotdArray = new byte[339];
byte[] newMotdArray = new byte[MAGIC_RAKNET_LENGTH - MINECRAFT_VERSION_BYTES_LENGTH - subMotdLength];
System.arraycopy(motdArray, 0, newMotdArray, 0, newMotdArray.length);
pong.setMotd(new String(newMotdArray, StandardCharsets.UTF_8));
}
Expand Down
5 changes: 3 additions & 2 deletions connector/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ bedrock:
# This option is for the plugin version only.
clone-remote-port: false
# The MOTD that will be broadcasted to Minecraft: Bedrock Edition clients. This is irrelevant if "passthrough-motd" is set to true
motd1: "GeyserMC"
motd2: "Another GeyserMC forced host."
# If either of these are empty, the respective string will default to "Geyser"
motd1: "Geyser"
motd2: "Another Geyser server."
# The Server Name that will be sent to Minecraft: Bedrock Edition clients. This is visible in both the pause menu and the settings menu.
server-name: "Geyser"
remote:
Expand Down