From 96c0dff8c16017b149a94ad72e4c1bc6f16f3f59 Mon Sep 17 00:00:00 2001 From: Mohammed Alteneiji Date: Sat, 22 Feb 2025 15:05:43 +0400 Subject: [PATCH] debug command introduction --- .../redisbungee/commands/CommandLoader.java | 19 +++++++ .../commands/CommandRedisBungeeDebug.java | 49 +++++++++++++++++++ gradle/libs.versions.toml | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungeeDebug.java diff --git a/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java b/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java index 5346be9..cddb1b3 100644 --- a/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java +++ b/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java @@ -10,14 +10,19 @@ package com.imaginarycode.minecraft.redisbungee.commands; +import co.aikar.commands.CommandContexts; import co.aikar.commands.CommandManager; +import co.aikar.commands.InvalidCommandArgument; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.commands.legacy.LegacyRedisBungeeCommands; +import java.util.UUID; + public class CommandLoader { public static void initCommands(CommandManager commandManager, RedisBungeePlugin plugin) { + registerContexts(commandManager); var commandsConfiguration = plugin.configuration().commandsConfiguration(); if (commandsConfiguration.redisbungeeEnabled()) { commandManager.registerCommand(new CommandRedisBungee(plugin)); @@ -26,6 +31,20 @@ public class CommandLoader { commandManager.registerCommand(new LegacyRedisBungeeCommands(commandManager,plugin)); } + commandManager.registerCommand(new CommandRedisBungeeDebug(plugin)); + + + } + private static void registerContexts(CommandManager commandManager) { + CommandContexts commandContexts = commandManager.getCommandContexts(); + commandContexts.registerContext(UUID.class, c -> { + String uuidString = c.popFirstArg(); + try { + return UUID.fromString(uuidString); + } catch (IllegalArgumentException e) { + throw new InvalidCommandArgument("invaild uuid"); + } + }); } } diff --git a/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungeeDebug.java b/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungeeDebug.java new file mode 100644 index 0000000..e10973a --- /dev/null +++ b/commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungeeDebug.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.*; +import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; +import net.kyori.adventure.text.Component; + +import java.util.UUID; + +@CommandAlias("rbd|redisbungeedebug") +@CommandPermission("redisbungee.command.debug.use") +@Description("debug commands") +public class CommandRedisBungeeDebug extends AdventureBaseCommand { + + private final RedisBungeePlugin plugin; + + public CommandRedisBungeeDebug(RedisBungeePlugin plugin) { + this.plugin = plugin; + } + + @Subcommand("kickByName") + @Description("kicks a player from the network by name") + @Private + public void kick(CommandIssuer issuer, String playerName) { + + plugin.getAbstractRedisBungeeApi().kickPlayer(playerName, Component.text("debug kick")); + } + + @Subcommand("kickByUUID") + @Description("kicks a player from the network by UUID") + @Private + public void kick(CommandIssuer issuer, UUID uuid) { + + plugin.getAbstractRedisBungeeApi().kickPlayer(uuid, Component.text("debug kick")); + } + + +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 08b742e..b312687 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ jedis = "5.2.0" okhttp = "4.12.0" configurateV3 = "3.7.3" caffeine = "3.1.8" -adventure = "4.18.0" +adventure = "4.19.0" adventure-bungeecord-platform = "4.3.4" acf = "e2005dd62d" bungeecordApi = "1.21-R0.1-SNAPSHOT"