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