mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-19 14:59:27 +00:00
Address reviews
This commit is contained in:
@@ -65,6 +65,11 @@ public interface GeyserConnection extends Connection, CommandSource {
|
|||||||
*/
|
*/
|
||||||
int ping();
|
int ping();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@code true} if the client currently has a form open.
|
||||||
|
*/
|
||||||
|
boolean hasFormOpen();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the currently open form on the client.
|
* 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>
|
* <li>If all of the above fails, no dialog is opened.</li>
|
||||||
* </ul>
|
* </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:
|
* 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>
|
* <li>If there are no dialogs in the tag, no dialog is opened.</li>
|
||||||
* </ul>
|
* </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.
|
* @param javaId the Java entity ID to look up.
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class ModPingPassthrough implements IGeyserPingPassthrough {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (packet instanceof ClientboundStatusResponsePacket statusResponse) {
|
||||||
status = statusResponse.status();
|
status = statusResponse.status();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class GeyserVelocityPingPassthrough implements IGeyserPingPassthrough {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandshakeIntent getHandshakeIntent() {
|
public HandshakeIntent getHandshakeIntent() {
|
||||||
return HandshakeIntent.LOGIN;
|
return HandshakeIntent.STATUS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ public class CommandRegistry implements EventRegistrar {
|
|||||||
registerBuiltInCommand(new ConnectionTestCommand(geyser, "connectiontest", "geyser.commands.connectiontest.desc", "geyser.command.connectiontest"));
|
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 PingCommand("ping", "geyser.commands.ping.desc", "geyser.command.ping"));
|
||||||
registerBuiltInCommand(new CustomOptionsCommand("options", "geyser.commands.options.desc", "geyser.command.options"));
|
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) {
|
if (this.geyser.getPlatformType() == PlatformType.STANDALONE) {
|
||||||
registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
|
registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ public class CustomOptionsCommand extends GeyserCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
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()));
|
context.sender().sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.options.fail", session.locale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
package org.geysermc.geyser.command.defaults;
|
package org.geysermc.geyser.command.defaults;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import org.geysermc.geyser.api.util.TriState;
|
import org.geysermc.geyser.api.util.TriState;
|
||||||
import org.geysermc.geyser.command.GeyserCommand;
|
import org.geysermc.geyser.command.GeyserCommand;
|
||||||
import org.geysermc.geyser.command.GeyserCommandSource;
|
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||||
@@ -44,7 +43,8 @@ public class QuickActionsCommand extends GeyserCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandContext<GeyserCommandSource> context) {
|
public void execute(CommandContext<GeyserCommandSource> context) {
|
||||||
GeyserSession session = Objects.requireNonNull(context.sender().connection());
|
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()));
|
context.sender().sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.quickactions.fail", session.locale()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1513,12 +1513,10 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean openPauseScreenAdditions() {
|
public void openPauseScreenAdditions() {
|
||||||
List<Dialog> additions = tagCache.get(DialogTag.PAUSE_SCREEN_ADDITIONS);
|
List<Dialog> additions = tagCache.get(DialogTag.PAUSE_SCREEN_ADDITIONS);
|
||||||
if (additions.isEmpty()) {
|
if (additions.isEmpty()) {
|
||||||
if (serverLinks.isEmpty()) {
|
if (!serverLinks.isEmpty()) {
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
dialogManager.openDialog(BuiltInDialog.SERVER_LINKS);
|
dialogManager.openDialog(BuiltInDialog.SERVER_LINKS);
|
||||||
}
|
}
|
||||||
} else if (additions.size() == 1) {
|
} else if (additions.size() == 1) {
|
||||||
@@ -1526,20 +1524,18 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
} else {
|
} else {
|
||||||
dialogManager.openDialog(BuiltInDialog.CUSTOM_OPTIONS);
|
dialogManager.openDialog(BuiltInDialog.CUSTOM_OPTIONS);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean openQuickActions() {
|
public void openQuickActions() {
|
||||||
List<Dialog> quickActions = tagCache.get(DialogTag.QUICK_ACTIONS);
|
List<Dialog> quickActions = tagCache.get(DialogTag.QUICK_ACTIONS);
|
||||||
if (quickActions.isEmpty()) {
|
if (quickActions.isEmpty()) {
|
||||||
return false;
|
return;
|
||||||
} else if (quickActions.size() == 1) {
|
} else if (quickActions.size() == 1) {
|
||||||
dialogManager.openDialog(quickActions.get(0));
|
dialogManager.openDialog(quickActions.get(0));
|
||||||
} else {
|
} else {
|
||||||
dialogManager.openDialog(BuiltInDialog.QUICK_ACTIONS);
|
dialogManager.openDialog(BuiltInDialog.QUICK_ACTIONS);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientRenderDistance(int clientRenderDistance) {
|
public void setClientRenderDistance(int clientRenderDistance) {
|
||||||
@@ -2286,6 +2282,11 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
return upstream.getProtocolVersion();
|
return upstream.getProtocolVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasFormOpen() {
|
||||||
|
return formCache.hasFormOpen();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void closeForm() {
|
public void closeForm() {
|
||||||
sendUpstreamPacket(new ClientboundCloseFormPacket());
|
sendUpstreamPacket(new ClientboundCloseFormPacket());
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ public class FormCache {
|
|||||||
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<Form> forms = new Int2ObjectOpenHashMap<>();
|
||||||
private final GeyserSession session;
|
private final GeyserSession session;
|
||||||
|
|
||||||
|
public boolean hasFormOpen() {
|
||||||
|
return !forms.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
public int addForm(Form form) {
|
public int addForm(Form form) {
|
||||||
int formId = formIdCounter.getAndIncrement();
|
int formId = formIdCounter.getAndIncrement();
|
||||||
forms.put(formId, form);
|
forms.put(formId, form);
|
||||||
|
|||||||
Reference in New Issue
Block a user