mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 16:05:00 +00:00
add %rank% for guild tags
This commit is contained in:
parent
8fd15988e0
commit
da6471941e
7 changed files with 94 additions and 11 deletions
2
pom.xml
2
pom.xml
|
@ -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>
|
||||
|
|
|
@ -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!");
|
||||
|
|
|
@ -88,28 +88,68 @@ 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":
|
||||
{
|
||||
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":
|
||||
{
|
||||
if (guild.getOwner().equals(sender.getName()))
|
||||
{
|
||||
return guild.getMembers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue