mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-31 04:36:33 +00:00
Address reviews
This commit is contained in:
@@ -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"));
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user