Add closeForm api method

This commit is contained in:
onebeastchris 2024-08-11 01:12:58 +02:00
parent 7121da70cd
commit 7675d91124
2 changed files with 19 additions and 5 deletions

View file

@ -60,6 +60,16 @@ public interface GeyserConnection extends Connection, CommandSource {
*/
@NonNull EntityData entities();
/**
* Returns the current ping of the connection.
*/
int ping();
/**
* Closes the currently open form on the client.
*/
void closeForm();
/**
* @param javaId the Java entity ID to look up.
* @return a {@link GeyserEntity} if present in this connection's entity tracker.
@ -132,9 +142,4 @@ public interface GeyserConnection extends Connection, CommandSource {
@Deprecated
@NonNull
Set<String> fogEffects();
/**
* Returns the current ping of the connection.
*/
int ping();
}

View file

@ -79,6 +79,7 @@ import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
import org.cloudburstmc.protocol.bedrock.packet.BiomeDefinitionListPacket;
import org.cloudburstmc.protocol.bedrock.packet.CameraPresetsPacket;
import org.cloudburstmc.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
import org.cloudburstmc.protocol.bedrock.packet.ClientboundCloseFormPacket;
import org.cloudburstmc.protocol.bedrock.packet.CraftingDataPacket;
import org.cloudburstmc.protocol.bedrock.packet.CreativeContentPacket;
import org.cloudburstmc.protocol.bedrock.packet.EmoteListPacket;
@ -2114,6 +2115,14 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
return (int) Math.floor(rakSessionCodec.getPing());
}
@Override
public void closeForm() {
// TODO remove once 1.21.2 is lowest supported version
if (upstream.getProtocolVersion() >= 686) {
sendUpstreamPacket(new ClientboundCloseFormPacket());
}
}
public void addCommandEnum(String name, String enums) {
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
}