Resolve more merge conflicts due to file system layout change.

This commit is contained in:
Aust1n46 2021-07-29 23:45:17 -04:00
parent 81ffcda38b
commit d20e2c0535
9 changed files with 4246 additions and 4213 deletions

View File

@ -105,34 +105,15 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Checking for Vault..."));
if(!setupPermissions() || !setupChat()) {
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - &cCould not find Vault dependency, disabling."));
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - &cCould not find Vault and/or a Vault compatible permissions plugin!"));
Bukkit.getPluginManager().disablePlugin(this);
}
Localization.initialize();
Alias.initialize();
JsonFormat.initialize();
GuiSlot.initialize();
ChatChannel.initialize(false);
initializeConfigReaders();
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - Loading player data"));
PlayerData.loadLegacyPlayerData();
PlayerData.loadPlayerData();
for(Player p : 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.getScheduler().runTaskAsynchronously(this, () -> {
Database.initializeMySQL();
@ -259,6 +240,14 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
return getPlugin(MineverseChat.class);
}
public static void initializeConfigReaders() {
Localization.initialize();
Alias.initialize();
JsonFormat.initialize();
GuiSlot.initialize();
ChatChannel.initialize(false);
}
public static Chat getVaultChat() {
return chat;
}

View File

@ -19,436 +19,439 @@ import mineverse.Aust1n46.chat.utilities.Format;
* @author Aust1n46
*/
public class ChatChannel {
private static final String PERMISSION_PREFIX = "venturechat.";
private static final String NO_PERMISSIONS = "venturechat.none";
private static final String PERMISSION_PREFIX = "venturechat.";
private static final String NO_PERMISSIONS = "venturechat.none";
private static MineverseChat plugin = MineverseChat.getInstance();
private static ChatChannel defaultChatChannel;
private static boolean aliasesRegisteredAsCommands;
private static boolean aliasesRegisteredAsCommands;
@Deprecated
private static ChatChannel[] channels;
private static MineverseChat plugin = MineverseChat.getInstance();
private static ChatChannel defaultChatChannel;
private static String defaultColor;
private static HashMap<String, ChatChannel> chatChannels;
private static String defaultColor;
private static HashMap<String, ChatChannel> 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;
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<String, ChatChannel>();
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;
}
}
}
/**
* Read chat channels from config file and initialize channel array.
*/
public static void initialize(boolean aliasesRegisteredAsCommands) {
chatChannels = new HashMap<String, ChatChannel>();
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;
}
public static boolean areAliasesRegisteredAsCommands() {
return aliasesRegisteredAsCommands;
}
/**
* Get array of chat channels.
*
* @return {@link ChatChannel}[]
*/
@Deprecated
public static ChatChannel[] getChannels() {
return channels;
}
/**
* Get array of chat channels.
*
* @return {@link ChatChannel}[]
*/
@Deprecated
public static ChatChannel[] getChannels() {
return channels;
}
/**
* Get list of chat channels.
*
* @return {@link Collection}&lt{@link ChatChannel}&gt
*/
public static Collection<ChatChannel> getChatChannels() {
return new HashSet<ChatChannel>(chatChannels.values());
}
/**
* Get list of chat channels.
*
* @return {@link Collection}&lt{@link ChatChannel}&gt
*/
public static Collection<ChatChannel> getChatChannels() {
return new HashSet<ChatChannel>(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());
}
/**
* 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;
}
/**
* 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 color.
*
* @return {@link String}
*/
public static String getDefaultColor() {
return defaultColor;
}
/**
* Get default chat channel.
*
* @return {@link ChatChannel}
*/
public static ChatChannel getDefaultChannel() {
return defaultChatChannel;
}
/**
* 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}&lt{@link ChatChannel}&gt
*/
public static List<ChatChannel> getAutojoinList() {
List<ChatChannel> joinlist = new ArrayList<ChatChannel>();
for (ChatChannel c : channels) {
if (c.getAutojoin()) {
joinlist.add(c);
}
}
return joinlist;
}
/**
* Get list of chat channels with autojoin set to true.
*
* @return {@link List}&lt{@link ChatChannel}&gt
*/
public static List<ChatChannel> getAutojoinList() {
List<ChatChannel> joinlist = new ArrayList<ChatChannel>();
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;
}
/**
* 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;
}
/**
* 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 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 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;
}
/**
* 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);
}
/**
* 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;
}
/**
* 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 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);
}
/**
* 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 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 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 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;
}
/**
* 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);
}
/**
* 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 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);
}
/**
* 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 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 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 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);
}
/**
* 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;
}
/**
* 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);
}
/**
* 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());
}
/**
* 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());
}
}

View File

@ -5,6 +5,7 @@ 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;
@ -53,82 +54,89 @@ import mineverse.Aust1n46.chat.command.mute.Unmuteall;
* Class that initializes and executes the plugin's commands.
*/
public class VentureCommandExecutor implements TabExecutor {
private static Map<String, VentureCommand> commands = new HashMap<String, VentureCommand>();
private static MineverseChat plugin = MineverseChat.getInstance();
private static VentureCommandExecutor commandExecutor;
private static Map<String, VentureCommand> commands = new HashMap<String, VentureCommand>();
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 boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) {
commands.get(command.getName()).execute(sender, command.getName(), parameters);
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return commands.get(command.getName()).onTabComplete(sender, command, label, args);
}
@Override
public List<String> 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()) {
plugin.getCommand(command).setExecutor(commandExecutor);
}
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);
plugin.getCommand("reply").setExecutor(commandExecutor);
plugin.getCommand("r").setExecutor(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());
plugin.getCommand("mute").setExecutor(commandExecutor);
plugin.getCommand("muteall").setExecutor(commandExecutor);
plugin.getCommand("unmute").setExecutor(commandExecutor);
plugin.getCommand("unmuteall").setExecutor(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();
plugin.getCommand("message").setExecutor(messageCommandExecutor);
plugin.getCommand("msg").setExecutor(messageCommandExecutor);
plugin.getCommand("tell").setExecutor(messageCommandExecutor);
plugin.getCommand("whisper").setExecutor(messageCommandExecutor);
plugin.getCommand("ignore").setExecutor(new IgnoreCommandExecutor());
}, 0);
}
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);
}
}
}

View File

@ -1,32 +1,60 @@
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();
private MineverseChat plugin = MineverseChat.getInstance();
@Override
public void execute(CommandSender sender, String command, String[] args) {
if (sender.hasPermission("venturechat.reload")) {
plugin.reloadConfig();
Bukkit.getPluginManager().disablePlugin(plugin);
Bukkit.getPluginManager().enablePlugin(plugin);
plugin.getServer().getLogger().info("[VentureChat] 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;
}
@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;
}
}

View File

@ -343,7 +343,7 @@ public class ChatListener implements Listener {
chDistance = eventChannel.getDistance();
}
format = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(plugin.getConfig().getConfigurationSection("channels." + eventChannel.getName()).getString("format"))));
format = Format.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(eventChannel.getFormat())));
if(plugin.getConfig().getBoolean("formatcleaner", false)) {
format = format.replace("[]", " ");
format = format.replace(" ", " ").replace(" ", " ").replace(" ", " ");

View File

@ -892,8 +892,11 @@ public class Format {
public static void playMessageSound(MineverseChatPlayer mcp) {
Player player = mcp.getPlayer();
Sound messageSound = getSound(getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND));
player.playSound(player.getLocation(), messageSound, 1, 0);
String soundName = getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND);
if(!soundName.equalsIgnoreCase("None")) {
Sound messageSound = getSound(soundName);
player.playSound(player.getLocation(), messageSound, 1, 0);
}
}
private static Sound getSound(String soundName) {

View File

@ -100,6 +100,7 @@ unmuteinterval: 60
bungeecordmessaging: false
# Sound for message notification
# Enter 'None' to disable the sound
message_sound: ENTITY_PLAYER_LEVELUP
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online

View File

@ -100,6 +100,7 @@ unmuteinterval: 60
bungeecordmessaging: false
# Sound for message notification
# Enter 'None' to disable the sound
message_sound: ENTITY_PLAYER_LEVELUP
# This will allow vanished players to be exempt from being sent private messages, and will act as if they aren't online