diff --git a/TFGuilds.iml b/TFGuilds.iml
index 391e646..6e3d2a4 100644
--- a/TFGuilds.iml
+++ b/TFGuilds.iml
@@ -27,7 +27,7 @@
-
+
diff --git a/pom.xml b/pom.xml
index c61db63..526aea5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.totalfreedom
TFGuilds
- 0.2.1
+ 0.2.3
jar
TFGuilds
@@ -81,4 +81,4 @@
development-SNAPSHOT
-
+
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java
index b8a8437..41c21f0 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/CreateSubcommand.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;
@@ -11,31 +12,65 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
public class CreateSubcommand extends Common implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
+ List BLACKLISTED_NAMES = Arrays.asList(
+ "admin", "owner", "moderator", "developer", "console", "dev", "staff", "mod", "sra", "tca", "sta", "sa");
+
if (sender instanceof ConsoleCommandSender)
{
sender.sendMessage(NO_PERMS);
return true;
}
+
Player player = (Player) sender;
String name = StringUtils.join(args, " ", 1, args.length);
String identifier = GUtil.flatten(name);
+
if (Guild.isInGuild(player))
{
sender.sendMessage(ChatColor.RED + "You are already in a guild!");
return true;
}
+
+ Pattern pattern = Pattern.compile("^[A-Za-z0-9? ,_-]+$");
+ Matcher matcher = pattern.matcher(name);
+
+ if (!matcher.matches())
+ {
+ sender.sendMessage(ChatColor.RED + "Guild names must be alphanumeric.");
+ return true;
+ }
+
if (Guild.guildExists(identifier))
{
sender.sendMessage(ChatColor.RED + "A guild with a name similar to yours already exists!");
return true;
}
+
+ for (String blacklisted : BLACKLISTED_NAMES)
+ {
+ if (args[0].equalsIgnoreCase(blacklisted))
+ {
+ if (!plugin.bridge.isAdmin(player))
+ {
+ player.sendMessage(ChatColor.RED + "You may not use that name.");
+ return true;
+ }
+ }
+ }
+
Guild.createGuild(identifier, name, player);
sender.sendMessage(tl(PREFIX + "Created a guild named \"" + GUtil.colorize(name) + "%p%\"!"));
+ Bukkit.broadcastMessage(GUtil.colorize("&a" + sender.getName() + " has created guild &a&l" + name));
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/DisbandSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/DisbandSubcommand.java
index 4865e6c..a7b032e 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/DisbandSubcommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/DisbandSubcommand.java
@@ -2,7 +2,9 @@ package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.guild.Guild;
+import me.totalfreedom.tfguilds.util.GLog;
import me.totalfreedom.tfguilds.util.GUtil;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -22,36 +24,47 @@ public class DisbandSubcommand extends Common implements CommandExecutor
sender.sendMessage(NO_PERMS);
return true;
}
+
Guild guild = Guild.getGuild(args[1]);
if (guild == null)
{
sender.sendMessage(ChatColor.RED + "That guild doesn't exist!");
return true;
}
+
String n = guild.getName();
+ GLog.info("Removing guilds.yml data for " + n);
guild.disband();
+ GLog.info(sender.getName() + " deleted guild " + guild.getName());
sender.sendMessage(tl(PREFIX + "Disbanded \"" + GUtil.colorize(n) + "%p%\"."));
return true;
}
+
if (sender instanceof ConsoleCommandSender)
{
sender.sendMessage(NO_PERMS);
return true;
}
+
Player player = (Player) sender;
if (!Guild.isInGuild(player))
{
sender.sendMessage(ChatColor.RED + "You aren't in a guild!");
return true;
}
+
Guild guild = Guild.getGuild(player);
if (!guild.getOwner().equals(player.getName()))
{
sender.sendMessage(ChatColor.RED + "You are not the owner of this guild!");
return true;
}
+
+ GLog.info("Removing guilds.yml data for " + guild.getName());
guild.disband();
+ GLog.info(player.getName() + " deleted guild " + guild.getName());
sender.sendMessage(tl(PREFIX + "You have disbanded your guild!"));
+ Bukkit.broadcastMessage(GUtil.colorize("&c&l" + guild.getName() + "&c has been disbanded"));
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java
index 3b3ffcf..3f4f946 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/GuildCommand.java
@@ -29,7 +29,6 @@ public class GuildCommand extends Common implements CommandExecutor
case "info": return new InfoSubcommand().onCommand(sender, command, label, args);
case "tag": return new TagSubcommand().onCommand(sender, command, label, args);
case "chat": return new ChatSubcommand().onCommand(sender, command, label, args);
- case "saveconfig": return new SaveConfigSubcommand().onCommand(sender, command, label, args);
case "join": return new JoinSubcommand().onCommand(sender, command, label, args);
case "rename": return new RenameSubcommand().onCommand(sender, command, label, args);
case "createrank": return new CreateRankSubcommand().onCommand(sender, command, label, args);
@@ -37,6 +36,7 @@ public class GuildCommand extends Common implements CommandExecutor
case "setrank": return new SetRankSubcommand().onCommand(sender, command, label, args);
case "motd": return new MOTDSubcommand().onCommand(sender, command, label, args);
case "home": return new HomeSubcommand().onCommand(sender, command, label, args);
+ case "roster": return new RosterSubcommand().onCommand(sender, command, label, args);
}
return false;
}
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java
index dc4dbfd..9e70f63 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/HelpSubcommand.java
@@ -11,7 +11,7 @@ public class HelpSubcommand extends Common implements CommandExecutor
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
sender.sendMessage(tl("%s%[%p%TFGuilds%s%] %p%Command List"));
- sender.sendMessage(tl("%s% - %p%list [guild]"));
+ sender.sendMessage(tl("%s% - %p%list"));
sender.sendMessage(tl("%s% - %p%help"));
sender.sendMessage(tl("%s% - %p%create "));
sender.sendMessage(tl("%s% - %p%disband [name]"));
@@ -31,6 +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]"));
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/ListSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/ListSubcommand.java
index 24a7e92..2b3bf1e 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/ListSubcommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/ListSubcommand.java
@@ -2,43 +2,29 @@ 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;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
+
+import java.util.List;
public class ListSubcommand extends Common implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
- if (args.length >= 2)
+ List guilds = Guild.getGuildList();
+
+ if (guilds.isEmpty())
{
- 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.getList());
+ sender.sendMessage(ChatColor.RED + "Nobody has made a guild yet.");
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.getList());
+
+ sender.sendMessage(tl(PREFIX + "%s%Guild List (%p%" + guilds.size() + " total%s%)"));
+ sender.sendMessage(tl("%s%- %p%" + StringUtils.join(guilds, ",\n%s%- %p%")));
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java
new file mode 100644
index 0000000..1c8c6bb
--- /dev/null
+++ b/src/main/java/me/totalfreedom/tfguilds/command/RosterSubcommand.java
@@ -0,0 +1,44 @@
+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;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.entity.Player;
+
+public class RosterSubcommand extends Common implements CommandExecutor
+{
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
+ {
+ if (args.length >= 2)
+ {
+ 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;
+ }
+}
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/SaveConfigSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/SaveConfigSubcommand.java
deleted file mode 100644
index 661baae..0000000
--- a/src/main/java/me/totalfreedom/tfguilds/command/SaveConfigSubcommand.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package me.totalfreedom.tfguilds.command;
-
-import me.totalfreedom.tfguilds.Common;
-import me.totalfreedom.tfguilds.guild.Guild;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
-
-public class SaveConfigSubcommand extends Common implements CommandExecutor
-{
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
- {
- if (args.length != 1)
- return false;
- if (!plugin.bridge.isAdmin(sender))
- {
- sender.sendMessage(NO_PERMS);
- return true;
- }
- plugin.config.load();
- plugin.guilds.load();
- plugin.config.save();
- plugin.guilds.save();
- sender.sendMessage(tl(PREFIX + "Saved all configuration files in their current state."));
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/TFGuildsCommand.java b/src/main/java/me/totalfreedom/tfguilds/command/TFGuildsCommand.java
index 38a6a41..ef8c2a9 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/TFGuildsCommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/TFGuildsCommand.java
@@ -1,26 +1,46 @@
package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.Common;
-import me.totalfreedom.tfguilds.guild.Guild;
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.ChatColor;
+import me.totalfreedom.tfguilds.util.GLog;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
public class TFGuildsCommand extends Common implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
- if (args.length != 0)
- return false;
- sender.sendMessage(tl(PREFIX + "Plugin Information"));
- sender.sendMessage(tl("%s%Programmers%p%: speed and super"));
- sender.sendMessage(tl("%s%Version%p%: " + plugin.getDescription().getVersion()));
- sender.sendMessage(tl("%s%Special Thanks%p%: ron (testing)"));
- return true;
+ if (args.length == 0)
+ {
+ sender.sendMessage(tl("%p%TFGuilds %s%is a plugin which allows for players to make their own guilds, providing guild chat, guild teleportation, and more."));
+ sender.sendMessage(tl("%s%Version %p%v" + plugin.getDescription().getVersion()));
+ sender.sendMessage(tl("%s%Developed by %p%speednt & supernt"));
+ sender.sendMessage(tl("%s%https://github.com/TFPatches/TFGuilds"));
+ return true;
+ }
+
+ if (args[0].toLowerCase().equals("reload"))
+ {
+ if (!plugin.bridge.isAdmin(sender))
+ {
+ sender.sendMessage(NO_PERMS);
+ return true;
+ }
+ try
+ {
+ plugin.config.load();
+ plugin.guilds.load();
+ GLog.info("All configs reloaded successfully");
+ sender.sendMessage(tl(PREFIX + "All configuration files have been reloaded successfully."));
+ return true;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return true;
+ }
+ return false;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java b/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java
index 86de36c..1a25c1e 100644
--- a/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java
+++ b/src/main/java/me/totalfreedom/tfguilds/command/TagSubcommand.java
@@ -38,6 +38,14 @@ public class TagSubcommand extends Common implements CommandExecutor
if (args[1].toLowerCase().equals("set"))
{
String tag = StringUtils.join(args, " ", 2, args.length);
+ if (!tag.contains("%tag%"))
+ {
+ sender.sendMessage(ChatColor.RED + "You must have your guild name in your tag. Use %tag% to specify where you want your tag");
+ return true;
+ }
+
+ tag = tag.replace("%tag%", guild.getName());
+
guild.setTag(tag);
guild.save();
sender.sendMessage(tl("%p%Your guild tag has been changed to be \"" + GUtil.colorize(tag) + "%p%\"."));
diff --git a/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java b/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java
index 48ed3fb..bc084fe 100644
--- a/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java
+++ b/src/main/java/me/totalfreedom/tfguilds/guild/Guild.java
@@ -4,6 +4,7 @@ import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.tfguilds.TFGuilds;
import me.totalfreedom.tfguilds.Common;
+import me.totalfreedom.tfguilds.util.GLog;
import me.totalfreedom.tfguilds.util.GUtil;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
@@ -222,7 +223,7 @@ public class Guild
return names;
}
- public String getList()
+ public String getRoster()
{
String list = Common.PREFIX + "Guild Roster\n" +
"%s%Owner%p% - " + owner + "\n" +
@@ -237,6 +238,17 @@ public class Guild
"%s%Members%p% - " + StringUtils.join(getOnlyMembers(), ", "));
}
+ public static List getGuildList()
+ {
+ List g = new ArrayList<>();
+ for (String key : plugin.guilds.getKeys(false))
+ {
+ Guild guild = getGuild(key);
+ g.add(guild.getName());
+ }
+ return g;
+ }
+
public String getInformation()
{
return Common.tl(Common.PREFIX + "Guild Information\n" +
@@ -254,6 +266,7 @@ public class Guild
public void chat(String as, String msg)
{
broadcast(Common.tl("%s%[%p%Guild Chat %s%| %p%" + GUtil.colorize(name) + "%s%] %p%" + as + ChatColor.WHITE + ": %p%" + msg));
+ GLog.info(Common.tl("%s%[%p%Guild Chat %s%| %p%" + GUtil.colorize(name) + "%s%] %p%" + as + ChatColor.WHITE + ": %p%" + msg));
}
public void disband()
@@ -278,13 +291,14 @@ public class Guild
owner.getName(),
Collections.singletonList(owner.getName()),
new ArrayList<>(),
- null,
+ ChatColor.DARK_GRAY + "[" + ChatColor.GRAY + name + ChatColor.DARK_GRAY + "]",
GuildState.INVITE_ONLY,
new ArrayList<>(),
null,
null,
System.currentTimeMillis());
guild.save();
+ GLog.info(owner.getName() + " has created guild " + name);
return guild;
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index e778443..a0d0462 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -13,7 +13,7 @@ commands:
guildchat:
description: Talk in chat with your guild.
usage: / [message]
- aliases: [gchat, gc]
+ aliases: [gchat]
tfguilds:
description: Information about the plugin.
usage: /