From 6e174a3f06aa3eae44c544f5aaadef5434c1e19d Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Wed, 1 Jul 2020 20:31:07 -0400 Subject: [PATCH] fix guild tags - fix guild tags not showing - limit guild names to 24 characters - allow guild tag spacing instead of guild name spacing --- TFGuilds.iml | 32 +++++++++++++++++++ pom.xml | 2 +- .../tfguilds/command/CreateGuildCommand.java | 6 ++++ .../tfguilds/command/GuildTagCommand.java | 29 ++++++++--------- .../tfguilds/command/TfGuildsCommand.java | 2 +- .../tfguilds/listener/ChatManager.java | 7 ++-- 6 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 TFGuilds.iml diff --git a/TFGuilds.iml b/TFGuilds.iml new file mode 100644 index 0000000..0ceb4cd --- /dev/null +++ b/TFGuilds.iml @@ -0,0 +1,32 @@ + + + + + + + SPIGOT + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index ec5586f..0364124 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.totalfreedom TFGuilds - 0.1.6 + 0.1.7 jar TFGuilds diff --git a/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java index 5a7753c..862f647 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/CreateGuildCommand.java @@ -48,6 +48,12 @@ public class CreateGuildCommand extends GBase implements CommandExecutor player.sendMessage(ChatColor.RED + "A guild with that name already exists."); return true; } + + if (args[0].length() > 24) + { + player.sendMessage(ChatColor.RED + "Guild name must not be over 24 characters."); + return true; + } } } catch (Exception e) diff --git a/src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java index c938f5b..e2aaba4 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildTagCommand.java @@ -3,6 +3,7 @@ package me.totalfreedom.tfguilds.command; import me.totalfreedom.tfguilds.util.GBase; import me.totalfreedom.tfguilds.util.GMessage; import me.totalfreedom.tfguilds.util.GUtil; +import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -14,11 +15,6 @@ public class GuildTagCommand extends GBase implements CommandExecutor @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (args.length == 0 || args.length > 2) - { - return false; - } - if (GUtil.isConsole(sender)) { sender.sendMessage(GMessage.PLAYER_ONLY); @@ -41,29 +37,32 @@ public class GuildTagCommand extends GBase implements CommandExecutor return true; } - if (args.length == 2) + if (args.length >= 2) { + String tag = StringUtils.join(args, " ", 1, args.length); if (args[0].equalsIgnoreCase("set")) { - if (!args[1].toLowerCase().contains(guild)) + if (!tag.contains(guild)) { player.sendMessage(ChatColor.RED + "Your guild tag must contain your guild name."); return true; } - GUtil.setTag(GUtil.color(args[1]) + " ", guild); - player.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(args[1]) + ChatColor.GREEN + "\""); + GUtil.setTag(GUtil.color(tag) + " ", guild); + player.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(tag) + ChatColor.GREEN + "\""); return true; } - return false; } - if (!args[0].equalsIgnoreCase("clear")) + if (args.length == 1) { - return false; + if (args[0].equalsIgnoreCase("clear")) + { + GUtil.setTag(GUtil.color("&8[&7" + guild + "&8]&r "), guild); + player.sendMessage(ChatColor.GRAY + "Removed your guild's tag."); + return true; + } } - GUtil.setTag(GUtil.color("&8[&7" + guild + "&8]&r "), guild); - player.sendMessage(ChatColor.GRAY + "Removed your guild's tag."); - return true; + return false; } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java index df445b6..75e1710 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/TfGuildsCommand.java @@ -21,7 +21,7 @@ public class TfGuildsCommand extends GBase implements CommandExecutor sender.sendMessage(GUtil.color("&2Developed by &aspeednt")); sender.sendMessage(GUtil.color("&2Contributors")); sender.sendMessage(GUtil.color("&a- supernt")); - sender.sendMessage(GUtil.color("&2https://github.com/speedxx/TFGuilds")); + sender.sendMessage(GUtil.color("&2https://github.com/TFPatches/TFGuilds")); return true; } diff --git a/src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java b/src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java index 27f786a..32edeb3 100644 --- a/src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java +++ b/src/main/java/me/totalfreedom/tfguilds/listener/ChatManager.java @@ -5,6 +5,7 @@ import me.totalfreedom.tfguilds.util.GUtil; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; @@ -16,13 +17,15 @@ public class ChatManager implements Listener this.plugin = TFGuilds.plugin; } - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerChat(AsyncPlayerChatEvent e) { Player player = e.getPlayer(); String guild = GUtil.getGuild(player); if (guild == null) + { return; - e.setFormat(GUtil.color(GUtil.getTag(guild)) + " " + ChatColor.RESET + e.getFormat()); + } + e.setFormat(GUtil.color(GUtil.getTag(guild)) + ChatColor.RESET + e.getFormat()); } } \ No newline at end of file