diff --git a/src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java b/src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java index cc437b8..d15a1e9 100644 --- a/src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java +++ b/src/main/java/totalfreedom/tfguilds/command/CreateGuildCommand.java @@ -4,6 +4,7 @@ import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import totalfreedom.tfguilds.util.GBase; import totalfreedom.tfguilds.util.GUtil; @@ -26,17 +27,32 @@ public class CreateGuildCommand extends GBase implements CommandExecutor return true; } - // this stupid shit + ConfigurationSection guildMembers = plugin.guilds.getConfigurationSection("guilds"); - /* List members = plugin.guilds.getStringList("guilds." + args[0] + ".members"); - for (String players : members) + if (guildMembers != null) { - if (players.contains(player.getName())) + try { - player.sendMessage(ChatColor.RED + "You are already in a guild."); - return true; + for (String guild : guildMembers.getKeys(false)) + { + if (plugin.guilds.getString("guilds." + guild + ".members").contains(player.getName())) + { + player.sendMessage(ChatColor.RED + "You are already in a guild."); + return true; + } + + if (guild.equals(args[0])) + { + player.sendMessage(ChatColor.RED + "A guild with that name already exists."); + return true; + } + } } - } */ + catch (Exception e) + { + e.printStackTrace(); + } + } GUtil.createGuild(sender, args[0]); sender.sendMessage(ChatColor.GREEN + "Successfully created a guild named " + args[0]);