Restrictions to commands players can send on Geyser Standalone (#2099)

- players cannot create a dump
- if the version command is sent by a player, it will not check for new updates
This commit is contained in:
Konicai 2021-04-02 13:36:30 -04:00 committed by GitHub
parent fb18a6493a
commit 8f6785e48f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 2 deletions

View File

@ -27,6 +27,7 @@ package org.geysermc.connector.command.defaults;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
@ -56,6 +57,12 @@ public class DumpCommand extends GeyserCommand {
@Override
public void execute(GeyserSession session, CommandSender sender, String[] args) {
// Only allow the console to create dumps on Geyser Standalone
if (!sender.isConsole() && connector.getPlatformType() == PlatformType.STANDALONE) {
sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", sender.getLocale()));
return;
}
boolean showSensitive = false;
boolean offlineDump = false;
if (args.length >= 1) {

View File

@ -30,6 +30,7 @@ import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.LanguageUtils;
import java.util.Collections;
@ -47,6 +48,7 @@ public class StopCommand extends GeyserCommand {
@Override
public void execute(GeyserSession session, CommandSender sender, String[] args) {
if (!sender.isConsole() && connector.getPlatformType() == PlatformType.STANDALONE) {
sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", sender.getLocale()));
return;
}

View File

@ -27,6 +27,7 @@ package org.geysermc.connector.command.defaults;
import com.github.steveice10.mc.protocol.MinecraftConstants;
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
@ -45,8 +46,12 @@ import java.util.Properties;
public class VersionCommand extends GeyserCommand {
private final GeyserConnector connector;
public VersionCommand(GeyserConnector connector, String name, String description, String permission) {
super(name, description, permission);
this.connector = connector;
}
@Override
@ -61,9 +66,9 @@ public class VersionCommand extends GeyserCommand {
sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.version.version", sender.getLocale(), GeyserConnector.NAME, GeyserConnector.VERSION, GeyserConnector.MINECRAFT_VERSION, bedrockVersions));
// Disable update checking in dev mode
// Disable update checking in dev mode and for players in Geyser Standalone
//noinspection ConstantConditions - changes in production
if (!GeyserConnector.VERSION.equals("DEV")) {
if (!GeyserConnector.VERSION.equals("DEV") && !(!sender.isConsole() && connector.getPlatformType() == PlatformType.STANDALONE)) {
sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.version.checking", sender.getLocale()));
try {
Properties gitProp = new Properties();