add %rank% for guild tags

This commit is contained in:
speedxx 2020-08-08 14:19:40 -04:00
parent 8fd15988e0
commit da6471941e
7 changed files with 94 additions and 11 deletions

View file

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

View file

@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.guild.Guild;
import me.totalfreedom.tfguilds.util.GUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -41,6 +42,19 @@ public class CreateRankSubcommand extends Common implements CommandExecutor
}
String rank = StringUtils.join(args, " ", 1, args.length);
for (String blacklisted : GUtil.BLACKLISTED_NAMES_AND_TAGS)
{
if (rank.equalsIgnoreCase(blacklisted))
{
if (!plugin.bridge.isAdmin(player))
{
player.sendMessage(ChatColor.RED + "You may not use that name.");
return true;
}
}
}
if (guild.hasRank(rank))
{
sender.sendMessage(ChatColor.RED + "A rank of that name already exists in the guild!");

View file

@ -88,26 +88,66 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
switch (args[0])
{
case "home":
{
return Arrays.asList("set");
}
case "info":
case "join":
case "roster":
{
return Guild.getGuildList();
}
case "motd":
case "tag":
{
return Arrays.asList("set", "clear");
}
case "setstate":
{
return Arrays.asList("OPEN", "INVITE", "CLOSED");
}
case "invite":
{
return GUtil.getPlayerList();
}
case "deleterank":
return guild.getRankNames();
{
if (guild.getOwner().equals(sender.getName()))
{
return guild.getRankNames();
}
}
case "tp":
{
return guild.getMembers();
}
case "disband":
{
if (!plugin.bridge.isAdmin(sender))
{
return Collections.emptyList();
}
return Guild.getGuildList();
}
case "removemod":
case "addmod":
case "setowner":
case "kick":
return guild.getMembers();
{
if (guild.getOwner().equals(sender.getName()))
{
return guild.getMembers();
}
}
}
}
return Collections.emptyList();

View file

@ -1,5 +1,6 @@
package me.totalfreedom.tfguilds.command;
import java.util.UUID;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.util.GLog;
import org.bukkit.Bukkit;
@ -8,8 +9,6 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.UUID;
public class TFGuildsCommand extends Common implements CommandExecutor
{
@Override

View file

@ -69,7 +69,7 @@ public class TagSubcommand extends Common implements CommandExecutor
guild.setTag(tag);
guild.save();
sender.sendMessage(tl("%p%Your guild tag has been changed to be \"" + GUtil.colorize(tag) + "%p%\"."));
sender.sendMessage(tl("%p%Your guild tag has been changed to be \"" + GUtil.colorize(tag).replace("%rank%", ChatColor.GOLD +"Guild Owner") + "%p%\"."));
return true;
}
return false;

View file

@ -1,5 +1,8 @@
package me.totalfreedom.tfguilds.guild;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.tfguilds.TFGuilds;
@ -15,10 +18,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Guild
{
private static TFGuilds plugin = TFGuilds.getPlugin();

View file

@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds.listener;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.guild.Guild;
import me.totalfreedom.tfguilds.guild.GuildRank;
import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -22,6 +23,36 @@ public class ChatListener implements Listener
return;
}
GuildRank rank = null;
for (GuildRank r : guild.getRanks())
{
if (r.getMembers().contains(player.getName()))
{
rank = r;
}
}
String display;
if (rank == null)
{
if (guild.getOwner().equals(player.getName()))
{
display = "Guild Owner";
}
else if (guild.hasModerator(player.getName()))
{
display = "Guild Moderator";
}
else
{
display = "Guild Member";
}
}
else
{
display = rank.getName();
}
if (Common.IN_GUILD_CHAT.contains(player))
{
guild.chat(player.getName(), e.getMessage());
@ -31,7 +62,7 @@ public class ChatListener implements Listener
if (guild.hasTag())
{
e.setFormat(GUtil.colorize(guild.getTag()) + ChatColor.RESET + " " + e.getFormat());
e.setFormat(GUtil.colorize(guild.getTag().replace("%rank%", display)) + ChatColor.RESET + " " + e.getFormat());
}
}
}