1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Address reviews

This commit is contained in:
Eclipse
2025-06-18 16:46:24 +00:00
parent 9c3151e13b
commit 3286e884ae
8 changed files with 29 additions and 18 deletions

View File

@@ -65,6 +65,11 @@ public interface GeyserConnection extends Connection, CommandSource {
*/
int ping();
/**
* @return {@code true} if the client currently has a form open.
*/
boolean hasFormOpen();
/**
* Closes the currently open form on the client.
*/
@@ -85,9 +90,9 @@ public interface GeyserConnection extends Connection, CommandSource {
* <li>If all of the above fails, no dialog is opened.</li>
* </ul>
*
* <p>This method returns {@code true} if a dialog was opened, and {@code false} otherwise.</p>
* <p>Use {@link GeyserConnection#hasFormOpen()} to check if a dialog was opened.</p>
*/
boolean openPauseScreenAdditions();
void openPauseScreenAdditions();
/**
* Tries to open the {@code minecraft:quick_actions} dialog tag. This method opens this tag the same way Java does, that is:
@@ -98,9 +103,9 @@ public interface GeyserConnection extends Connection, CommandSource {
* <li>If there are no dialogs in the tag, no dialog is opened.</li>
* </ul>
*
* <p>This method returns {@code true} if a dialog was opened, and {@code false} otherwise.</p>
* <p>Use {@link GeyserConnection#hasFormOpen()} to check if a dialog was opened.</p>
*/
boolean openQuickActions();
void openQuickActions();
/**
* @param javaId the Java entity ID to look up.

View File

@@ -94,7 +94,7 @@ public class ModPingPassthrough implements IGeyserPingPassthrough {
}
@Override
public void send(Packet<?> packet, @org.jetbrains.annotations.Nullable ChannelFutureListener channelFutureListener, boolean bl) {
public void send(Packet<?> packet, @Nullable ChannelFutureListener channelFutureListener, boolean bl) {
if (packet instanceof ClientboundStatusResponsePacket statusResponse) {
status = statusResponse.status();
}

View File

@@ -107,7 +107,7 @@ public class GeyserVelocityPingPassthrough implements IGeyserPingPassthrough {
@Override
public HandshakeIntent getHandshakeIntent() {
return HandshakeIntent.LOGIN;
return HandshakeIntent.STATUS;
}
}

View File

@@ -169,7 +169,7 @@ public class CommandRegistry implements EventRegistrar {
registerBuiltInCommand(new ConnectionTestCommand(geyser, "connectiontest", "geyser.commands.connectiontest.desc", "geyser.command.connectiontest"));
registerBuiltInCommand(new PingCommand("ping", "geyser.commands.ping.desc", "geyser.command.ping"));
registerBuiltInCommand(new CustomOptionsCommand("options", "geyser.commands.options.desc", "geyser.command.options"));
registerBuiltInCommand(new QuickActionsCommand("quickactions", "geyser.commands.quickactions.desc", "geyser.command.options"));
registerBuiltInCommand(new QuickActionsCommand("quickactions", "geyser.commands.quickactions.desc", "geyser.command.quickactions"));
if (this.geyser.getPlatformType() == PlatformType.STANDALONE) {
registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));

View File

@@ -43,7 +43,8 @@ public class CustomOptionsCommand extends GeyserCommand {
@Override
public void execute(CommandContext<GeyserCommandSource> context) {
GeyserSession session = Objects.requireNonNull(context.sender().connection());
if (!session.openPauseScreenAdditions()) {
session.openPauseScreenAdditions();
if (!session.hasFormOpen()) {
context.sender().sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.options.fail", session.locale()));
}
}

View File

@@ -25,7 +25,6 @@
package org.geysermc.geyser.command.defaults;
import net.kyori.adventure.text.Component;
import org.geysermc.geyser.api.util.TriState;
import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandSource;
@@ -44,7 +43,8 @@ public class QuickActionsCommand extends GeyserCommand {
@Override
public void execute(CommandContext<GeyserCommandSource> context) {
GeyserSession session = Objects.requireNonNull(context.sender().connection());
if (!session.openQuickActions()) {
session.openQuickActions();
if (!session.hasFormOpen()) {
context.sender().sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.quickactions.fail", session.locale()));
}
}

View File

@@ -1513,12 +1513,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
}
@Override
public boolean openPauseScreenAdditions() {
public void openPauseScreenAdditions() {
List<Dialog> additions = tagCache.get(DialogTag.PAUSE_SCREEN_ADDITIONS);
if (additions.isEmpty()) {
if (serverLinks.isEmpty()) {
return false;
} else {
if (!serverLinks.isEmpty()) {
dialogManager.openDialog(BuiltInDialog.SERVER_LINKS);
}
} else if (additions.size() == 1) {
@@ -1526,20 +1524,18 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
} else {
dialogManager.openDialog(BuiltInDialog.CUSTOM_OPTIONS);
}
return true;
}
@Override
public boolean openQuickActions() {
public void openQuickActions() {
List<Dialog> quickActions = tagCache.get(DialogTag.QUICK_ACTIONS);
if (quickActions.isEmpty()) {
return false;
return;
} else if (quickActions.size() == 1) {
dialogManager.openDialog(quickActions.get(0));
} else {
dialogManager.openDialog(BuiltInDialog.QUICK_ACTIONS);
}
return true;
}
public void setClientRenderDistance(int clientRenderDistance) {
@@ -2286,6 +2282,11 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
return upstream.getProtocolVersion();
}
@Override
public boolean hasFormOpen() {
return formCache.hasFormOpen();
}
@Override
public void closeForm() {
sendUpstreamPacket(new ClientboundCloseFormPacket());

View File

@@ -64,6 +64,10 @@ public class FormCache {
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
private final GeyserSession session;
public boolean hasFormOpen() {
return !forms.isEmpty();
}
public int addForm(Form form) {
int formId = formIdCounter.getAndIncrement();
forms.put(formId, form);