2022-02-22 00:20:22 +00:00
|
|
|
package dev.plex.command.impl;
|
|
|
|
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.command.annotation.CommandParameters;
|
|
|
|
import dev.plex.command.annotation.CommandPermissions;
|
|
|
|
import dev.plex.rank.enums.Rank;
|
2022-02-25 09:54:11 +00:00
|
|
|
import dev.plex.util.PlexLog;
|
2022-02-22 00:20:22 +00:00
|
|
|
import dev.plex.util.PlexUtils;
|
2022-02-26 06:26:42 +00:00
|
|
|
import java.util.List;
|
2022-02-22 00:20:22 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import net.kyori.adventure.text.format.NamedTextColor;
|
2022-02-25 09:54:11 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.World;
|
2022-02-22 00:20:22 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
2022-02-25 09:54:11 +00:00
|
|
|
@CommandParameters(name = "debug", description = "Debug command", usage = "/<command> <redis-reset | gamerules> [player]")
|
2022-02-22 00:20:22 +00:00
|
|
|
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
|
|
|
public class DebugCMD extends PlexCommand
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
|
|
|
{
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
return usage();
|
|
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("redis-reset"))
|
|
|
|
{
|
|
|
|
Player player = getNonNullPlayer(args[1]);
|
2022-02-22 07:11:37 +00:00
|
|
|
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
2022-02-22 00:20:22 +00:00
|
|
|
{
|
2022-02-22 07:11:37 +00:00
|
|
|
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString());
|
|
|
|
return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW);
|
2022-02-22 00:20:22 +00:00
|
|
|
}
|
2022-02-22 07:11:37 +00:00
|
|
|
return componentFromString("Couldn't find player in Redis punishments.");
|
2022-02-22 00:20:22 +00:00
|
|
|
}
|
2022-02-25 09:54:11 +00:00
|
|
|
if (args[0].equalsIgnoreCase("gamerules"))
|
|
|
|
{
|
|
|
|
for (World world : Bukkit.getWorlds())
|
|
|
|
{
|
|
|
|
PlexUtils.commitGameRules(world);
|
|
|
|
PlexLog.debug("Set gamerules for world: " + world.getName());
|
|
|
|
}
|
|
|
|
return mmString("<aqua>Re-applied game all the game rules!");
|
|
|
|
}
|
2022-02-22 00:20:22 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
|
|
{
|
|
|
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
|
|
|
}
|
|
|
|
}
|