From f4ba215e6c84c7af4389328d261d480215437864 Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Wed, 26 Aug 2020 18:48:48 -0400 Subject: [PATCH] allow staff to toggle personal player tags change a few naming limits too since they were way too high --- .../command/CreateRankSubcommand.java | 6 +++ .../tfguilds/command/CreateSubcommand.java | 4 +- .../tfguilds/command/GuildCommand.java | 10 +++++ .../tfguilds/command/HelpSubcommand.java | 2 +- .../tfguilds/command/RenameSubcommand.java | 6 +++ .../tfguilds/command/TagSubcommand.java | 4 +- .../tfguilds/command/ToggleTagSubcommand.java | 38 +++++++++++++++++++ 7 files changed, 65 insertions(+), 5 deletions(-) diff --git a/src/main/java/me/totalfreedom/tfguilds/command/CreateRankSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/CreateRankSubcommand.java index c1f0bc5..97eb2b9 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/CreateRankSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/CreateRankSubcommand.java @@ -56,6 +56,12 @@ public class CreateRankSubcommand extends Common implements CommandExecutor } } + if (rank.length() > 15) + { + sender.sendMessage(ChatColor.RED + "Guild rank names may not be over 15 characters."); + return true; + } + if (guild.hasRank(rank)) { sender.sendMessage(ChatColor.RED + "A rank of that name already exists in the guild!"); diff --git a/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java index f0307a9..7e41555 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java @@ -51,9 +51,9 @@ public class CreateSubcommand extends Common implements CommandExecutor return true; } - if (name.length() > 64) + if (name.length() > 30) { - sender.sendMessage(ChatColor.RED + "Your guild name may not be over 64 characters."); + sender.sendMessage(ChatColor.RED + "Your guild name may not be over 30 characters."); return true; } diff --git a/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java index c116f54..294b329 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java @@ -107,6 +107,16 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete return Guild.getGuildList(); } + case "toggletag": + { + if (!plugin.bridge.isAdmin(sender)) + { + return Collections.emptyList(); + } + + return GUtil.getPlayerList(); + } + case "motd": case "tag": { diff --git a/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java index f60028b..a2918b3 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java @@ -36,7 +36,7 @@ public class HelpSubcommand extends Common implements CommandExecutor sender.sendMessage(tl("%s% - %p%setstate ")); sender.sendMessage(tl("%s% - %p%setdefaultrank ")); sender.sendMessage(tl("%s% - %p%toggletags")); - sender.sendMessage(tl("%s% - %p%toggletag")); + sender.sendMessage(tl("%s% - %p%toggletag [player]")); return true; } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/tfguilds/command/RenameSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/RenameSubcommand.java index f6c31ee..29137b8 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/RenameSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/RenameSubcommand.java @@ -56,6 +56,12 @@ public class RenameSubcommand extends Common implements CommandExecutor return true; } + if (identifier.length() > 30) + { + sender.sendMessage(ChatColor.RED + "Your new guild name may not be over 30 characters."); + return true; + } + if (Guild.guildExists(identifier)) { sender.sendMessage(ChatColor.RED + "A guild with a name similar to yours already exists!"); diff --git a/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java index ee005e4..e594f2a 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java @@ -50,9 +50,9 @@ public class TagSubcommand extends Common implements CommandExecutor tag = tag.replace("%tag%", guild.getName()); - if (tag.length() > 75) + if (tag.length() > 30) { - player.sendMessage(ChatColor.RED + "Your guild tag must not be over 75 characters."); + player.sendMessage(ChatColor.RED + "Your guild tag must not be over 30 characters."); return true; } diff --git a/src/main/java/me/totalfreedom/tfguilds/command/ToggleTagSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/ToggleTagSubcommand.java index 8b3990d..222352a 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/ToggleTagSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/ToggleTagSubcommand.java @@ -2,6 +2,8 @@ package me.totalfreedom.tfguilds.command; import me.totalfreedom.tfguilds.Common; import me.totalfreedom.tfguilds.guild.Guild; +import me.totalfreedom.tfguilds.util.GUtil; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -14,6 +16,42 @@ public class ToggleTagSubcommand extends Common implements CommandExecutor @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (args.length > 2) + { + sender.sendMessage(tl(PREFIX + "Proper usage: /g toggletag [player]")); + return true; + } + + if (args.length == 2) + { + if (!plugin.bridge.isAdmin(sender)) + { + sender.sendMessage(NO_PERMS); + return true; + } + + Player player = Bukkit.getPlayer(args[1]); + if (player == null) + { + sender.sendMessage(PNF); + return true; + } + + boolean enabled = plugin.players.getBoolean(player.getName() + ".tag"); + if (!plugin.players.contains(player.getName()) || enabled) + { + plugin.players.set(player.getName() + ".tag", false); + plugin.players.save(); + sender.sendMessage(tl(PREFIX + "Disabled personal guild tag for " + player.getName() + ".")); + return true; + } + + plugin.players.set(player.getName() + ".tag", true); + plugin.players.save(); + sender.sendMessage(tl(PREFIX + "Enabled personal guild tag for " + player.getName() + ".")); + return true; + } + if (sender instanceof ConsoleCommandSender) { sender.sendMessage(NO_PERMS);