2022-05-08 05:54:22 +00:00
|
|
|
package dev.plex.command.sub;
|
|
|
|
|
|
|
|
import dev.plex.Guilds;
|
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.command.annotation.CommandParameters;
|
|
|
|
import dev.plex.command.annotation.CommandPermissions;
|
|
|
|
import dev.plex.command.source.RequiredCommandSource;
|
|
|
|
import dev.plex.guild.Guild;
|
|
|
|
import dev.plex.rank.enums.Rank;
|
|
|
|
import dev.plex.util.PlexUtils;
|
|
|
|
import dev.plex.util.minimessage.SafeMiniMessage;
|
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
|
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
|
|
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
2022-06-14 04:14:06 +00:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-05-08 05:54:22 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
2022-05-09 00:52:08 +00:00
|
|
|
@CommandParameters(name = "prefix", aliases = "tag,settag,setprefix", usage = "/guild <command> <prefix>", description = "Sets the guild's default prefix")
|
2022-05-08 05:54:22 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.prefix")
|
|
|
|
public class PrefixSubCommand extends PlexCommand
|
|
|
|
{
|
|
|
|
public PrefixSubCommand()
|
|
|
|
{
|
|
|
|
super(false);
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
|
|
|
|
{
|
|
|
|
if (args.length == 0)
|
|
|
|
{
|
|
|
|
return usage();
|
|
|
|
}
|
|
|
|
assert player != null;
|
|
|
|
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresentOrElse(guild -> {
|
2022-05-09 00:15:22 +00:00
|
|
|
if (!guild.getOwner().getUuid().equals(player.getUniqueId()))
|
2022-05-08 05:54:22 +00:00
|
|
|
{
|
|
|
|
send(player, messageComponent("guildNotOwner"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("off"))
|
|
|
|
{
|
|
|
|
guild.setPrefix(null);
|
|
|
|
send(player, messageComponent("guildPrefixCleared"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
guild.setPrefix(StringUtils.join(args, " "));
|
|
|
|
send(player, messageComponent("guildPrefixSet", SafeMiniMessage.mmDeserializeWithoutEvents(guild.getPrefix())));
|
2022-05-08 23:34:03 +00:00
|
|
|
}, () -> send(player, messageComponent("guildNotFound")));
|
2022-05-08 05:54:22 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|