1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Close the current inventory before sending form, kick players sending invalid block break actions

This commit is contained in:
onebeastchris
2025-09-19 03:30:36 +02:00
parent e8e4e80fe8
commit 7b0913ca86
2 changed files with 18 additions and 1 deletions

View File

@@ -1681,6 +1681,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
public boolean sendForm(@NonNull Form form) {
// First close any dialogs that are open. This won't execute the dialog's closing action.
dialogManager.close();
// Also close current inventories, otherwise the form will not show
if (getOpenInventory() != null) {
InventoryUtils.closeInventory(this, getOpenInventory().getJavaId(), true);
}
return doSendForm(form);
}
@@ -2278,11 +2282,17 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
@Override
public @NonNull String version() {
if (clientData == null) {
return "unknown";
}
return clientData.getGameVersion();
}
@Override
public @NonNull BedrockPlatform platform() {
if (clientData == null) {
return BedrockPlatform.UNKNOWN;
}
return BedrockPlatform.values()[clientData.getDeviceOs().ordinal()]; //todo
}
@@ -2429,4 +2439,8 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
packet.setSoftEnum(new CommandEnumData(name, Collections.singletonMap(enums, Collections.emptySet()), true));
sendUpstreamPacket(packet);
}
public String getDebugInfo() {
return "Username: %s, DeviceOs: %s, Version: %s".formatted(bedrockUsername(), platform(), version());
}
}

View File

@@ -256,7 +256,10 @@ public class BlockBreakHandler {
handleAbortBreaking(position);
}
default -> {
throw new IllegalStateException("Unknown block break action: " + actionData.getAction());
GeyserImpl.getInstance().getLogger().warning("Unknown block break action (%s) received! (origin: %s)!"
.formatted(actionData.getAction(), session.getDebugInfo()));
GeyserImpl.getInstance().getLogger().debug("Odd packet: " + packet);
session.disconnect("Invalid block breaking action received!");
}
}
}