1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-31 04:36:47 +00:00

Register permissions on Spigot. Profile ID can be null. Fixed submodule

This commit is contained in:
Tim203
2022-02-06 02:10:17 +01:00
parent 141643f381
commit 039b398dad
13 changed files with 63 additions and 33 deletions

View File

@@ -100,7 +100,7 @@ public class FloodgatePlatform {
InstanceHolder.set(api, link, this.injector, packetHandlers, handshakeHandlers, KEY);
// todo provide build number and branch for Geyser dump
// todo this was the place where we provided the build number and branch for Geyser dump
guice.getInstance(NewsChecker.class).start();
}

View File

@@ -48,7 +48,7 @@ import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.player.UserAudience.PlayerAudience;
import org.geysermc.floodgate.player.UserAudienceArgument;
import org.geysermc.floodgate.util.Constants;
import org.geysermc.floodgate.util.Permissions;
import org.geysermc.floodgate.command.util.Permission;
@NoArgsConstructor
public final class LinkAccountCommand implements FloodgateCommand {
@@ -60,7 +60,7 @@ public final class LinkAccountCommand implements FloodgateCommand {
return commandManager.commandBuilder("linkaccount",
ArgumentDescription.of("Link your Java account with your Bedrock account"))
.senderType(PlayerAudience.class)
.permission(Permissions.COMMAND_LINK.get())
.permission(Permission.COMMAND_LINK.get())
.argument(UserAudienceArgument.of("player", true))
.argument(StringArgument.optional("code"))
.handler(this::execute)

View File

@@ -43,7 +43,7 @@ import org.geysermc.floodgate.platform.command.TranslatableMessage;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.player.UserAudience.PlayerAudience;
import org.geysermc.floodgate.util.Constants;
import org.geysermc.floodgate.util.Permissions;
import org.geysermc.floodgate.command.util.Permission;
@NoArgsConstructor
public final class UnlinkAccountCommand implements FloodgateCommand {
@@ -54,7 +54,7 @@ public final class UnlinkAccountCommand implements FloodgateCommand {
return commandManager.commandBuilder("unlinkaccount",
ArgumentDescription.of("Unlink your Java account from your Bedrock account"))
.senderType(PlayerAudience.class)
.permission(Permissions.COMMAND_UNLINK.get())
.permission(Permission.COMMAND_UNLINK.get())
.handler(this::execute)
.build();
}

View File

@@ -48,7 +48,7 @@ import org.geysermc.floodgate.player.UserAudienceArgument;
import org.geysermc.floodgate.player.UserAudienceArgument.PlayerType;
import org.geysermc.floodgate.util.Constants;
import org.geysermc.floodgate.util.HttpUtils;
import org.geysermc.floodgate.util.Permissions;
import org.geysermc.floodgate.command.util.Permission;
public class WhitelistCommand implements FloodgateCommand {
@Inject private FloodgateConfig config;
@@ -58,7 +58,7 @@ public class WhitelistCommand implements FloodgateCommand {
public Command<UserAudience> buildCommand(CommandManager<UserAudience> commandManager) {
Command.Builder<UserAudience> builder = commandManager.commandBuilder("fwhitelist",
ArgumentDescription.of("Easy way to whitelist Bedrock players"))
.permission(Permissions.COMMAND_WHITELIST.get());
.permission(Permission.COMMAND_WHITELIST.get());
commandManager.command(builder
.literal("add", "a")

View File

@@ -35,9 +35,9 @@ import cloud.commandframework.context.CommandContext;
import java.util.Locale;
import java.util.function.Consumer;
import lombok.RequiredArgsConstructor;
import org.geysermc.floodgate.command.util.Permission;
import org.geysermc.floodgate.platform.command.FloodgateCommand;
import org.geysermc.floodgate.player.UserAudience;
import org.geysermc.floodgate.util.Permissions;
public final class MainCommand implements FloodgateCommand {
@Override
@@ -46,12 +46,13 @@ public final class MainCommand implements FloodgateCommand {
"floodgate",
ArgumentDescription.of("A set of Floodgate related actions in one command"))
.senderType(UserAudience.class)
.permission(Permissions.COMMAND_MAIN.get())
.permission(Permission.COMMAND_MAIN.get())
.handler(this::execute);
for (SubCommand subCommand : SubCommand.VALUES) {
commandManager.command(builder
.literal(subCommand.name().toLowerCase(Locale.ROOT), subCommand.description)
.permission(subCommand.permission.get())
.handler(subCommand.executor::accept)
);
}
@@ -65,10 +66,12 @@ public final class MainCommand implements FloodgateCommand {
StringBuilder helpMessage = new StringBuilder("Available subcommands are:\n");
for (SubCommand subCommand : SubCommand.VALUES) {
helpMessage.append('\n').append(COLOR_CHAR).append('b')
.append(subCommand.name().toLowerCase(Locale.ROOT))
.append(COLOR_CHAR).append("f - ").append(COLOR_CHAR).append('7')
.append(subCommand.description);
if (context.getSender().hasPermission(subCommand.permission.get())) {
helpMessage.append('\n').append(COLOR_CHAR).append('b')
.append(subCommand.name().toLowerCase(Locale.ROOT))
.append(COLOR_CHAR).append("f - ").append(COLOR_CHAR).append('7')
.append(subCommand.description);
}
}
context.getSender().sendMessage(helpMessage.toString());
@@ -77,11 +80,12 @@ public final class MainCommand implements FloodgateCommand {
@RequiredArgsConstructor
enum SubCommand {
FIREWALL("Check if your outgoing firewall allows Floodgate to work properly",
FirewallCheckSubcommand::executeFirewall);
Permission.COMMAND_MAIN_FIREWALL, FirewallCheckSubcommand::executeFirewall);
static final SubCommand[] VALUES = values();
final String description;
final Permission permission;
final Consumer<CommandContext<UserAudience>> executor;
}
}

View File

@@ -72,7 +72,7 @@ public final class ConfigUpdater {
"config now and we'll also generate a new Floodgate key for you, but if " +
"you're running a network or if you're running a Spigot server with " +
"Geyser Standalone please update as you'll no longer be able to connect.");
renames.put("enabled", "enable"); //todo make dump system and add a boolean 'found-legacy-key' or something like that
renames.put("enabled", "enable");
renames.put("allowed", "allow-linking");
// relocate the old key so that they can restore it if it was a new key

View File

@@ -43,7 +43,7 @@ import org.geysermc.floodgate.platform.command.CommandUtil;
import org.geysermc.floodgate.util.Constants;
import org.geysermc.floodgate.util.HttpUtils;
import org.geysermc.floodgate.util.HttpUtils.HttpResponse;
import org.geysermc.floodgate.util.Permissions;
import org.geysermc.floodgate.command.util.Permission;
public class NewsChecker {
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
@@ -72,8 +72,6 @@ public class NewsChecker {
}
private void checkNews() {
// todo also check news for the downloaded database types
HttpResponse<JsonArray> response =
HttpUtils.getSilent(
Constants.NEWS_OVERVIEW_URL + Constants.NEWS_PROJECT_NAME,
@@ -121,14 +119,14 @@ public class NewsChecker {
return;
}
if (commandUtil.hasPermission(player, Permissions.NEWS_RECEIVE.get())) {
if (commandUtil.hasPermission(player, Permission.NEWS_RECEIVE.get())) {
String message = Constants.COLOR_CHAR + "a " + news.getMessage();
commandUtil.sendMessage(player, message);
}
break;
case BROADCAST_TO_OPERATORS:
Collection<Object> onlinePlayers = commandUtil.getOnlinePlayersWithPermission(
Permissions.NEWS_RECEIVE.get()
Permission.NEWS_RECEIVE.get()
);
for (Object onlinePlayer : onlinePlayers) {
@@ -182,7 +180,8 @@ public class NewsChecker {
schedule(delayMs > 0 ? delayMs : 0);
break;
case CONFIG_SPECIFIC:
//todo
//todo this can replace the downloaded database types update check.
// check if ConfigUtils has a way to check this easily
break;
}
activeNewsItems.put(item.getId(), item);