mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 06:24:59 +01:00
Feature: Add method to close forms in the API (#4957)
* Add closeForm api method * Move version check to GameProtocol
This commit is contained in:
parent
bd73cbd243
commit
ce62824899
3 changed files with 23 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,10 @@ public final class GameProtocol {
|
|||
return session.getUpstream().getProtocolVersion() < Bedrock_v685.CODEC.getProtocolVersion();
|
||||
}
|
||||
|
||||
public static boolean isPre1_21_2(GeyserSession session) {
|
||||
return session.getUpstream().getProtocolVersion() < Bedrock_v686.CODEC.getProtocolVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link PacketCodec} for Minecraft: Java Edition.
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
@ -140,6 +141,7 @@ import org.geysermc.geyser.item.type.BlockItem;
|
|||
import org.geysermc.geyser.level.BedrockDimension;
|
||||
import org.geysermc.geyser.level.JavaDimension;
|
||||
import org.geysermc.geyser.level.physics.CollisionManager;
|
||||
import org.geysermc.geyser.network.GameProtocol;
|
||||
import org.geysermc.geyser.network.netty.LocalSession;
|
||||
import org.geysermc.geyser.registry.Registries;
|
||||
import org.geysermc.geyser.registry.type.BlockMappings;
|
||||
|
@ -2114,6 +2116,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||
return (int) Math.floor(rakSessionCodec.getPing());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeForm() {
|
||||
if (!GameProtocol.isPre1_21_2(this)) {
|
||||
sendUpstreamPacket(new ClientboundCloseFormPacket());
|
||||
}
|
||||
}
|
||||
|
||||
public void addCommandEnum(String name, String enums) {
|
||||
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue