mirror of
https://github.com/plexusorg/Module-Guilds.git
synced 2025-07-04 00:16:41 +00:00
fix prefix sub command and add clearing guild prefixes
fix some issues with hover events in prefixes
This commit is contained in:
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.command.sub.CreateSubCommand;
|
||||
import dev.plex.command.sub.InfoSubCommand;
|
||||
import dev.plex.command.sub.PrefixSubCommand;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.GuildUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
@ -29,17 +30,15 @@ public class GuildCommand extends PlexCommand
|
||||
|
||||
public GuildCommand()
|
||||
{
|
||||
System.out.println("Aaa");
|
||||
PlexLog.log("Test");
|
||||
try
|
||||
{
|
||||
this.registerSubCommand(new CreateSubCommand());
|
||||
this.registerSubCommand(new InfoSubCommand());
|
||||
this.registerSubCommand(new PrefixSubCommand());
|
||||
} catch (Exception e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
}
|
||||
PlexLog.log("Registered");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
55
src/main/java/dev/plex/command/sub/PrefixSubCommand.java
Normal file
55
src/main/java/dev/plex/command/sub/PrefixSubCommand.java
Normal file
@ -0,0 +1,55 @@
|
||||
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;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "prefix", aliases = "tag,settag,setprefix", usage = "/guild <command> <prefix>")
|
||||
@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 -> {
|
||||
if (!guild.getOwner().equals(player.getUniqueId()))
|
||||
{
|
||||
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())));
|
||||
}, () -> send(player, messageComponent("alreadyInGuild")));
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user