From a0360386c977047b4c030ede7e2fa08d75627526 Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Thu, 29 Jul 2021 23:45:54 -0400 Subject: [PATCH] Remove unneeded files. --- .../Aust1n46/chat/channel/ChatChannel.java | 457 ------------------ .../chat/command/VentureCommandExecutor.java | 142 ------ .../chat/command/chat/Chatreload.java | 60 --- 3 files changed, 659 deletions(-) delete mode 100644 src/mineverse/Aust1n46/chat/channel/ChatChannel.java delete mode 100644 src/mineverse/Aust1n46/chat/command/VentureCommandExecutor.java delete mode 100644 src/mineverse/Aust1n46/chat/command/chat/Chatreload.java diff --git a/src/mineverse/Aust1n46/chat/channel/ChatChannel.java b/src/mineverse/Aust1n46/chat/channel/ChatChannel.java deleted file mode 100644 index a45435a..0000000 --- a/src/mineverse/Aust1n46/chat/channel/ChatChannel.java +++ /dev/null @@ -1,457 +0,0 @@ -package mineverse.Aust1n46.chat.channel; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.configuration.ConfigurationSection; - -import mineverse.Aust1n46.chat.MineverseChat; -import mineverse.Aust1n46.chat.utilities.Format; - -/** - * Chat channel object pojo. Class also contains static initialization methods - * for reading chat channels from the config file. - * - * @author Aust1n46 - */ -public class ChatChannel { - private static final String PERMISSION_PREFIX = "venturechat."; - private static final String NO_PERMISSIONS = "venturechat.none"; - - private static boolean aliasesRegisteredAsCommands; - - private static MineverseChat plugin = MineverseChat.getInstance(); - private static ChatChannel defaultChatChannel; - private static String defaultColor; - private static HashMap chatChannels; - - @Deprecated - private static ChatChannel[] channels; - - private String name; - private String permission; - private String speakPermission; - private boolean mutable; - private String color; - private String chatColor; - private boolean defaultChannel; - private boolean autojoin; - private String alias; - private double distance; - private boolean filter; - private boolean bungee; - private String format; - private int cooldown; - - /** - * Read chat channels from config file and initialize channel array. - */ - public static void initialize(boolean aliasesRegisteredAsCommands) { - chatChannels = new HashMap(); - ChatChannel.aliasesRegisteredAsCommands = aliasesRegisteredAsCommands; - ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels"); - int len = (cs.getKeys(false)).size(); - channels = new ChatChannel[len]; - int counter = 0; - for (String key : cs.getKeys(false)) { - String color = cs.getString(key + ".color", "white"); - String chatColor = cs.getString(key + ".chatcolor", "white"); - String name = key; - String permission = cs.getString(key + ".permissions", "None"); - String speakPermission = cs.getString(key + ".speak_permissions", "None"); - boolean mutable = cs.getBoolean(key + ".mutable", false); - boolean filter = cs.getBoolean(key + ".filter", true); - boolean bungee = cs.getBoolean(key + ".bungeecord", false); - String format = cs.getString(key + ".format", "Default"); - boolean defaultChannel = cs.getBoolean(key + ".default", false); - String alias = cs.getString(key + ".alias", "None"); - double distance = cs.getDouble(key + ".distance", (double) 0); - int cooldown = cs.getInt(key + ".cooldown", 0); - boolean autojoin = cs.getBoolean(key + ".autojoin", false); - ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable, - filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format); - channels[counter++] = chatChannel; - chatChannels.put(name.toLowerCase(), chatChannel); - chatChannels.put(alias.toLowerCase(), chatChannel); - if (defaultChannel) { - defaultChatChannel = chatChannel; - defaultColor = color; - } - } - } - - public static boolean areAliasesRegisteredAsCommands() { - return aliasesRegisteredAsCommands; - } - - /** - * Get array of chat channels. - * - * @return {@link ChatChannel}[] - */ - @Deprecated - public static ChatChannel[] getChannels() { - return channels; - } - - /** - * Get list of chat channels. - * - * @return {@link Collection}<{@link ChatChannel}> - */ - public static Collection getChatChannels() { - return new HashSet(chatChannels.values()); - } - - /** - * Get a chat channel by name. - * - * @param channelName - * name of channel to get. - * @return {@link ChatChannel} - */ - public static ChatChannel getChannel(String channelName) { - return chatChannels.get(channelName.toLowerCase()); - } - - /** - * Checks if the chat channel exists. - * - * @param channelName - * name of channel to check. - * @return true if channel exists, false otherwise. - */ - public static boolean isChannel(String channelName) { - return getChannel(channelName) != null; - } - - /** - * Get default chat channel color. - * - * @return {@link String} - */ - public static String getDefaultColor() { - return defaultColor; - } - - /** - * Get default chat channel. - * - * @return {@link ChatChannel} - */ - public static ChatChannel getDefaultChannel() { - return defaultChatChannel; - } - - /** - * Get list of chat channels with autojoin set to true. - * - * @return {@link List}<{@link ChatChannel}> - */ - public static List getAutojoinList() { - List joinlist = new ArrayList(); - for (ChatChannel c : channels) { - if (c.getAutojoin()) { - joinlist.add(c); - } - } - return joinlist; - } - - /** - * Parameterized constructor a {@link ChatChannel}. - * - * @param name - * @param color - * @param chatColor - * @param permission - * @param speakPermission - * @param mutable - * @param filter - * @param defaultChannel - * @param alias - * @param distance - * @param autojoin - * @param bungee - * @param cooldown - * @param format - */ - public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission, - boolean mutable, boolean filter, boolean defaultChannel, String alias, double distance, boolean autojoin, - boolean bungee, int cooldown, String format) { - this.name = name; - this.color = color; - this.chatColor = chatColor; - this.permission = PERMISSION_PREFIX + permission; - this.speakPermission = PERMISSION_PREFIX + speakPermission; - this.mutable = mutable; - this.filter = filter; - this.defaultChannel = defaultChannel; - this.alias = alias; - this.distance = distance; - this.autojoin = autojoin; - this.bungee = bungee; - this.cooldown = cooldown; - this.format = format; - } - - /** - * Deprecated parameterized constructor a {@link ChatChannel}. - * - * @param name - * @param color - * @param chatColor - * @param permission - * @param speakPermission - * @param mutable - * @param filter - * @param defaultChannel - * @param alias - * @param distance - * @param autojoin - * @param bungee - * @param cooldown - * @param format - */ - @Deprecated - public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission, - Boolean mutable, Boolean filter, Boolean defaultChannel, String alias, Double distance, Boolean autojoin, - Boolean bungee, int cooldown, String format) { - this.name = name; - this.color = color; - this.chatColor = chatColor; - this.permission = PERMISSION_PREFIX + permission; - this.speakPermission = PERMISSION_PREFIX + speakPermission; - this.mutable = mutable; - this.filter = filter; - this.defaultChannel = defaultChannel; - this.alias = alias; - this.distance = distance; - this.autojoin = autojoin; - this.bungee = bungee; - this.cooldown = cooldown; - this.format = format; - } - - /** - * Get the name of the chat channel. - * - * @return {@link String} - */ - public String getName() { - return name; - } - - /** - * Get the format of the chat channel. - * - * @return {@link String} - */ - public String getFormat() { - return format; - } - - /** - * Get the cooldown of the chat channel in seconds. - * - * @return int - */ - public int getCooldown() { - return cooldown; - } - - /** - * Check if the chat channel is BungeeCord enabled. - * - * @return {@link Boolean#TRUE} if the chat channel is BungeeCord enabled, - * {@link Boolean#FALSE} otherwise. - */ - public Boolean getBungee() { - return Boolean.valueOf(bungee); - } - - /** - * Get the permissions node for the chat channel. - * - * @return {@link String} - */ - public String getPermission() { - return permission; - } - - /** - * Check if autojoin is enabled for the chat channel. - * - * @return {@link Boolean#TRUE} if autojoin is enabled, {@link Boolean#FALSE} - * otherwise. - */ - public Boolean getAutojoin() { - return Boolean.valueOf(autojoin); - } - - /** - * Check if the chat channel allows muting. - * - * @return {@link Boolean#TRUE} if muting is allowed, {@link Boolean#FALSE} - * otherwise. - */ - public Boolean isMutable() { - return Boolean.valueOf(mutable); - } - - /** - * Get the formatted color of the chat channel. - * - * @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the - * color is invalid. - */ - public String getColor() { - if (Format.isValidColor(color)) { - return String.valueOf(ChatColor.valueOf(color.toUpperCase())); - } - if (Format.isValidHexColor(color)) { - return Format.convertHexColorCodeToBukkitColorCode(color); - } - return Format.DEFAULT_COLOR_CODE; - } - - /** - * Get the raw color value of the chat channel. - * - * @return {@link String} - */ - public String getColorRaw() { - return color; - } - - /** - * Get the formatted chat color of the chat channel. - * - * @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the chat - * color is invalid. - */ - public String getChatColor() { - if (chatColor.equalsIgnoreCase("None")) { - return chatColor; - } - if (Format.isValidColor(chatColor)) { - return String.valueOf(ChatColor.valueOf(chatColor.toUpperCase())); - } - if (Format.isValidHexColor(chatColor)) { - return Format.convertHexColorCodeToBukkitColorCode(chatColor); - } - return Format.DEFAULT_COLOR_CODE; - } - - /** - * Get the raw chat color value of the chat channel. - * - * @return {@link String} - */ - public String getChatColorRaw() { - return chatColor; - } - - /** - * Check if the chat channel is the default chat channel. - * - * @return {@link Boolean#TRUE} if the chat channel is the default chat channel, - * {@link Boolean#FALSE} otherwise. - */ - public Boolean isDefaultchannel() { - return Boolean.valueOf(defaultChannel); - } - - /** - * Get the alias of the chat channel. - * - * @return {@link String} - */ - public String getAlias() { - return alias; - } - - /** - * Get the distance of the chat channel in blocks. - * - * @return {@link Double} - */ - public Double getDistance() { - return Double.valueOf(distance); - } - - /** - * Checks if the chat channel has a distance set. - * - * @return {@link Boolean#TRUE} if the distance is greater than zero, - * {@link Boolean#FALSE} otherwise. - */ - public Boolean hasDistance() { - return Boolean.valueOf(distance > 0); - } - - /** - * Checks if the chat channel has a cooldown set. - * - * @return {@link Boolean#TRUE} if the cooldown is greater than zero, - * {@link Boolean#FALSE} otherwise. - */ - public Boolean hasCooldown() { - return Boolean.valueOf(cooldown > 0); - } - - /** - * Checks if the chat channel has a permission set. - * - * @return {@link Boolean#TRUE} if the permission does not equal - * {@link ChatChannel#NO_PERMISSIONS}, {@link Boolean#FALSE} otherwise. - */ - public Boolean hasPermission() { - return Boolean.valueOf(!permission.equalsIgnoreCase(NO_PERMISSIONS)); - } - - /** - * Checks if the chat channel has a speak permission set. - * - * @return true if the speak permission does not equal - * {@link ChatChannel#NO_PERMISSIONS}, false otherwise. - */ - public boolean hasSpeakPermission() { - return !speakPermission.equalsIgnoreCase(NO_PERMISSIONS); - } - - /** - * Get the speak permissions node for the chat channel. - * - * @return {@link String} - */ - public String getSpeakPermission() { - return speakPermission; - } - - /** - * Checks if the chat channel has the filter enabled. - * - * @return {@link Boolean#TRUE} if the chat channel has the filter enabled, - * {@link Boolean#FALSE} otherwise. - */ - public Boolean isFiltered() { - return Boolean.valueOf(filter); - } - - /** - * Compares the chat channel by name to determine equality. - * - * @param channel - * Object to compare for equality. - * @return true if the objects are equal, false otherwise. - */ - @Override - public boolean equals(Object channel) { - return channel instanceof ChatChannel && this.name.equals(((ChatChannel) channel).getName()); - } -} diff --git a/src/mineverse/Aust1n46/chat/command/VentureCommandExecutor.java b/src/mineverse/Aust1n46/chat/command/VentureCommandExecutor.java deleted file mode 100644 index 89929fc..0000000 --- a/src/mineverse/Aust1n46/chat/command/VentureCommandExecutor.java +++ /dev/null @@ -1,142 +0,0 @@ -package mineverse.Aust1n46.chat.command; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabExecutor; - -import mineverse.Aust1n46.chat.MineverseChat; -import mineverse.Aust1n46.chat.command.chat.Broadcast; -import mineverse.Aust1n46.chat.command.chat.BungeeToggle; -import mineverse.Aust1n46.chat.command.chat.Channel; -import mineverse.Aust1n46.chat.command.chat.Channelinfo; -import mineverse.Aust1n46.chat.command.chat.Chatinfo; -import mineverse.Aust1n46.chat.command.chat.Chatreload; -import mineverse.Aust1n46.chat.command.chat.Chlist; -import mineverse.Aust1n46.chat.command.chat.Chwho; -import mineverse.Aust1n46.chat.command.chat.Clearchat; -import mineverse.Aust1n46.chat.command.chat.Commandblock; -import mineverse.Aust1n46.chat.command.chat.Commandspy; -import mineverse.Aust1n46.chat.command.chat.Config; -import mineverse.Aust1n46.chat.command.chat.Edit; -import mineverse.Aust1n46.chat.command.chat.Filter; -import mineverse.Aust1n46.chat.command.chat.Force; -import mineverse.Aust1n46.chat.command.chat.Forceall; -import mineverse.Aust1n46.chat.command.chat.Kickchannel; -import mineverse.Aust1n46.chat.command.chat.Kickchannelall; -import mineverse.Aust1n46.chat.command.chat.Leave; -import mineverse.Aust1n46.chat.command.chat.Listen; -import mineverse.Aust1n46.chat.command.chat.Me; -import mineverse.Aust1n46.chat.command.chat.Nick; -import mineverse.Aust1n46.chat.command.chat.Party; -import mineverse.Aust1n46.chat.command.chat.RangedSpy; -import mineverse.Aust1n46.chat.command.chat.Removemessage; -import mineverse.Aust1n46.chat.command.chat.Setchannel; -import mineverse.Aust1n46.chat.command.chat.Setchannelall; -import mineverse.Aust1n46.chat.command.chat.VentureChatGui; -import mineverse.Aust1n46.chat.command.chat.Venturechat; -import mineverse.Aust1n46.chat.command.message.IgnoreCommandExecutor; -import mineverse.Aust1n46.chat.command.message.MessageCommandExecutor; -import mineverse.Aust1n46.chat.command.message.MessageToggle; -import mineverse.Aust1n46.chat.command.message.Notifications; -import mineverse.Aust1n46.chat.command.message.Reply; -import mineverse.Aust1n46.chat.command.message.Spy; -import mineverse.Aust1n46.chat.command.mute.Mute; -import mineverse.Aust1n46.chat.command.mute.Muteall; -import mineverse.Aust1n46.chat.command.mute.Unmute; -import mineverse.Aust1n46.chat.command.mute.Unmuteall; - -/** - * Class that initializes and executes the plugin's commands. - */ -public class VentureCommandExecutor implements TabExecutor { - private static Map commands = new HashMap(); - private static MineverseChat plugin = MineverseChat.getInstance(); - private static VentureCommandExecutor commandExecutor; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) { - commands.get(command.getName()).execute(sender, command.getName(), parameters); - return true; - } - - @Override - public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { - return commands.get(command.getName()).onTabComplete(sender, command, label, args); - } - - public static void initialize() { - commandExecutor = new VentureCommandExecutor(); - commands.put("broadcast", new Broadcast()); - commands.put("channel", new Channel()); - commands.put("join", new Channel()); - commands.put("channelinfo", new Channelinfo()); - commands.put("chatinfo", new Chatinfo()); - commands.put("chatreload", new Chatreload()); - commands.put("chlist", new Chlist()); - commands.put("chwho", new Chwho()); - commands.put("clearchat", new Clearchat()); - commands.put("commandblock", new Commandblock()); - commands.put("commandspy", new Commandspy()); - commands.put("config", new Config()); - commands.put("edit", new Edit()); - commands.put("filter", new Filter()); - commands.put("force", new Force()); - commands.put("forceall", new Forceall()); - commands.put("kickchannel", new Kickchannel()); - commands.put("kickchannelall", new Kickchannelall()); - commands.put("leave", new Leave()); - commands.put("listen", new Listen()); - commands.put("me", new Me()); - commands.put("venturechat", new Venturechat()); - commands.put("setnickname", new Nick()); - commands.put("notifications", new Notifications()); - commands.put("party", new Party()); - commands.put("rangedspy", new RangedSpy()); - commands.put("removemessage", new Removemessage()); - commands.put("setchannel", new Setchannel()); - commands.put("setchannelall", new Setchannelall()); - commands.put("spy", new Spy()); - commands.put("venturechatgui", new VentureChatGui()); - commands.put("messagetoggle", new MessageToggle()); - commands.put("bungeetoggle", new BungeeToggle()); - for(String command : commands.keySet()) { - registerCommand(command, commandExecutor); - } - - plugin.getServer().getScheduler().runTaskLater(plugin, () -> { - VentureCommand reply = new Reply(); - commands.put("reply", reply); - commands.put("r", reply); - registerCommand("reply", commandExecutor); - registerCommand("r", commandExecutor); - - commands.put("mute", new Mute()); - commands.put("muteall", new Muteall()); - commands.put("unmute", new Unmute()); - commands.put("unmuteall", new Unmuteall()); - registerCommand("mute", commandExecutor); - registerCommand("muteall", commandExecutor); - registerCommand("unmute", commandExecutor); - registerCommand("unmuteall", commandExecutor); - - MessageCommandExecutor messageCommandExecutor = new MessageCommandExecutor(); - registerCommand("message", messageCommandExecutor); - registerCommand("msg", messageCommandExecutor); - registerCommand("tell", messageCommandExecutor); - registerCommand("whisper", messageCommandExecutor); - - registerCommand("ignore", new IgnoreCommandExecutor()); - }, 0); - } - - private static void registerCommand(String command, CommandExecutor commandExecutor) { - if(plugin.getCommand(command) != null) { - plugin.getCommand(command).setExecutor(commandExecutor); - } - } -} diff --git a/src/mineverse/Aust1n46/chat/command/chat/Chatreload.java b/src/mineverse/Aust1n46/chat/command/chat/Chatreload.java deleted file mode 100644 index 038b7b8..0000000 --- a/src/mineverse/Aust1n46/chat/command/chat/Chatreload.java +++ /dev/null @@ -1,60 +0,0 @@ -package mineverse.Aust1n46.chat.command.chat; - -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import mineverse.Aust1n46.chat.MineverseChat; -import mineverse.Aust1n46.chat.api.MineverseChatAPI; -import mineverse.Aust1n46.chat.api.MineverseChatPlayer; -import mineverse.Aust1n46.chat.command.VentureCommand; -import mineverse.Aust1n46.chat.database.PlayerData; -import mineverse.Aust1n46.chat.localization.LocalizedMessage; -import mineverse.Aust1n46.chat.utilities.Format; - -public class Chatreload implements VentureCommand { - private MineverseChat plugin = MineverseChat.getInstance(); - - @Override - public void execute(CommandSender sender, String command, String[] args) { - if(sender.hasPermission("venturechat.reload")) { - PlayerData.savePlayerData(); - MineverseChatAPI.clearMineverseChatPlayerMap(); - MineverseChatAPI.clearNameMap(); - MineverseChatAPI.clearOnlineMineverseChatPlayerMap(); - - plugin.reloadConfig(); - MineverseChat.initializeConfigReaders(); - - PlayerData.loadLegacyPlayerData(); - PlayerData.loadPlayerData(); - for(Player p : plugin.getServer().getOnlinePlayers()) { - MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(p); - if(mcp == null) { - Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Could not find player data post reload for currently online player: " + p.getName())); - Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - There could be an issue with your player data saving.")); - String name = p.getName(); - UUID uuid = p.getUniqueId(); - mcp = new MineverseChatPlayer(uuid, name); - } - mcp.setOnline(true); - mcp.setHasPlayed(false); - mcp.setJsonFormat(); - MineverseChatAPI.addMineverseChatOnlinePlayerToMap(mcp); - MineverseChatAPI.addNameToMap(mcp); - } - - Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Config reloaded")); - for(MineverseChatPlayer player : MineverseChatAPI.getOnlineMineverseChatPlayers()) { - if(player.getPlayer().hasPermission("venturechat.reload")) { - player.getPlayer().sendMessage(LocalizedMessage.CONFIG_RELOADED.toString()); - } - } - return; - } - sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString()); - return; - } -}