Skip to content

Commit 7b0913c

Browse files
committed
Close the current inventory before sending form, kick players sending invalid block break actions
1 parent e8e4e80 commit 7b0913c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

core/src/main/java/org/geysermc/geyser/session/GeyserSession.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,10 @@ public InetSocketAddress getSocketAddress() {
16811681
public boolean sendForm(@NonNull Form form) {
16821682
// First close any dialogs that are open. This won't execute the dialog's closing action.
16831683
dialogManager.close();
1684+
// Also close current inventories, otherwise the form will not show
1685+
if (getOpenInventory() != null) {
1686+
InventoryUtils.closeInventory(this, getOpenInventory().getJavaId(), true);
1687+
}
16841688
return doSendForm(form);
16851689
}
16861690

@@ -2278,11 +2282,17 @@ public UUID javaUuid() {
22782282

22792283
@Override
22802284
public @NonNull String version() {
2285+
if (clientData == null) {
2286+
return "unknown";
2287+
}
22812288
return clientData.getGameVersion();
22822289
}
22832290

22842291
@Override
22852292
public @NonNull BedrockPlatform platform() {
2293+
if (clientData == null) {
2294+
return BedrockPlatform.UNKNOWN;
2295+
}
22862296
return BedrockPlatform.values()[clientData.getDeviceOs().ordinal()]; //todo
22872297
}
22882298

@@ -2429,4 +2439,8 @@ private void softEnumPacket(String name, SoftEnumUpdateType type, String enums)
24292439
packet.setSoftEnum(new CommandEnumData(name, Collections.singletonMap(enums, Collections.emptySet()), true));
24302440
sendUpstreamPacket(packet);
24312441
}
2442+
2443+
public String getDebugInfo() {
2444+
return "Username: %s, DeviceOs: %s, Version: %s".formatted(bedrockUsername(), platform(), version());
2445+
}
24322446
}

core/src/main/java/org/geysermc/geyser/session/cache/BlockBreakHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ protected void handleBlockBreakActions(PlayerAuthInputPacket packet) {
256256
handleAbortBreaking(position);
257257
}
258258
default -> {
259-
throw new IllegalStateException("Unknown block break action: " + actionData.getAction());
259+
GeyserImpl.getInstance().getLogger().warning("Unknown block break action (%s) received! (origin: %s)!"
260+
.formatted(actionData.getAction(), session.getDebugInfo()));
261+
GeyserImpl.getInstance().getLogger().debug("Odd packet: " + packet);
262+
session.disconnect("Invalid block breaking action received!");
260263
}
261264
}
262265
}

0 commit comments

Comments
 (0)