mirror of
https://github.com/TotalFreedomMC/TFGuilds.git
synced 2024-12-22 07:55:03 +00:00
Remaining tickets completed
FS-96, FS-270, FS-271, FS-272, FS-282 and FS-303 are included in this commit
This commit is contained in:
parent
8263e8b20f
commit
b0f4017cde
17 changed files with 441 additions and 82 deletions
|
@ -111,5 +111,8 @@ public class TFGuilds extends JavaPlugin
|
||||||
subCommands.put("tag", new TagSubCommand());
|
subCommands.put("tag", new TagSubCommand());
|
||||||
subCommands.put("list", new ListSubCommand());
|
subCommands.put("list", new ListSubCommand());
|
||||||
subCommands.put("help", new HelpSubCommand());
|
subCommands.put("help", new HelpSubCommand());
|
||||||
|
subCommands.put("mchat", new ModChatSubCommand());
|
||||||
|
subCommands.put("notag", new NoTagSubCommand());
|
||||||
|
subCommands.put("togglechat", new ToggleChatSubCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
@ -61,4 +62,22 @@ public class TFMBridge
|
||||||
}
|
}
|
||||||
return getTfm().al.isVanished(player.getName());
|
return getTfm().al.isVanished(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTag(Player player)
|
||||||
|
{
|
||||||
|
if (getTfm() == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ChatColor.stripColor(getTfm().pl.getPlayer(player).getTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearTag(Player player)
|
||||||
|
{
|
||||||
|
if (getTfm() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getTfm().pl.getPlayer(player).setTag(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ChatSubCommand extends Common implements SubCommand
|
||||||
if (args.length >= 2)
|
if (args.length >= 2)
|
||||||
{
|
{
|
||||||
String message = StringUtils.join(args, " ", 1, args.length);
|
String message = StringUtils.join(args, " ", 1, args.length);
|
||||||
guild.chat(playerSender, message);
|
guild.chat(playerSender, message, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
import me.totalfreedom.tfguilds.Common;
|
import me.totalfreedom.tfguilds.Common;
|
||||||
import me.totalfreedom.tfguilds.guild.Guild;
|
import me.totalfreedom.tfguilds.guild.Guild;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -27,7 +28,7 @@ public class DisbandSubCommand extends Common implements SubCommand
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Guild guild = Guild.getGuild(playerSender);
|
Guild guild = Guild.getGuild(StringUtils.join(args, " ", 1, args.length));
|
||||||
if (guild == null)
|
if (guild == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(PREFIX + "That guild does not exist.");
|
sender.sendMessage(PREFIX + "That guild does not exist.");
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package me.totalfreedom.tfguilds.command;
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.tfguilds.Common;
|
import me.totalfreedom.tfguilds.Common;
|
||||||
import me.totalfreedom.tfguilds.TFGuilds;
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
|
import me.totalfreedom.tfguilds.guild.Guild;
|
||||||
|
import me.totalfreedom.tfguilds.util.GUtil;
|
||||||
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;
|
||||||
|
@ -43,6 +46,100 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
{
|
{
|
||||||
|
Guild guild = null;
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
guild = Guild.getGuild((Player)sender);
|
||||||
|
}
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
return TFGuilds.getPlugin().getSubCommands();
|
||||||
|
}
|
||||||
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
|
switch (args[0])
|
||||||
|
{
|
||||||
|
case "home":
|
||||||
|
{
|
||||||
|
return Collections.singletonList("set");
|
||||||
|
}
|
||||||
|
|
||||||
|
case "info":
|
||||||
|
case "join":
|
||||||
|
case "roster":
|
||||||
|
{
|
||||||
|
return Guild.getGuildNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
case "toggletag":
|
||||||
|
{
|
||||||
|
if (!tfmBridge.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return GUtil.getPlayerNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
case "motd":
|
||||||
|
case "tag":
|
||||||
|
{
|
||||||
|
return Arrays.asList("set", "clear");
|
||||||
|
}
|
||||||
|
|
||||||
|
case "setstate":
|
||||||
|
{
|
||||||
|
return Arrays.asList("OPEN", "CLOSED", "INVITE_ONLY");
|
||||||
|
}
|
||||||
|
|
||||||
|
case "invite":
|
||||||
|
{
|
||||||
|
return GUtil.getPlayerNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
case "deleterank":
|
||||||
|
case "setdefaultrank":
|
||||||
|
{
|
||||||
|
if (guild != null && guild.getOwner().equals(((Player)sender).getUniqueId()))
|
||||||
|
{
|
||||||
|
return guild.getRankNames();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "tp":
|
||||||
|
{
|
||||||
|
return guild != null ? guild.getMemberNames() : Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
case "disband":
|
||||||
|
{
|
||||||
|
if (!tfmBridge.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Guild.getGuildNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
case "kick":
|
||||||
|
{
|
||||||
|
if (guild != null && guild.isModerator((Player)sender))
|
||||||
|
{
|
||||||
|
return guild.getMemberOnlyNames();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case "removemod":
|
||||||
|
case "addmod":
|
||||||
|
case "setowner":
|
||||||
|
{
|
||||||
|
if (guild != null && guild.getOwner().equals(((Player)sender).getUniqueId()))
|
||||||
|
{
|
||||||
|
return guild.getMemberNames();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
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.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ModChatSubCommand extends Common implements SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
sender.sendMessage(IN_GAME_ONLY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Guild guild = Guild.getGuild(playerSender);
|
||||||
|
if (guild == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(NOT_IN_GUILD);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
sender.sendMessage(USAGE + "/g mchat <message>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
guild.chat(playerSender, message, true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
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 org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class NoTagSubCommand extends Common implements SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (!tfmBridge.isAdmin(sender))
|
||||||
|
{
|
||||||
|
sender.sendMessage(PREFIX + "You do not have the permission.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
sender.sendMessage(USAGE + "/g edittag <guild>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Guild guild = Guild.getGuild(StringUtils.join(args, " ", 1, args.length));
|
||||||
|
if (guild == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(PREFIX + "That guild does not exist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enabled = guild.canUseTag();
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
guild.setUseTag(false);
|
||||||
|
sender.sendMessage(PREFIX + ChatColor.GOLD + "Disabled " + ChatColor.GRAY + "guild tags for " + ChatColor.GOLD + guild.getName());
|
||||||
|
guild.broadcast(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has disabled guild tags for your guild.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
guild.setUseTag(true);
|
||||||
|
sender.sendMessage(PREFIX + ChatColor.GOLD + "Enabled " + ChatColor.GRAY + "guild tags for " + ChatColor.GOLD + guild.getName());
|
||||||
|
guild.broadcast(PREFIX + ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has enabled guild tags for your guild.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package me.totalfreedom.tfguilds.command;
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
import me.totalfreedom.tfguilds.Common;
|
import me.totalfreedom.tfguilds.Common;
|
||||||
|
import me.totalfreedom.tfguilds.config.ConfigEntry;
|
||||||
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;
|
||||||
|
@ -39,15 +40,22 @@ public class TagSubCommand extends Common implements SubCommand
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!guild.canUseTag())
|
||||||
|
{
|
||||||
|
sender.sendMessage(PREFIX + "You may not edit or clear your guild tag, please contact an admin if this is an error.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length >= 3)
|
if (args.length >= 3)
|
||||||
{
|
{
|
||||||
if (args[1].equalsIgnoreCase("set"))
|
if (args[1].equalsIgnoreCase("set"))
|
||||||
{
|
{
|
||||||
|
int length = ConfigEntry.GUILD_TAG_MAX_LENGTH.getInteger();
|
||||||
String tag = StringUtils.join(args, " ", 2, args.length);
|
String tag = StringUtils.join(args, " ", 2, args.length);
|
||||||
tag = tag.replace("%tag%", guild.getName());
|
tag = tag.replace("%tag%", guild.getName());
|
||||||
if (tag.length() > 15)
|
if (GUtil.removeColorCodes(tag).length() > length && length > 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage(PREFIX + "The guild tag cannot go over 15 characters limit.");
|
sender.sendMessage(PREFIX + "The guild tag cannot go over " + length + " characters limit.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,16 +68,7 @@ public class TagSubCommand extends Common implements SubCommand
|
||||||
guild.setTag(tag);
|
guild.setTag(tag);
|
||||||
sender.sendMessage(PREFIX + "The guild tag has been changed to " + ChatColor.GOLD + GUtil.colorize(tag).replace("%rank%", "Guild Owner"));
|
sender.sendMessage(PREFIX + "The guild tag has been changed to " + ChatColor.GOLD + GUtil.colorize(tag).replace("%rank%", "Guild Owner"));
|
||||||
}
|
}
|
||||||
else
|
else if (args[1].equalsIgnoreCase("clear"))
|
||||||
{
|
|
||||||
sender.sendMessage(USAGE + "/g tag <set <tag> | clear [guild]>");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("clear"))
|
|
||||||
{
|
|
||||||
if (args.length >= 3)
|
|
||||||
{
|
{
|
||||||
if (!tfmBridge.isAdmin(sender))
|
if (!tfmBridge.isAdmin(sender))
|
||||||
{
|
{
|
||||||
|
@ -88,7 +87,15 @@ public class TagSubCommand extends Common implements SubCommand
|
||||||
sender.sendMessage(PREFIX + "Successfully cleared the guild tag for " + ChatColor.GOLD + guild.getName());
|
sender.sendMessage(PREFIX + "Successfully cleared the guild tag for " + ChatColor.GOLD + guild.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(USAGE + "/g tag <set <tag> | clear [guild]>");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("clear"))
|
||||||
|
{
|
||||||
guild.setTag(null);
|
guild.setTag(null);
|
||||||
sender.sendMessage(PREFIX + "Successfully cleared the guild tag.");
|
sender.sendMessage(PREFIX + "Successfully cleared the guild tag.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package me.totalfreedom.tfguilds.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.Common;
|
||||||
|
import me.totalfreedom.tfguilds.guild.User;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ToggleChatSubCommand extends Common implements SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
sender.sendMessage(NOT_IN_GUILD);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
sender.sendMessage(USAGE + "/g togglechat");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
User user = User.getUserFromPlayer(playerSender);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
user = User.create(playerSender);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Must use this otherwise the subcommand will not work properly, unlike ToggleTagSubCommand.java
|
||||||
|
boolean enabled = user.displayChat();
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
user.setDisplayChat(false);
|
||||||
|
sender.sendMessage(PREFIX + ChatColor.GOLD + "Disabled" + ChatColor.GRAY + " personal guild chat.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user.setDisplayChat(true);
|
||||||
|
sender.sendMessage(PREFIX + ChatColor.GOLD + "Enabled" + ChatColor.GRAY + " personal guild chat.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ public enum ConfigEntry
|
||||||
|
|
||||||
GUILD_CHAT_LOGGING("server.guild_chat_logging"),
|
GUILD_CHAT_LOGGING("server.guild_chat_logging"),
|
||||||
GUILD_TAGS("server.guild_tags"),
|
GUILD_TAGS("server.guild_tags"),
|
||||||
|
GUILD_TAG_MAX_LENGTH("server.guild_tag_max_length"),
|
||||||
|
GLOBAL_TAG_MAX_LENGTH("server.global_tag_max_length"),
|
||||||
MYSQL_HOST("mysql.host"),
|
MYSQL_HOST("mysql.host"),
|
||||||
MYSQL_PORT("mysql.port"),
|
MYSQL_PORT("mysql.port"),
|
||||||
MYSQL_USERNAME("mysql.username"),
|
MYSQL_USERNAME("mysql.username"),
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class Guild
|
||||||
private State state;
|
private State state;
|
||||||
private String motd;
|
private String motd;
|
||||||
private Location home;
|
private Location home;
|
||||||
|
private boolean useTag;
|
||||||
|
|
||||||
public Guild(String name,
|
public Guild(String name,
|
||||||
UUID owner,
|
UUID owner,
|
||||||
|
@ -54,7 +55,8 @@ public class Guild
|
||||||
double y,
|
double y,
|
||||||
double z,
|
double z,
|
||||||
String world,
|
String world,
|
||||||
long createdAt)
|
long createdAt,
|
||||||
|
boolean useTag)
|
||||||
{
|
{
|
||||||
this.id = name.toLowerCase().replaceAll(" ", "_");
|
this.id = name.toLowerCase().replaceAll(" ", "_");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -82,6 +84,7 @@ public class Guild
|
||||||
}
|
}
|
||||||
this.home = new Location(w, x, y, z);
|
this.home = new Location(w, x, y, z);
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
|
this.useTag = useTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guild(Player player, String name)
|
public Guild(Player player, String name)
|
||||||
|
@ -100,7 +103,8 @@ public class Guild
|
||||||
50,
|
50,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
System.currentTimeMillis());
|
System.currentTimeMillis(),
|
||||||
|
true);
|
||||||
save(true);
|
save(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,13 +149,12 @@ public class Guild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<UUID> members = new ArrayList<>();
|
List<UUID> members = new ArrayList<>();
|
||||||
members.add(owner);
|
|
||||||
if (set.getString("members") != null)
|
if (set.getString("members") != null)
|
||||||
{
|
{
|
||||||
for (String string : set.getString("members").split(","))
|
for (String string : set.getString("members").split(","))
|
||||||
{
|
{
|
||||||
User user = User.getUserFromId(Integer.parseInt(string));
|
User user = User.getUserFromId(Integer.parseInt(string));
|
||||||
if (user != null)
|
if (user != null && !user.equals(User.getUserFromUuid(owner)))
|
||||||
{
|
{
|
||||||
members.add(user.getUuid());
|
members.add(user.getUuid());
|
||||||
}
|
}
|
||||||
|
@ -212,7 +215,8 @@ public class Guild
|
||||||
set.getDouble("y"),
|
set.getDouble("y"),
|
||||||
set.getDouble("z"),
|
set.getDouble("z"),
|
||||||
set.getString("world"),
|
set.getString("world"),
|
||||||
set.getLong("creation"));
|
set.getLong("creation"),
|
||||||
|
set.getBoolean("usetag"));
|
||||||
guilds.put(id, guild);
|
guilds.put(id, guild);
|
||||||
}
|
}
|
||||||
TFGuilds.getPlugin().getLogger().info(guilds.size() + " guilds loaded!");
|
TFGuilds.getPlugin().getLogger().info(guilds.size() + " guilds loaded!");
|
||||||
|
@ -282,7 +286,7 @@ public class Guild
|
||||||
{
|
{
|
||||||
if (isModerator(player))
|
if (isModerator(player))
|
||||||
{
|
{
|
||||||
moderators.remove(player);
|
moderators.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
members.remove(player.getUniqueId());
|
members.remove(player.getUniqueId());
|
||||||
save();
|
save();
|
||||||
|
@ -430,7 +434,18 @@ public class Guild
|
||||||
return rank;
|
return rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultRank;
|
|
||||||
|
if (owner.equals(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
return "Guild Owner";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (moderators.contains(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
return "Guild Moderator";
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultRank != null ? defaultRank : "Guild Member";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModeratorIds()
|
public String getModeratorIds()
|
||||||
|
@ -479,8 +494,8 @@ public class Guild
|
||||||
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO guilds (`id`, `name`, `owner`, `moderators`, `members`, `tag`, `default_rank`, `state`, `motd`, `x`, `y`, `z`, `world`, `creation`)" +
|
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO guilds (`id`, `name`, `owner`, `moderators`, `members`, `tag`, `default_rank`, `state`, `motd`, `x`, `y`, `z`, `world`, `creation`, `usetag`)" +
|
||||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||||
: connection.prepareStatement("UPDATE guilds SET owner=?," +
|
: connection.prepareStatement("UPDATE guilds SET owner=?," +
|
||||||
"moderators=?," +
|
"moderators=?," +
|
||||||
"members=?," +
|
"members=?," +
|
||||||
|
@ -491,7 +506,8 @@ public class Guild
|
||||||
"x=?," +
|
"x=?," +
|
||||||
"y=?," +
|
"y=?," +
|
||||||
"z=?," +
|
"z=?," +
|
||||||
"world=? WHERE id=?");
|
"world=?," +
|
||||||
|
"usetag=? WHERE id=?");
|
||||||
if (newSave)
|
if (newSave)
|
||||||
{
|
{
|
||||||
statement.setString(1, id);
|
statement.setString(1, id);
|
||||||
|
@ -508,6 +524,7 @@ public class Guild
|
||||||
statement.setDouble(12, home.getZ());
|
statement.setDouble(12, home.getZ());
|
||||||
statement.setString(13, home.getWorld().getName());
|
statement.setString(13, home.getWorld().getName());
|
||||||
statement.setLong(14, createdAt);
|
statement.setLong(14, createdAt);
|
||||||
|
statement.setBoolean(15, useTag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -522,7 +539,8 @@ public class Guild
|
||||||
statement.setDouble(9, home.getY());
|
statement.setDouble(9, home.getY());
|
||||||
statement.setDouble(10, home.getZ());
|
statement.setDouble(10, home.getZ());
|
||||||
statement.setString(11, home.getWorld().getName());
|
statement.setString(11, home.getWorld().getName());
|
||||||
statement.setString(12, id);
|
statement.setBoolean(12, useTag);
|
||||||
|
statement.setString(13, id);
|
||||||
}
|
}
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
|
@ -647,6 +665,19 @@ public class Guild
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getMemberNames()
|
||||||
|
{
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
for (UUID uuid : members)
|
||||||
|
{
|
||||||
|
if (GUtil.getPlayerNames().contains(Bukkit.getOfflinePlayer(uuid).getName()))
|
||||||
|
{
|
||||||
|
names.add(Bukkit.getOfflinePlayer(uuid).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getNamesByRank(String name)
|
public List<String> getNamesByRank(String name)
|
||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
|
@ -665,10 +696,7 @@ public class Guild
|
||||||
|
|
||||||
public List<String> getRankNames()
|
public List<String> getRankNames()
|
||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
return new ArrayList<>(ranks.keySet());
|
||||||
ranks.keySet().forEach(rank ->
|
|
||||||
names.add(rank));
|
|
||||||
return names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Location> getWarps()
|
public Map<String, Location> getWarps()
|
||||||
|
@ -678,10 +706,7 @@ public class Guild
|
||||||
|
|
||||||
public List<String> getWarpNames()
|
public List<String> getWarpNames()
|
||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
return new ArrayList<>(warps.keySet());
|
||||||
warps.keySet().forEach(name ->
|
|
||||||
names.add(name));
|
|
||||||
return names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getWarp(String name)
|
public Location getWarp(String name)
|
||||||
|
@ -737,6 +762,17 @@ public class Guild
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canUseTag()
|
||||||
|
{
|
||||||
|
return useTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseTag(boolean useTag)
|
||||||
|
{
|
||||||
|
this.useTag = useTag;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public void disband()
|
public void disband()
|
||||||
{
|
{
|
||||||
if (hasGuild(name))
|
if (hasGuild(name))
|
||||||
|
@ -773,18 +809,21 @@ public class Guild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void chat(Player player, String message)
|
public void chat(Player player, String message, boolean modChat)
|
||||||
{
|
{
|
||||||
broadcast(GUtil.colorize("&7[&bGuild Chat &7| &b" + name + "&7] " + player.getName() + " &8\u00BB &6") + message);
|
|
||||||
|
|
||||||
if (ConfigEntry.GUILD_CHAT_LOGGING.getBoolean())
|
if (ConfigEntry.GUILD_CHAT_LOGGING.getBoolean())
|
||||||
{
|
{
|
||||||
Bukkit.getServer().getLogger().info("[Guild Chat | " + name + "] " + player.getName() + " \u00BB " + message);
|
Bukkit.getServer().getLogger().info("[Guild " + (modChat ? "Mod " : "") + "Chat | " + name + "] " + player.getName() + " \u00BB " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (Common.GUILD_CHAT_SPY.contains(p) && player != p)
|
if (User.getUserFromPlayer(p).displayChat() && isMember(p))
|
||||||
|
{
|
||||||
|
p.sendMessage(GUtil.colorize("&7[&bGuild " + (modChat ? "Mod " : "") + "Chat &7| &b" + name + "&7] " + player.getName() + " &8\u00BB &6") + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Common.GUILD_CHAT_SPY.contains(p) && player != p && !isMember(p))
|
||||||
{
|
{
|
||||||
p.sendMessage(GUtil.colorize("&7[&bGuild Chat Spy &7| &b" + name + "&7] " + player.getName() + " &8\u00BB &6") + message);
|
p.sendMessage(GUtil.colorize("&7[&bGuild Chat Spy &7| &b" + name + "&7] " + player.getName() + " &8\u00BB &6") + message);
|
||||||
}
|
}
|
||||||
|
@ -814,18 +853,16 @@ public class Guild
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
return ChatColor.AQUA + "Guild Information" + "\n" + ChatColor.GRAY +
|
||||||
builder.append(ChatColor.AQUA).append("Guild Information").append("\n").append(ChatColor.GRAY)
|
" Identifier: " + ChatColor.GOLD + id + "\n" +
|
||||||
.append(" Identifier: ").append(ChatColor.GOLD).append(id).append("\n")
|
ChatColor.GRAY + " Name: " + ChatColor.GOLD + name + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" Name: ").append(ChatColor.GOLD).append(name).append("\n")
|
ChatColor.GRAY + " Owner: " + ChatColor.GOLD + Bukkit.getOfflinePlayer(owner).getName() + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" Owner: ").append(ChatColor.GOLD).append(Bukkit.getOfflinePlayer(owner).getName()).append("\n")
|
ChatColor.GRAY + " Moderators: " + ChatColor.GOLD + moderators.size() + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" Moderators (").append(getModerators().size()).append("): ").append(ChatColor.GOLD).append(StringUtils.join(getModeratorNames(), ", ")).append("\n")
|
ChatColor.GRAY + " Members: " + ChatColor.GOLD + members.size() + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" Members (").append(getMembers().size()).append("): ").append(ChatColor.GOLD).append(StringUtils.join(getMemberOnlyNames(), ", ")).append("\n")
|
ChatColor.GRAY + " Tag: " + ChatColor.GOLD + (tag != null ? GUtil.colorize(tag) : "None") + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" Tag: ").append(ChatColor.GOLD).append(tag != null ? GUtil.colorize(tag) : "None").append("\n")
|
ChatColor.GRAY + " State: " + ChatColor.GOLD + state.name() + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" State: ").append(ChatColor.GOLD).append(state.name()).append("\n")
|
ChatColor.GRAY + " Ranks (" + ranks.size() + "): " + ChatColor.GOLD + StringUtils.join(getRankNames(), ", ") + "\n" +
|
||||||
.append(ChatColor.GRAY).append(" Ranks (").append(ranks.size()).append("): ").append(ChatColor.GOLD).append(StringUtils.join(getRankNames(), ", ")).append("\n")
|
ChatColor.GRAY + " Created At: " + ChatColor.GOLD + GUtil.formatTime(createdAt);
|
||||||
.append(ChatColor.GRAY).append(" Created At: ").append(ChatColor.GOLD).append(GUtil.formatTime(createdAt));
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCreatedAt()
|
public long getCreatedAt()
|
||||||
|
@ -849,7 +886,7 @@ public class Guild
|
||||||
{
|
{
|
||||||
return valueOf(string.toUpperCase());
|
return valueOf(string.toUpperCase());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -18,18 +18,20 @@ public class User
|
||||||
private final int id;
|
private final int id;
|
||||||
private final UUID uuid;
|
private final UUID uuid;
|
||||||
private boolean tag;
|
private boolean tag;
|
||||||
|
private boolean chat;
|
||||||
|
|
||||||
public User(int id, UUID uuid, boolean tag)
|
public User(int id, UUID uuid, boolean tag, boolean chat)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
|
this.chat = chat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static User create(Player player)
|
public static User create(Player player)
|
||||||
{
|
{
|
||||||
int id = users.size() + 1;
|
int id = users.size() + 1;
|
||||||
User user = new User(id, player.getUniqueId(), true);
|
User user = new User(id, player.getUniqueId(), true, true);
|
||||||
users.put(id, user);
|
users.put(id, user);
|
||||||
user.save(true);
|
user.save(true);
|
||||||
return user;
|
return user;
|
||||||
|
@ -43,10 +45,11 @@ public class User
|
||||||
ResultSet set = connection.prepareStatement("SELECT * FROM users").executeQuery();
|
ResultSet set = connection.prepareStatement("SELECT * FROM users").executeQuery();
|
||||||
while (set.next())
|
while (set.next())
|
||||||
{
|
{
|
||||||
int id = set.getInt("id");
|
int id = set.getInt("rowid");
|
||||||
UUID uuid = UUID.fromString(set.getString("uuid"));
|
UUID uuid = UUID.fromString(set.getString("uuid"));
|
||||||
boolean tag = set.getBoolean("tag");
|
boolean tag = set.getBoolean("tag");
|
||||||
users.put(id, new User(id, uuid, tag));
|
boolean chat = set.getBoolean("chat");
|
||||||
|
users.put(id, new User(id, uuid, tag, chat));
|
||||||
}
|
}
|
||||||
TFGuilds.getPlugin().getLogger().info(users.size() + " users loaded!");
|
TFGuilds.getPlugin().getLogger().info(users.size() + " users loaded!");
|
||||||
}
|
}
|
||||||
|
@ -108,23 +111,35 @@ public class User
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean displayChat()
|
||||||
|
{
|
||||||
|
return chat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplayChat(boolean chat)
|
||||||
|
{
|
||||||
|
this.chat = chat;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
public void save(boolean newSave)
|
public void save(boolean newSave)
|
||||||
{
|
{
|
||||||
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
Connection connection = TFGuilds.getPlugin().getSQL().getConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO users (`uuid`, `id`, `tag`) VALUES (?, ?, ?)")
|
PreparedStatement statement = newSave ? connection.prepareStatement("INSERT INTO users (`uuid`, `tag`, `chat`) VALUES (?, ?, ?)")
|
||||||
: connection.prepareStatement("UPDATE users SET tag=? WHERE id=?");
|
: connection.prepareStatement("UPDATE users SET tag=?, chat=? WHERE rowid=?");
|
||||||
if (newSave)
|
if (newSave)
|
||||||
{
|
{
|
||||||
statement.setString(1, uuid.toString());
|
statement.setString(1, uuid.toString());
|
||||||
statement.setInt(2, id);
|
statement.setBoolean(2, tag);
|
||||||
statement.setBoolean(3, tag);
|
statement.setBoolean(3, chat);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
statement.setBoolean(1, tag);
|
statement.setBoolean(1, tag);
|
||||||
statement.setInt(2, id);
|
statement.setBoolean(2, chat);
|
||||||
|
statement.setInt(3, id);
|
||||||
}
|
}
|
||||||
statement.execute();
|
statement.execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class ChatListener implements Listener
|
||||||
if (Common.GUILD_CHAT.contains(player))
|
if (Common.GUILD_CHAT.contains(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
guild.chat(player, event.getMessage());
|
guild.chat(player, event.getMessage(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,27 +43,20 @@ public class ChatListener implements Listener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String display = guild.getPlayerRank(player);
|
|
||||||
if (display == guild.getDefaultRank())
|
|
||||||
{
|
|
||||||
if (guild.getOwner().equals(player.getUniqueId()))
|
|
||||||
{
|
|
||||||
display = "Guild Owner";
|
|
||||||
}
|
|
||||||
else if (guild.isModerator(player))
|
|
||||||
{
|
|
||||||
display = "Guild Moderator";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (display == null)
|
|
||||||
{
|
|
||||||
display = "Guild Member";
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = User.getUserFromPlayer(player);
|
User user = User.getUserFromPlayer(player);
|
||||||
if (guild.getTag() != null && user.displayTag())
|
if (guild.getTag() != null && user.displayTag())
|
||||||
{
|
{
|
||||||
event.setFormat(GUtil.colorize(guild.getTag().replace("%rank%", display)) + ChatColor.RESET + " " + event.getFormat());
|
int maxLength = ConfigEntry.GLOBAL_TAG_MAX_LENGTH.getInteger();
|
||||||
|
String tfmTag = TFGuilds.getPlugin().getTfmBridge().getTag(player);
|
||||||
|
if (tfmTag != null && maxLength > 0)
|
||||||
|
{
|
||||||
|
int length = GUtil.removeColorCodes(tfmTag).length() + GUtil.removeColorCodes(guild.getTag()).length();
|
||||||
|
if (length > maxLength)
|
||||||
|
{
|
||||||
|
TFGuilds.getPlugin().getTfmBridge().clearTag(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.setFormat(GUtil.colorize(guild.getTag().replace("%rank%", guild.getPlayerRank(player))) + ChatColor.RESET + " " + event.getFormat());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package me.totalfreedom.tfguilds.listener;
|
package me.totalfreedom.tfguilds.listener;
|
||||||
|
|
||||||
import me.totalfreedom.tfguilds.TFGuilds;
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
|
import me.totalfreedom.tfguilds.config.ConfigEntry;
|
||||||
import me.totalfreedom.tfguilds.guild.Guild;
|
import me.totalfreedom.tfguilds.guild.Guild;
|
||||||
import me.totalfreedom.tfguilds.guild.User;
|
import me.totalfreedom.tfguilds.guild.User;
|
||||||
|
import me.totalfreedom.tfguilds.util.GUtil;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -17,7 +19,7 @@ public class JoinListener implements Listener
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
@ -38,5 +40,16 @@ public class JoinListener implements Listener
|
||||||
{
|
{
|
||||||
player.sendMessage(guild.getMotd());
|
player.sendMessage(guild.getMotd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maxLength = ConfigEntry.GLOBAL_TAG_MAX_LENGTH.getInteger();
|
||||||
|
String tfmTag = TFGuilds.getPlugin().getTfmBridge().getTag(player);
|
||||||
|
if (user.displayTag() && tfmTag != null && guild.getTag() != null && maxLength > 0)
|
||||||
|
{
|
||||||
|
int length = GUtil.removeColorCodes(tfmTag).length() + GUtil.removeColorCodes(guild.getTag()).length();
|
||||||
|
if (length > maxLength)
|
||||||
|
{
|
||||||
|
TFGuilds.getPlugin().getTfmBridge().clearTag(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import me.totalfreedom.tfguilds.TFGuilds;
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
import me.totalfreedom.tfguilds.config.ConfigEntry;
|
import me.totalfreedom.tfguilds.config.ConfigEntry;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
public class SQLDatabase
|
public class SQLDatabase
|
||||||
{
|
{
|
||||||
|
@ -45,8 +44,8 @@ public class SQLDatabase
|
||||||
{
|
{
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `users` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `users` (" +
|
||||||
"`uuid` TEXT," +
|
"`uuid` TEXT," +
|
||||||
"`id` INT," +
|
|
||||||
"`tag` BOOLEAN," +
|
"`tag` BOOLEAN," +
|
||||||
|
"`chat` BOOLEAN," +
|
||||||
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
||||||
.execute();
|
.execute();
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `warps` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `warps` (" +
|
||||||
|
@ -73,6 +72,7 @@ public class SQLDatabase
|
||||||
"`z` DOUBLE," +
|
"`z` DOUBLE," +
|
||||||
"`world` TEXT," +
|
"`world` TEXT," +
|
||||||
"`creation` LONG," +
|
"`creation` LONG," +
|
||||||
|
"`usetag` BOOLEAN," +
|
||||||
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
"`rowid` INTEGER AUTO_INCREMENT PRIMARY KEY)")
|
||||||
.execute();
|
.execute();
|
||||||
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `ranks` (" +
|
connection.prepareStatement("CREATE TABLE IF NOT EXISTS `ranks` (" +
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package me.totalfreedom.tfguilds.util;
|
package me.totalfreedom.tfguilds.util;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class GUtil
|
public class GUtil
|
||||||
{
|
{
|
||||||
|
@ -16,6 +20,7 @@ public class GUtil
|
||||||
"admin", "owner", "moderator", "developer", "console", "dev", "staff",
|
"admin", "owner", "moderator", "developer", "console", "dev", "staff",
|
||||||
"mod", "sra", "sta", "sa", "super admin", "telnet admin", "senior admin",
|
"mod", "sra", "sta", "sa", "super admin", "telnet admin", "senior admin",
|
||||||
"trial mod", "trial moderator", "trialmod", "trialmoderator");
|
"trial mod", "trial moderator", "trialmod", "trialmoderator");
|
||||||
|
private static final Pattern CHAT_COLOR_FORMAT = Pattern.compile("&[a-fk-or0-9]", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
public static String colorize(String string)
|
public static String colorize(String string)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +38,19 @@ public class GUtil
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String removeColorCodes(String string)
|
||||||
|
{
|
||||||
|
if (string != null)
|
||||||
|
{
|
||||||
|
Matcher matcher = CHAT_COLOR_FORMAT.matcher(string);
|
||||||
|
while (matcher.find())
|
||||||
|
{
|
||||||
|
string = string.replaceAll(matcher.group(), "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean containsBlacklistedWord(String string)
|
public static boolean containsBlacklistedWord(String string)
|
||||||
{
|
{
|
||||||
for (String blacklist : BLACKLISTED_NAMES_AND_TAGS)
|
for (String blacklist : BLACKLISTED_NAMES_AND_TAGS)
|
||||||
|
@ -45,6 +63,19 @@ public class GUtil
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> getPlayerNames()
|
||||||
|
{
|
||||||
|
List<String> names = new ArrayList<>();
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!TFGuilds.getPlugin().getTfmBridge().isVanished(player))
|
||||||
|
{
|
||||||
|
names.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
public static String formatTime(long time)
|
public static String formatTime(long time)
|
||||||
{
|
{
|
||||||
Date date = new Date(time);
|
Date date = new Date(time);
|
||||||
|
|
|
@ -9,6 +9,15 @@ server:
|
||||||
# Enable guild tags globally?
|
# Enable guild tags globally?
|
||||||
guild_tags_enabled: true
|
guild_tags_enabled: true
|
||||||
|
|
||||||
|
# Maximum guild tag length - 0 for unlimited.
|
||||||
|
# Note: chat colors are ignored
|
||||||
|
guild_tag_max_length: 20
|
||||||
|
|
||||||
|
# Maximum overall tag length - requires TotalFreedomMod.
|
||||||
|
# If the player's tag and guild tag combined exceeds the maximum overall length, guild tag will take priority. 0 for unlimited.
|
||||||
|
# Note: chat colors are ignored
|
||||||
|
global_tag_max_length: 30
|
||||||
|
|
||||||
# MySQL configuration
|
# MySQL configuration
|
||||||
mysql:
|
mysql:
|
||||||
host: localhost
|
host: localhost
|
||||||
|
|
Loading…
Reference in a new issue