From 5ad6403f8f7d4c97f6e9c08f62f44c82b8c946e0 Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Fri, 24 Jul 2020 15:13:13 -0400 Subject: [PATCH] /g roster [player] --- .../tfguilds/command/HelpSubcommand.java | 2 +- .../tfguilds/command/RosterSubcommand.java | 18 +++++++++++++++++- .../me/totalfreedom/tfguilds/guild/Guild.java | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java index 27a2719..14f722f 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java @@ -31,7 +31,7 @@ public class HelpSubcommand extends Common implements CommandExecutor sender.sendMessage(tl("%s% - %p%motd | clear>")); sender.sendMessage(tl("%s% - %p%home [set]")); 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 ")); return true; } diff --git a/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java index 1c8c6bb..6d45c93 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java @@ -4,6 +4,7 @@ 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.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -18,27 +19,42 @@ public class RosterSubcommand extends Common implements CommandExecutor { 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))); if (guild == null) { sender.sendMessage(ChatColor.RED + "That guild doesn't exist!"); return true; } + sender.sendMessage(guild.getRoster()); return true; } + if (sender instanceof ConsoleCommandSender) { sender.sendMessage(NO_PERMS); return true; } + Guild guild = Guild.getGuild((Player) sender); if (guild == null) { sender.sendMessage(ChatColor.RED + "You aren't in a guild!"); return true; } + sender.sendMessage(guild.getRoster()); return true; } -} +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java b/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java index 730bfa7..099f229 100644 --- a/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java +++ b/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java @@ -225,7 +225,7 @@ public class Guild 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%Moderators%p% - " + StringUtils.join(moderators, ", ") + "\n"; @@ -252,7 +252,7 @@ public class Guild public String getInformation() { 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%Moderators%p%: " + StringUtils.join(moderators, ", ") + "\n" + "%s%Members%p%: " + StringUtils.join(getOnlyMembers(), ", ") + "\n" +