From 87e591abc117500c1fd85e2f3bbb86aae8659d62 Mon Sep 17 00:00:00 2001 From: speedxx <43330808+speedxx@users.noreply.github.com> Date: Mon, 22 Jun 2020 17:48:42 -0400 Subject: [PATCH] get other guilds --- .../tfguilds/command/GuildInfoCommand.java | 32 +++++++++++++++++-- .../me/totalfreedom/tfguilds/util/GUtil.java | 28 ++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/totalfreedom/tfguilds/command/GuildInfoCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildInfoCommand.java index 918faeb..e89cf0d 100644 --- a/src/main/java/me/totalfreedom/tfguilds/command/GuildInfoCommand.java +++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildInfoCommand.java @@ -16,11 +16,37 @@ public class GuildInfoCommand extends GBase implements CommandExecutor public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player player = (Player) sender; - String guild = GUtil.getGuild(player); + if (args.length == 0) + { + String guild = GUtil.getGuild(player); + + if (guild == null) + { + sender.sendMessage(ChatColor.RED + "You aren't in a guild!"); + return true; + } + + String owner = GUtil.getOwner(guild); + String tag = GUtil.getTag(guild); + String creation = GUtil.getTimeCreated(guild); + List members = GUtil.getMember(guild); + + player.sendMessage(GUtil.color("&2-=-=-=- &aGuild Information &2-=-=-=-")); + player.sendMessage(GUtil.color("&2Guild Name: &a" + guild)); + player.sendMessage(GUtil.color("&2Guild Owner: &a" + owner)); + player.sendMessage(GUtil.color("&2Guild Tag: &a" + tag)); + player.sendMessage(GUtil.color("&2Guild Creation Date: &a" + creation)); + player.sendMessage(GUtil.color("&2Member Count: &a" + members.size())); + player.sendMessage(GUtil.color("&2Members: &a" + members)); + player.sendMessage(GUtil.color("&2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")); + return true; + } + + String guild = GUtil.getGuild(args[0]); if (guild == null) { - sender.sendMessage(ChatColor.RED + "You aren't in a guild!"); + sender.sendMessage(ChatColor.RED + "Guild not found."); return true; } @@ -36,7 +62,7 @@ public class GuildInfoCommand extends GBase implements CommandExecutor player.sendMessage(GUtil.color("&2Guild Creation Date: &a" + creation)); player.sendMessage(GUtil.color("&2Member Count: &a" + members.size())); player.sendMessage(GUtil.color("&2Members: &a" + members)); - player.sendMessage(GUtil.color("&2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")); + player.sendMessage(GUtil.color("&2-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")); return true; } } \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java b/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java index dd68891..97b0523 100644 --- a/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java +++ b/src/main/java/me/totalfreedom/tfguilds/util/GUtil.java @@ -119,6 +119,34 @@ public class GUtil return g; } + public static String getGuild(String arg) + { + String g = ""; + boolean a = false; + ConfigurationSection guildMembers = plugin.guilds.getConfigurationSection("guilds"); + if (guildMembers != null) + { + try + { + for (String guild : guildMembers.getKeys(false)) + { + if (guild.equals(arg)) + { + a = true; + g = guild; + } + } + } + catch (Exception e) + { + e.fillInStackTrace(); + } + } + if (!a) + return null; + return g; + } + public static String getOwner(String guildName) { return plugin.guilds.getString("guilds." + guildName + ".owner");