Plex/src/main/java/dev/plex/command/impl/PlexCMD.java

67 lines
2.7 KiB
Java
Raw Normal View History

2021-01-03 07:21:15 +00:00
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
2021-06-20 08:02:07 +00:00
import dev.plex.Plex;
2022-01-04 03:04:39 +00:00
import dev.plex.command.PlexCommand;
2021-01-03 07:21:15 +00:00
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
2022-01-04 03:04:39 +00:00
import dev.plex.command.exception.CommandArgumentException;
import dev.plex.command.exception.CommandFailException;
2021-01-03 07:21:15 +00:00
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
2022-01-27 21:23:01 +00:00
import java.util.List;
import net.kyori.adventure.text.Component;
2021-06-20 08:02:07 +00:00
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandPermissions(level = Rank.OP, permission = "plex.plex", source = RequiredCommandSource.ANY)
@CommandParameters(name = "plex", usage = "/<command> [reload]", aliases = "plexhelp", description = "Show information about Plex or reload it")
public class PlexCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length == 0)
{
send(sender, ChatColor.LIGHT_PURPLE + "Plex. The long awaited TotalFreedomMod rewrite starts here...");
return componentFromString(ChatColor.LIGHT_PURPLE + "Plugin version: " + ChatColor.GOLD + "1.0");
2022-01-04 03:04:39 +00:00
}
if (args[0].equalsIgnoreCase("reload"))
2022-01-04 03:04:39 +00:00
{
checkRank(sender, Rank.SENIOR_ADMIN, "plex.reload");
2022-01-04 03:04:39 +00:00
Plex.get().config.load();
send(sender, "Reloaded config file");
2022-01-04 03:04:39 +00:00
Plex.get().messages.load();
send(sender, "Reloaded messages file");
2022-01-04 03:04:39 +00:00
Plex.get().getRankManager().importDefaultRanks();
send(sender, "Imported ranks");
send(sender, "Plex successfully reloaded.");
}
else if (args[0].equalsIgnoreCase("redis"))
{
checkRank(sender, Rank.SENIOR_ADMIN, "plex.redis");
if (!plugin.getRedisConnection().isEnabled())
{
throw new CommandFailException("&cRedis is not enabled.");
}
plugin.getRedisConnection().getJedis().set("test", "123");
send(sender, "Set test to 123. Now outputting key test...");
send(sender, plugin.getRedisConnection().getJedis().get("test"));
2022-02-04 19:30:05 +00:00
plugin.getRedisConnection().getJedis().close();
}
else
{
2022-01-04 03:04:39 +00:00
throw new CommandArgumentException();
}
return null;
}
@Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
return ImmutableList.of("reload", "redis");
}
}