/* * 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.Constants; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; import com.imaginarycode.minecraft.redisbungee.commands.utils.StopperUUIDCleanupTask; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import java.util.Date; @CommandAlias("rb|redisbungee") @CommandPermission("redisbungee.command.use") public class CommandRedisBungee extends AdventureBaseCommand { private final RedisBungeePlugin plugin; public CommandRedisBungee(RedisBungeePlugin plugin) { this.plugin = plugin; } @Default @Subcommand("info|version|git") public void info(CommandIssuer issuer) { final String message = """ This proxy is running RedisBungee Limework's fork ======================================== RedisBungee version: Build date: Commit: ======================================== run /rb help for more commands"""; sendMessage( issuer, MiniMessage.miniMessage() .deserialize( message, Placeholder.component("version", Component.text(Constants.VERSION)), Placeholder.component("build-date", Component.text( new Date(Constants.BUILD_DATE * 1000).toString() )), Placeholder.component( "commit", Component.text(Constants.GIT_COMMIT.substring(0, 8)) .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.OPEN_URL, Constants.getGithubCommitLink())) .hoverEvent(HoverEvent.showText(Component.text("Click me to open: " + Constants.getGithubCommitLink()))) ))); } // ......: ...... @HelpCommand public void help(CommandIssuer issuer) { final String message = """ ======================================== /rb info: shows info of this version. /rb help: shows this page. /rb clean: cleans up the uuid cache WARNING... command above could cause performance issues /rb show: shows list of proxies with player count ======================================== run /rb help for more commands"""; sendMessage(issuer, MiniMessage.miniMessage().deserialize(message)); } @Subcommand("clean") @Private public void cleanUp(CommandIssuer issuer) { if (StopperUUIDCleanupTask.isRunning) { sendMessage(issuer, Component.text("cleanup is currently running!").color(NamedTextColor.RED)); return; } sendMessage(issuer, Component.text("cleanup is Starting, you should see the output status in the proxy console").color(NamedTextColor.GOLD)); plugin.executeAsync(new StopperUUIDCleanupTask(plugin)); } @Subcommand("show") public void showProxies(CommandIssuer issuer) { final String message = """ ======================================== ========================================"""; final String proxyPlayersMessage = " : online"; TextComponent.Builder builder = Component.text(); plugin.proxyDataManager().eachProxyCount().forEach((proxy, players) -> builder.append( MiniMessage.miniMessage() .deserialize(proxyPlayersMessage, Placeholder.component("here", Component.text(plugin.proxyDataManager().proxyId().equals(proxy) ? " (#) " : "")), Placeholder.component("proxy", Component.text(proxy)), Placeholder.component("players", Component.text(players)) ) .appendNewline())); sendMessage(issuer, MiniMessage.miniMessage().deserialize(message, Placeholder.component("data", builder))); } }