fix guild tags

- fix guild tags not showing
- limit guild names to 24 characters
- allow guild tag spacing instead of guild name spacing
This commit is contained in:
speedxx 2020-07-01 20:31:07 -04:00
parent dd045c06e3
commit 6e174a3f06
6 changed files with 59 additions and 19 deletions

32
TFGuilds.iml Normal file
View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TotalFreedomMod:5.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
</component>
</module>

View file

@ -6,7 +6,7 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TFGuilds</artifactId> <artifactId>TFGuilds</artifactId>
<version>0.1.6</version> <version>0.1.7</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>TFGuilds</name> <name>TFGuilds</name>

View file

@ -48,6 +48,12 @@ public class CreateGuildCommand extends GBase implements CommandExecutor
player.sendMessage(ChatColor.RED + "A guild with that name already exists."); player.sendMessage(ChatColor.RED + "A guild with that name already exists.");
return true; return true;
} }
if (args[0].length() > 24)
{
player.sendMessage(ChatColor.RED + "Guild name must not be over 24 characters.");
return true;
}
} }
} }
catch (Exception e) catch (Exception e)

View file

@ -3,6 +3,7 @@ package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.util.GBase; import me.totalfreedom.tfguilds.util.GBase;
import me.totalfreedom.tfguilds.util.GMessage; import me.totalfreedom.tfguilds.util.GMessage;
import me.totalfreedom.tfguilds.util.GUtil; import me.totalfreedom.tfguilds.util.GUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -14,11 +15,6 @@ public class GuildTagCommand extends GBase implements CommandExecutor
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{ {
if (args.length == 0 || args.length > 2)
{
return false;
}
if (GUtil.isConsole(sender)) if (GUtil.isConsole(sender))
{ {
sender.sendMessage(GMessage.PLAYER_ONLY); sender.sendMessage(GMessage.PLAYER_ONLY);
@ -41,29 +37,32 @@ public class GuildTagCommand extends GBase implements CommandExecutor
return true; 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[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."); player.sendMessage(ChatColor.RED + "Your guild tag must contain your guild name.");
return true; return true;
} }
GUtil.setTag(GUtil.color(args[1]) + " ", guild); GUtil.setTag(GUtil.color(tag) + " ", guild);
player.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(args[1]) + ChatColor.GREEN + "\""); player.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(tag) + ChatColor.GREEN + "\"");
return true; 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); return false;
player.sendMessage(ChatColor.GRAY + "Removed your guild's tag.");
return true;
} }
} }

View file

@ -21,7 +21,7 @@ public class TfGuildsCommand extends GBase implements CommandExecutor
sender.sendMessage(GUtil.color("&2Developed by &aspeednt")); sender.sendMessage(GUtil.color("&2Developed by &aspeednt"));
sender.sendMessage(GUtil.color("&2Contributors")); sender.sendMessage(GUtil.color("&2Contributors"));
sender.sendMessage(GUtil.color("&a- supernt")); 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; return true;
} }

View file

@ -5,6 +5,7 @@ import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -16,13 +17,15 @@ public class ChatManager implements Listener
this.plugin = TFGuilds.plugin; this.plugin = TFGuilds.plugin;
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent e) public void onPlayerChat(AsyncPlayerChatEvent e)
{ {
Player player = e.getPlayer(); Player player = e.getPlayer();
String guild = GUtil.getGuild(player); String guild = GUtil.getGuild(player);
if (guild == null) if (guild == null)
{
return; return;
e.setFormat(GUtil.color(GUtil.getTag(guild)) + " " + ChatColor.RESET + e.getFormat()); }
e.setFormat(GUtil.color(GUtil.getTag(guild)) + ChatColor.RESET + e.getFormat());
} }
} }