Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-24 23:30:22 +01:00
Feature: Add method to close forms in the API (#4957)
* Add closeForm api method * Move version check to GameProtocol
Dieser Commit ist enthalten in:
Ursprung
bd73cbd243
Commit
ce62824899
@ -60,6 +60,16 @@ public interface GeyserConnection extends Connection, CommandSource {
|
|||||||
*/
|
*/
|
||||||
@NonNull EntityData entities();
|
@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.
|
* @param javaId the Java entity ID to look up.
|
||||||
* @return a {@link GeyserEntity} if present in this connection's entity tracker.
|
* @return a {@link GeyserEntity} if present in this connection's entity tracker.
|
||||||
@ -132,9 +142,4 @@ public interface GeyserConnection extends Connection, CommandSource {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
@NonNull
|
@NonNull
|
||||||
Set<String> fogEffects();
|
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();
|
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.
|
* 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.BiomeDefinitionListPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.CameraPresetsPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.CameraPresetsPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
|
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.CraftingDataPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.CreativeContentPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.CreativeContentPacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.EmoteListPacket;
|
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.BedrockDimension;
|
||||||
import org.geysermc.geyser.level.JavaDimension;
|
import org.geysermc.geyser.level.JavaDimension;
|
||||||
import org.geysermc.geyser.level.physics.CollisionManager;
|
import org.geysermc.geyser.level.physics.CollisionManager;
|
||||||
|
import org.geysermc.geyser.network.GameProtocol;
|
||||||
import org.geysermc.geyser.network.netty.LocalSession;
|
import org.geysermc.geyser.network.netty.LocalSession;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
import org.geysermc.geyser.registry.Registries;
|
||||||
import org.geysermc.geyser.registry.type.BlockMappings;
|
import org.geysermc.geyser.registry.type.BlockMappings;
|
||||||
@ -2114,6 +2116,13 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
return (int) Math.floor(rakSessionCodec.getPing());
|
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) {
|
public void addCommandEnum(String name, String enums) {
|
||||||
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
|
softEnumPacket(name, SoftEnumUpdateType.ADD, enums);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren