/g roster [player]

This commit is contained in:
speedxx 2020-07-24 15:13:13 -04:00
parent d6a0407e89
commit 5ad6403f8f
3 changed files with 20 additions and 4 deletions

View file

@ -31,7 +31,7 @@ public class HelpSubcommand extends Common implements CommandExecutor
sender.sendMessage(tl("%s% - %p%motd <set <motd> | clear>")); sender.sendMessage(tl("%s% - %p%motd <set <motd> | clear>"));
sender.sendMessage(tl("%s% - %p%home [set]")); sender.sendMessage(tl("%s% - %p%home [set]"));
sender.sendMessage(tl("%s% - %p%chat [message]")); sender.sendMessage(tl("%s% - %p%chat [message]"));
sender.sendMessage(tl("%s% - %p%roster [guild]")); sender.sendMessage(tl("%s% - %p%roster [guild | player]"));
sender.sendMessage(tl("%s% - %p%setstate <open | invite | closed>")); sender.sendMessage(tl("%s% - %p%setstate <open | invite | closed>"));
return true; return true;
} }

View file

@ -4,6 +4,7 @@ import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.guild.Guild; import me.totalfreedom.tfguilds.guild.Guild;
import me.totalfreedom.tfguilds.util.GUtil; import me.totalfreedom.tfguilds.util.GUtil;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
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;
@ -18,26 +19,41 @@ public class RosterSubcommand extends Common implements CommandExecutor
{ {
if (args.length >= 2) if (args.length >= 2)
{ {
Player player = Bukkit.getPlayer(args[1]);
if (player != null)
{
Guild guild = Guild.getGuild(player);
if (guild != null)
{
sender.sendMessage(guild.getRoster());
return true;
}
}
Guild guild = Guild.getGuild(GUtil.flatten(StringUtils.join(args, " ", 1, args.length))); Guild guild = Guild.getGuild(GUtil.flatten(StringUtils.join(args, " ", 1, args.length)));
if (guild == null) if (guild == null)
{ {
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!"); sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
return true; return true;
} }
sender.sendMessage(guild.getRoster()); sender.sendMessage(guild.getRoster());
return true; return true;
} }
if (sender instanceof ConsoleCommandSender) if (sender instanceof ConsoleCommandSender)
{ {
sender.sendMessage(NO_PERMS); sender.sendMessage(NO_PERMS);
return true; return true;
} }
Guild guild = Guild.getGuild((Player) sender); Guild guild = Guild.getGuild((Player) sender);
if (guild == null) if (guild == null)
{ {
sender.sendMessage(ChatColor.RED + "You aren't in a guild!"); sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
return true; return true;
} }
sender.sendMessage(guild.getRoster()); sender.sendMessage(guild.getRoster());
return true; return true;
} }

View file

@ -225,7 +225,7 @@ public class Guild
public String getRoster() public String getRoster()
{ {
String list = Common.PREFIX + "Guild Roster\n" + String list = Common.PREFIX + "Guild Roster for " + name + "\n" +
"%s%Owner%p% - " + owner + "\n" + "%s%Owner%p% - " + owner + "\n" +
"%s%Moderators%p% - " + StringUtils.join(moderators, ", ") + "\n"; "%s%Moderators%p% - " + StringUtils.join(moderators, ", ") + "\n";
@ -252,7 +252,7 @@ public class Guild
public String getInformation() public String getInformation()
{ {
return Common.tl(Common.PREFIX + "Guild Information\n" + return Common.tl(Common.PREFIX + "Guild Information\n" +
"%s%Name%p%: " + GUtil.colorize(name) + "\n" + "%s%Name%p%: " + name + "\n" +
"%s%Owner%p%: " + owner + "\n" + "%s%Owner%p%: " + owner + "\n" +
"%s%Moderators%p%: " + StringUtils.join(moderators, ", ") + "\n" + "%s%Moderators%p%: " + StringUtils.join(moderators, ", ") + "\n" +
"%s%Members%p%: " + StringUtils.join(getOnlyMembers(), ", ") + "\n" + "%s%Members%p%: " + StringUtils.join(getOnlyMembers(), ", ") + "\n" +