add global guild tag toggle

This commit is contained in:
speedxx 2020-08-12 22:41:38 -04:00
parent 50de5817e9
commit e8d95df46f
7 changed files with 65 additions and 5 deletions

View file

@ -68,6 +68,8 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
return new RosterSubcommand().onCommand(sender, command, label, args);
case "setdefaultrank":
return new SetDefaultRankSubcommand().onCommand(sender, command, label, args);
case "toggletags":
return new ToggleTagsSubcommand().onCommand(sender, command, label, args);
}
return false;
}
@ -83,7 +85,7 @@ public class GuildCommand extends Common implements CommandExecutor, TabComplete
return Arrays.asList("addmod", "chat", "createrank", "create",
"deleterank", "disband", "help", "home", "info", "invite",
"join", "kick", "leave", "list", "motd", "removemod", "rename",
"roster", "setowner", "setrank", "setstate", "tag", "tp", "setdefaultrank");
"roster", "setowner", "setrank", "setstate", "tag", "tp", "setdefaultrank", "toggletags");
}
else if (args.length == 2)
{

View file

@ -0,0 +1,33 @@
package me.totalfreedom.tfguilds.command;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.config.ConfigEntry;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class ToggleTagsSubcommand extends Common implements CommandExecutor
{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (!plugin.bridge.isAdmin(sender))
{
sender.sendMessage(NO_PERMS);
return true;
}
boolean enabled = ConfigEntry.GUILD_TAGS_ENABLED.getBoolean();
if (enabled)
{
ConfigEntry.GUILD_TAGS_ENABLED.setBoolean(false);
sender.sendMessage(tl(PREFIX + "Disabled guild tags."));
}
else
{
ConfigEntry.GUILD_TAGS_ENABLED.setBoolean(true);
sender.sendMessage(tl(PREFIX + "Enabled guild tags."));
}
return true;
}
}

View file

@ -8,7 +8,8 @@ public enum ConfigEntry
SCHEME_PRIMARY("scheme.primary"),
SCHEME_SECONDARY("scheme.secondary"),
// Server
SERVER_GUILD_CHAT_LOGGING_ENABLED("server.guild_chat_logging.enabled");
SERVER_GUILD_CHAT_LOGGING_ENABLED("server.guild_chat_logging.enabled"),
GUILD_TAGS_ENABLED("server.guild_tags.enabled");
private final String path;
@ -17,13 +18,19 @@ public enum ConfigEntry
this.path = path;
}
private static Config config = TFGuilds.getPlugin().config;
private static final Config config = TFGuilds.getPlugin().config;
public boolean getBoolean()
{
return config.getBoolean(path);
}
public void setBoolean(boolean value)
{
config.set(path, value);
config.save();
}
public ChatColor getChatColor()
{
return ChatColor.valueOf(config.getString(path).toUpperCase());

View file

@ -291,7 +291,7 @@ public class Guild
for (String key : plugin.guilds.getKeys(false))
{
Guild guild = getGuild(key);
g.add(GUtil.colorize(guild.getName()));
g.add(guild.getName());
}
return g;
}

View file

@ -1,9 +1,11 @@
package me.totalfreedom.tfguilds.listener;
import me.totalfreedom.tfguilds.Common;
import me.totalfreedom.tfguilds.config.ConfigEntry;
import me.totalfreedom.tfguilds.guild.Guild;
import me.totalfreedom.tfguilds.guild.GuildRank;
import me.totalfreedom.tfguilds.util.GUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -64,5 +66,18 @@ public class ChatListener implements Listener
{
e.setFormat(GUtil.colorize(guild.getTag().replace("%rank%", display)) + ChatColor.RESET + " " + e.getFormat());
}
if (!ConfigEntry.GUILD_TAGS_ENABLED.getBoolean())
{
for (Player p : Bukkit.getOnlinePlayers())
{
Guild g = Guild.getGuild(p);
if (guild.hasTag())
{
e.setFormat(e.getFormat().replace(g.getTag(), ""));
}
}
}
}
}

View file

@ -6,6 +6,9 @@ server:
guild_chat_logging:
enabled: true
guild_tags_enabled:
enabled: true
scheme:
primary: GREEN
secondary: DARK_GREEN

View file

@ -7,7 +7,7 @@ description: A guilds plugin for the TotalFreedom server.
commands:
guild:
description: The main command of TFGuilds.
usage: /<command> [list | help | create <name> | disband [name] | invite <player> | addmod <guild <player> | player> | removemod <guild <name> | name> | createrank <name> | setowner <guild <player> | player> | kick <guild <player> | player> | leave | setstate <guild <state> | state> | tp <player> | info [guild | player] | tag <set <tag> | clear> | join <guild> | chat [message] | roster [guild] | rename <name> | createrank <name> | deleterank <rank> | setrank <player> <rank | none> motd <set <motd> | clear> | home [set] | chat [message]]
usage: /<command> [list | help | create <name> | disband [name] | invite <player> | addmod <guild <player> | player> | removemod <guild <name> | name> | createrank <name> | setowner <guild <player> | player> | kick <guild <player> | player> | leave | setstate <guild <state> | state> | tp <player> | info [guild | player] | tag <set <tag> | clear> | join <guild> | chat [message] | roster [guild] | rename <name> | createrank <name> | deleterank <rank> | setrank <player> <rank | none> motd <set <motd> | clear> | home [set] | chat [message] | setdefaultrank <rank | none> | toggletags]
aliases: [g]
guildchat:
description: Talk in chat with your guild.