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

View File

@ -19,436 +19,439 @@ import mineverse.Aust1n46.chat.utilities.Format;
* @author Aust1n46 * @author Aust1n46
*/ */
public class ChatChannel { public class ChatChannel {
private static final String PERMISSION_PREFIX = "venturechat."; private static final String PERMISSION_PREFIX = "venturechat.";
private static final String NO_PERMISSIONS = "venturechat.none"; private static final String NO_PERMISSIONS = "venturechat.none";
private static MineverseChat plugin = MineverseChat.getInstance(); private static boolean aliasesRegisteredAsCommands;
private static ChatChannel defaultChatChannel;
private static boolean aliasesRegisteredAsCommands;
@Deprecated private static MineverseChat plugin = MineverseChat.getInstance();
private static ChatChannel[] channels; private static ChatChannel defaultChatChannel;
private static String defaultColor;
private static HashMap<String, ChatChannel> chatChannels;
private static String defaultColor; @Deprecated
private static HashMap<String, ChatChannel> chatChannels; private static ChatChannel[] channels;
private String name; private String name;
private String permission; private String permission;
private String speakPermission; private String speakPermission;
private boolean mutable; private boolean mutable;
private String color; private String color;
private String chatColor; private String chatColor;
private boolean defaultChannel; private boolean defaultChannel;
private boolean autojoin; private boolean autojoin;
private String alias; private String alias;
private double distance; private double distance;
private boolean filter; private boolean filter;
private boolean bungee; private boolean bungee;
private String format; private String format;
private int cooldown; private int cooldown;
/** /**
* Read chat channels from config file and initialize channel array. * Read chat channels from config file and initialize channel array.
*/ */
public static void initialize(boolean aliasesRegisteredAsCommands) { public static void initialize(boolean aliasesRegisteredAsCommands) {
chatChannels = new HashMap<String, ChatChannel>(); chatChannels = new HashMap<String, ChatChannel>();
ChatChannel.aliasesRegisteredAsCommands = aliasesRegisteredAsCommands; ChatChannel.aliasesRegisteredAsCommands = aliasesRegisteredAsCommands;
ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels"); ConfigurationSection cs = plugin.getConfig().getConfigurationSection("channels");
int len = (cs.getKeys(false)).size(); int len = (cs.getKeys(false)).size();
channels = new ChatChannel[len]; channels = new ChatChannel[len];
int counter = 0; int counter = 0;
for (String key : cs.getKeys(false)) { for (String key : cs.getKeys(false)) {
String color = cs.getString(key + ".color", "white"); String color = cs.getString(key + ".color", "white");
String chatColor = cs.getString(key + ".chatcolor", "white"); String chatColor = cs.getString(key + ".chatcolor", "white");
String name = key; String name = key;
String permission = cs.getString(key + ".permissions", "None"); String permission = cs.getString(key + ".permissions", "None");
String speakPermission = cs.getString(key + ".speak_permissions", "None"); String speakPermission = cs.getString(key + ".speak_permissions", "None");
boolean mutable = cs.getBoolean(key + ".mutable", false); boolean mutable = cs.getBoolean(key + ".mutable", false);
boolean filter = cs.getBoolean(key + ".filter", true); boolean filter = cs.getBoolean(key + ".filter", true);
boolean bungee = cs.getBoolean(key + ".bungeecord", false); boolean bungee = cs.getBoolean(key + ".bungeecord", false);
String format = cs.getString(key + ".format", "Default"); String format = cs.getString(key + ".format", "Default");
boolean defaultChannel = cs.getBoolean(key + ".default", false); boolean defaultChannel = cs.getBoolean(key + ".default", false);
String alias = cs.getString(key + ".alias", "None"); String alias = cs.getString(key + ".alias", "None");
double distance = cs.getDouble(key + ".distance", (double) 0); double distance = cs.getDouble(key + ".distance", (double) 0);
int cooldown = cs.getInt(key + ".cooldown", 0); int cooldown = cs.getInt(key + ".cooldown", 0);
boolean autojoin = cs.getBoolean(key + ".autojoin", false); boolean autojoin = cs.getBoolean(key + ".autojoin", false);
ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable, ChatChannel chatChannel = new ChatChannel(name, color, chatColor, permission, speakPermission, mutable,
filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format); filter, defaultChannel, alias, distance, autojoin, bungee, cooldown, format);
channels[counter++] = chatChannel; channels[counter++] = chatChannel;
chatChannels.put(name.toLowerCase(), chatChannel); chatChannels.put(name.toLowerCase(), chatChannel);
chatChannels.put(alias.toLowerCase(), chatChannel); chatChannels.put(alias.toLowerCase(), chatChannel);
if (defaultChannel) { if (defaultChannel) {
defaultChatChannel = chatChannel; defaultChatChannel = chatChannel;
defaultColor = color; defaultColor = color;
} }
} }
} }
public static boolean areAliasesRegisteredAsCommands() { public static boolean areAliasesRegisteredAsCommands() {
return aliasesRegisteredAsCommands; return aliasesRegisteredAsCommands;
} }
/** /**
* Get array of chat channels. * Get array of chat channels.
* *
* @return {@link ChatChannel}[] * @return {@link ChatChannel}[]
*/ */
@Deprecated @Deprecated
public static ChatChannel[] getChannels() { public static ChatChannel[] getChannels() {
return channels; return channels;
} }
/** /**
* Get list of chat channels. * Get list of chat channels.
* *
* @return {@link Collection}&lt{@link ChatChannel}&gt * @return {@link Collection}&lt{@link ChatChannel}&gt
*/ */
public static Collection<ChatChannel> getChatChannels() { public static Collection<ChatChannel> getChatChannels() {
return new HashSet<ChatChannel>(chatChannels.values()); return new HashSet<ChatChannel>(chatChannels.values());
} }
/** /**
* Get a chat channel by name. * Get a chat channel by name.
* *
* @param channelName name of channel to get. * @param channelName
* @return {@link ChatChannel} * name of channel to get.
*/ * @return {@link ChatChannel}
public static ChatChannel getChannel(String channelName) { */
return chatChannels.get(channelName.toLowerCase()); public static ChatChannel getChannel(String channelName) {
} return chatChannels.get(channelName.toLowerCase());
}
/** /**
* Checks if the chat channel exists. * Checks if the chat channel exists.
* *
* @param channelName name of channel to check. * @param channelName
* @return true if channel exists, false otherwise. * name of channel to check.
*/ * @return true if channel exists, false otherwise.
public static boolean isChannel(String channelName) { */
return getChannel(channelName) != null; public static boolean isChannel(String channelName) {
} return getChannel(channelName) != null;
}
/** /**
* Get default chat channel color. * Get default chat channel color.
* *
* @return {@link String} * @return {@link String}
*/ */
public static String getDefaultColor() { public static String getDefaultColor() {
return defaultColor; return defaultColor;
} }
/** /**
* Get default chat channel. * Get default chat channel.
* *
* @return {@link ChatChannel} * @return {@link ChatChannel}
*/ */
public static ChatChannel getDefaultChannel() { public static ChatChannel getDefaultChannel() {
return defaultChatChannel; return defaultChatChannel;
} }
/** /**
* Get list of chat channels with autojoin set to true. * Get list of chat channels with autojoin set to true.
* *
* @return {@link List}&lt{@link ChatChannel}&gt * @return {@link List}&lt{@link ChatChannel}&gt
*/ */
public static List<ChatChannel> getAutojoinList() { public static List<ChatChannel> getAutojoinList() {
List<ChatChannel> joinlist = new ArrayList<ChatChannel>(); List<ChatChannel> joinlist = new ArrayList<ChatChannel>();
for (ChatChannel c : channels) { for (ChatChannel c : channels) {
if (c.getAutojoin()) { if (c.getAutojoin()) {
joinlist.add(c); joinlist.add(c);
} }
} }
return joinlist; return joinlist;
} }
/** /**
* Parameterized constructor a {@link ChatChannel}. * Parameterized constructor a {@link ChatChannel}.
* *
* @param name * @param name
* @param color * @param color
* @param chatColor * @param chatColor
* @param permission * @param permission
* @param speakPermission * @param speakPermission
* @param mutable * @param mutable
* @param filter * @param filter
* @param defaultChannel * @param defaultChannel
* @param alias * @param alias
* @param distance * @param distance
* @param autojoin * @param autojoin
* @param bungee * @param bungee
* @param cooldown * @param cooldown
* @param format * @param format
*/ */
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission, 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 mutable, boolean filter, boolean defaultChannel, String alias, double distance, boolean autojoin,
boolean bungee, int cooldown, String format) { boolean bungee, int cooldown, String format) {
this.name = name; this.name = name;
this.color = color; this.color = color;
this.chatColor = chatColor; this.chatColor = chatColor;
this.permission = PERMISSION_PREFIX + permission; this.permission = PERMISSION_PREFIX + permission;
this.speakPermission = PERMISSION_PREFIX + speakPermission; this.speakPermission = PERMISSION_PREFIX + speakPermission;
this.mutable = mutable; this.mutable = mutable;
this.filter = filter; this.filter = filter;
this.defaultChannel = defaultChannel; this.defaultChannel = defaultChannel;
this.alias = alias; this.alias = alias;
this.distance = distance; this.distance = distance;
this.autojoin = autojoin; this.autojoin = autojoin;
this.bungee = bungee; this.bungee = bungee;
this.cooldown = cooldown; this.cooldown = cooldown;
this.format = format; this.format = format;
} }
/** /**
* Deprecated parameterized constructor a {@link ChatChannel}. * Deprecated parameterized constructor a {@link ChatChannel}.
* *
* @param name * @param name
* @param color * @param color
* @param chatColor * @param chatColor
* @param permission * @param permission
* @param speakPermission * @param speakPermission
* @param mutable * @param mutable
* @param filter * @param filter
* @param defaultChannel * @param defaultChannel
* @param alias * @param alias
* @param distance * @param distance
* @param autojoin * @param autojoin
* @param bungee * @param bungee
* @param cooldown * @param cooldown
* @param format * @param format
*/ */
@Deprecated @Deprecated
public ChatChannel(String name, String color, String chatColor, String permission, String speakPermission, 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 mutable, Boolean filter, Boolean defaultChannel, String alias, Double distance, Boolean autojoin,
Boolean bungee, int cooldown, String format) { Boolean bungee, int cooldown, String format) {
this.name = name; this.name = name;
this.color = color; this.color = color;
this.chatColor = chatColor; this.chatColor = chatColor;
this.permission = PERMISSION_PREFIX + permission; this.permission = PERMISSION_PREFIX + permission;
this.speakPermission = PERMISSION_PREFIX + speakPermission; this.speakPermission = PERMISSION_PREFIX + speakPermission;
this.mutable = mutable; this.mutable = mutable;
this.filter = filter; this.filter = filter;
this.defaultChannel = defaultChannel; this.defaultChannel = defaultChannel;
this.alias = alias; this.alias = alias;
this.distance = distance; this.distance = distance;
this.autojoin = autojoin; this.autojoin = autojoin;
this.bungee = bungee; this.bungee = bungee;
this.cooldown = cooldown; this.cooldown = cooldown;
this.format = format; this.format = format;
} }
/** /**
* Get the name of the chat channel. * Get the name of the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* Get the format of the chat channel. * Get the format of the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getFormat() { public String getFormat() {
return format; return format;
} }
/** /**
* Get the cooldown of the chat channel in seconds. * Get the cooldown of the chat channel in seconds.
* *
* @return int * @return int
*/ */
public int getCooldown() { public int getCooldown() {
return cooldown; return cooldown;
} }
/** /**
* Check if the chat channel is BungeeCord enabled. * Check if the chat channel is BungeeCord enabled.
* *
* @return {@link Boolean#TRUE} if the chat channel is BungeeCord enabled, * @return {@link Boolean#TRUE} if the chat channel is BungeeCord enabled,
* {@link Boolean#FALSE} otherwise. * {@link Boolean#FALSE} otherwise.
*/ */
public Boolean getBungee() { public Boolean getBungee() {
return Boolean.valueOf(bungee); return Boolean.valueOf(bungee);
} }
/** /**
* Get the permissions node for the chat channel. * Get the permissions node for the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getPermission() { public String getPermission() {
return permission; return permission;
} }
/** /**
* Check if autojoin is enabled for the chat channel. * Check if autojoin is enabled for the chat channel.
* *
* @return {@link Boolean#TRUE} if autojoin is enabled, {@link Boolean#FALSE} * @return {@link Boolean#TRUE} if autojoin is enabled, {@link Boolean#FALSE}
* otherwise. * otherwise.
*/ */
public Boolean getAutojoin() { public Boolean getAutojoin() {
return Boolean.valueOf(autojoin); return Boolean.valueOf(autojoin);
} }
/** /**
* Check if the chat channel allows muting. * Check if the chat channel allows muting.
* *
* @return {@link Boolean#TRUE} if muting is allowed, {@link Boolean#FALSE} * @return {@link Boolean#TRUE} if muting is allowed, {@link Boolean#FALSE}
* otherwise. * otherwise.
*/ */
public Boolean isMutable() { public Boolean isMutable() {
return Boolean.valueOf(mutable); return Boolean.valueOf(mutable);
} }
/** /**
* Get the formatted color of the chat channel. * Get the formatted color of the chat channel.
* *
* @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the * @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the
* color is invalid. * color is invalid.
*/ */
public String getColor() { public String getColor() {
if (Format.isValidColor(color)) { if (Format.isValidColor(color)) {
return String.valueOf(ChatColor.valueOf(color.toUpperCase())); return String.valueOf(ChatColor.valueOf(color.toUpperCase()));
} }
if (Format.isValidHexColor(color)) { if (Format.isValidHexColor(color)) {
return Format.convertHexColorCodeToBukkitColorCode(color); return Format.convertHexColorCodeToBukkitColorCode(color);
} }
return Format.DEFAULT_COLOR_CODE; return Format.DEFAULT_COLOR_CODE;
} }
/** /**
* Get the raw color value of the chat channel. * Get the raw color value of the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getColorRaw() { public String getColorRaw() {
return color; return color;
} }
/** /**
* Get the formatted chat color of the chat channel. * Get the formatted chat color of the chat channel.
* *
* @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the chat * @return {@link String}. Returns {@link Format#DEFAULT_COLOR_CODE} if the chat
* color is invalid. * color is invalid.
*/ */
public String getChatColor() { public String getChatColor() {
if (chatColor.equalsIgnoreCase("None")) { if (chatColor.equalsIgnoreCase("None")) {
return chatColor; return chatColor;
} }
if (Format.isValidColor(chatColor)) { if (Format.isValidColor(chatColor)) {
return String.valueOf(ChatColor.valueOf(chatColor.toUpperCase())); return String.valueOf(ChatColor.valueOf(chatColor.toUpperCase()));
} }
if (Format.isValidHexColor(chatColor)) { if (Format.isValidHexColor(chatColor)) {
return Format.convertHexColorCodeToBukkitColorCode(chatColor); return Format.convertHexColorCodeToBukkitColorCode(chatColor);
} }
return Format.DEFAULT_COLOR_CODE; return Format.DEFAULT_COLOR_CODE;
} }
/** /**
* Get the raw chat color value of the chat channel. * Get the raw chat color value of the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getChatColorRaw() { public String getChatColorRaw() {
return chatColor; return chatColor;
} }
/** /**
* Check if the chat channel is the default chat channel. * Check if the chat channel is the default chat channel.
* *
* @return {@link Boolean#TRUE} 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. * {@link Boolean#FALSE} otherwise.
*/ */
public Boolean isDefaultchannel() { public Boolean isDefaultchannel() {
return Boolean.valueOf(defaultChannel); return Boolean.valueOf(defaultChannel);
} }
/** /**
* Get the alias of the chat channel. * Get the alias of the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getAlias() { public String getAlias() {
return alias; return alias;
} }
/** /**
* Get the distance of the chat channel in blocks. * Get the distance of the chat channel in blocks.
* *
* @return {@link Double} * @return {@link Double}
*/ */
public Double getDistance() { public Double getDistance() {
return Double.valueOf(distance); return Double.valueOf(distance);
} }
/** /**
* Checks if the chat channel has a distance set. * Checks if the chat channel has a distance set.
* *
* @return {@link Boolean#TRUE} if the distance is greater than zero, * @return {@link Boolean#TRUE} if the distance is greater than zero,
* {@link Boolean#FALSE} otherwise. * {@link Boolean#FALSE} otherwise.
*/ */
public Boolean hasDistance() { public Boolean hasDistance() {
return Boolean.valueOf(distance > 0); return Boolean.valueOf(distance > 0);
} }
/** /**
* Checks if the chat channel has a cooldown set. * Checks if the chat channel has a cooldown set.
* *
* @return {@link Boolean#TRUE} if the cooldown is greater than zero, * @return {@link Boolean#TRUE} if the cooldown is greater than zero,
* {@link Boolean#FALSE} otherwise. * {@link Boolean#FALSE} otherwise.
*/ */
public Boolean hasCooldown() { public Boolean hasCooldown() {
return Boolean.valueOf(cooldown > 0); return Boolean.valueOf(cooldown > 0);
} }
/** /**
* Checks if the chat channel has a permission set. * Checks if the chat channel has a permission set.
* *
* @return {@link Boolean#TRUE} if the permission does not equal * @return {@link Boolean#TRUE} if the permission does not equal
* {@link ChatChannel#NO_PERMISSIONS}, {@link Boolean#FALSE} otherwise. * {@link ChatChannel#NO_PERMISSIONS}, {@link Boolean#FALSE} otherwise.
*/ */
public Boolean hasPermission() { public Boolean hasPermission() {
return Boolean.valueOf(!permission.equalsIgnoreCase(NO_PERMISSIONS)); return Boolean.valueOf(!permission.equalsIgnoreCase(NO_PERMISSIONS));
} }
/** /**
* Checks if the chat channel has a speak permission set. * Checks if the chat channel has a speak permission set.
* *
* @return true if the speak permission does not equal * @return true if the speak permission does not equal
* {@link ChatChannel#NO_PERMISSIONS}, false otherwise. * {@link ChatChannel#NO_PERMISSIONS}, false otherwise.
*/ */
public boolean hasSpeakPermission() { public boolean hasSpeakPermission() {
return !speakPermission.equalsIgnoreCase(NO_PERMISSIONS); return !speakPermission.equalsIgnoreCase(NO_PERMISSIONS);
} }
/** /**
* Get the speak permissions node for the chat channel. * Get the speak permissions node for the chat channel.
* *
* @return {@link String} * @return {@link String}
*/ */
public String getSpeakPermission() { public String getSpeakPermission() {
return speakPermission; return speakPermission;
} }
/** /**
* Checks if the chat channel has the filter enabled. * Checks if the chat channel has the filter enabled.
* *
* @return {@link Boolean#TRUE} if the chat channel has the filter enabled, * @return {@link Boolean#TRUE} if the chat channel has the filter enabled,
* {@link Boolean#FALSE} otherwise. * {@link Boolean#FALSE} otherwise.
*/ */
public Boolean isFiltered() { public Boolean isFiltered() {
return Boolean.valueOf(filter); return Boolean.valueOf(filter);
} }
/** /**
* Compares the chat channel by name to determine equality. * Compares the chat channel by name to determine equality.
* *
* @param channel Object to compare for equality. * @param channel
* @return true if the objects are equal, false otherwise. * Object to compare for equality.
*/ * @return true if the objects are equal, false otherwise.
@Override */
public boolean equals(Object channel) { @Override
return channel instanceof ChatChannel && this.name.equals(((ChatChannel) channel).getName()); 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 java.util.Map;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; 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. * Class that initializes and executes the plugin's commands.
*/ */
public class VentureCommandExecutor implements TabExecutor { public class VentureCommandExecutor implements TabExecutor {
private static Map<String, VentureCommand> commands = new HashMap<String, VentureCommand>(); private static Map<String, VentureCommand> commands = new HashMap<String, VentureCommand>();
private static MineverseChat plugin = MineverseChat.getInstance(); private static MineverseChat plugin = MineverseChat.getInstance();
private static VentureCommandExecutor commandExecutor; private static VentureCommandExecutor commandExecutor;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) { public boolean onCommand(CommandSender sender, Command command, String label, String[] parameters) {
commands.get(command.getName()).execute(sender, command.getName(), parameters); commands.get(command.getName()).execute(sender, command.getName(), parameters);
return true; return true;
} }
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return commands.get(command.getName()).onTabComplete(sender, command, label, args); return commands.get(command.getName()).onTabComplete(sender, command, label, args);
} }
public static void initialize() { public static void initialize() {
commandExecutor = new VentureCommandExecutor(); commandExecutor = new VentureCommandExecutor();
commands.put("broadcast", new Broadcast()); commands.put("broadcast", new Broadcast());
commands.put("channel", new Channel()); commands.put("channel", new Channel());
commands.put("join", new Channel()); commands.put("join", new Channel());
commands.put("channelinfo", new Channelinfo()); commands.put("channelinfo", new Channelinfo());
commands.put("chatinfo", new Chatinfo()); commands.put("chatinfo", new Chatinfo());
commands.put("chatreload", new Chatreload()); commands.put("chatreload", new Chatreload());
commands.put("chlist", new Chlist()); commands.put("chlist", new Chlist());
commands.put("chwho", new Chwho()); commands.put("chwho", new Chwho());
commands.put("clearchat", new Clearchat()); commands.put("clearchat", new Clearchat());
commands.put("commandblock", new Commandblock()); commands.put("commandblock", new Commandblock());
commands.put("commandspy", new Commandspy()); commands.put("commandspy", new Commandspy());
commands.put("config", new Config()); commands.put("config", new Config());
commands.put("edit", new Edit()); commands.put("edit", new Edit());
commands.put("filter", new Filter()); commands.put("filter", new Filter());
commands.put("force", new Force()); commands.put("force", new Force());
commands.put("forceall", new Forceall()); commands.put("forceall", new Forceall());
commands.put("kickchannel", new Kickchannel()); commands.put("kickchannel", new Kickchannel());
commands.put("kickchannelall", new Kickchannelall()); commands.put("kickchannelall", new Kickchannelall());
commands.put("leave", new Leave()); commands.put("leave", new Leave());
commands.put("listen", new Listen()); commands.put("listen", new Listen());
commands.put("me", new Me()); commands.put("me", new Me());
commands.put("venturechat", new Venturechat()); commands.put("venturechat", new Venturechat());
commands.put("setnickname", new Nick()); commands.put("setnickname", new Nick());
commands.put("notifications", new Notifications()); commands.put("notifications", new Notifications());
commands.put("party", new Party()); commands.put("party", new Party());
commands.put("rangedspy", new RangedSpy()); commands.put("rangedspy", new RangedSpy());
commands.put("removemessage", new Removemessage()); commands.put("removemessage", new Removemessage());
commands.put("setchannel", new Setchannel()); commands.put("setchannel", new Setchannel());
commands.put("setchannelall", new Setchannelall()); commands.put("setchannelall", new Setchannelall());
commands.put("spy", new Spy()); commands.put("spy", new Spy());
commands.put("venturechatgui", new VentureChatGui()); commands.put("venturechatgui", new VentureChatGui());
commands.put("messagetoggle", new MessageToggle()); commands.put("messagetoggle", new MessageToggle());
commands.put("bungeetoggle", new BungeeToggle()); commands.put("bungeetoggle", new BungeeToggle());
for (String command : commands.keySet()) { for(String command : commands.keySet()) {
plugin.getCommand(command).setExecutor(commandExecutor); registerCommand(command, commandExecutor);
} }
plugin.getServer().getScheduler().runTaskLater(plugin, () -> { plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
VentureCommand reply = new Reply(); VentureCommand reply = new Reply();
commands.put("reply", reply); commands.put("reply", reply);
commands.put("r", reply); commands.put("r", reply);
plugin.getCommand("reply").setExecutor(commandExecutor); registerCommand("reply", commandExecutor);
plugin.getCommand("r").setExecutor(commandExecutor); registerCommand("r", commandExecutor);
commands.put("mute", new Mute()); commands.put("mute", new Mute());
commands.put("muteall", new Muteall()); commands.put("muteall", new Muteall());
commands.put("unmute", new Unmute()); commands.put("unmute", new Unmute());
commands.put("unmuteall", new Unmuteall()); commands.put("unmuteall", new Unmuteall());
plugin.getCommand("mute").setExecutor(commandExecutor); registerCommand("mute", commandExecutor);
plugin.getCommand("muteall").setExecutor(commandExecutor); registerCommand("muteall", commandExecutor);
plugin.getCommand("unmute").setExecutor(commandExecutor); registerCommand("unmute", commandExecutor);
plugin.getCommand("unmuteall").setExecutor(commandExecutor); registerCommand("unmuteall", commandExecutor);
MessageCommandExecutor messageCommandExecutor = new MessageCommandExecutor(); MessageCommandExecutor messageCommandExecutor = new MessageCommandExecutor();
plugin.getCommand("message").setExecutor(messageCommandExecutor); registerCommand("message", messageCommandExecutor);
plugin.getCommand("msg").setExecutor(messageCommandExecutor); registerCommand("msg", messageCommandExecutor);
plugin.getCommand("tell").setExecutor(messageCommandExecutor); registerCommand("tell", messageCommandExecutor);
plugin.getCommand("whisper").setExecutor(messageCommandExecutor); registerCommand("whisper", messageCommandExecutor);
plugin.getCommand("ignore").setExecutor(new IgnoreCommandExecutor());
}, 0); 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; package mineverse.Aust1n46.chat.command.chat;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import mineverse.Aust1n46.chat.MineverseChat; import mineverse.Aust1n46.chat.MineverseChat;
import mineverse.Aust1n46.chat.api.MineverseChatAPI; import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.MineverseChatPlayer; import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.command.VentureCommand; import mineverse.Aust1n46.chat.command.VentureCommand;
import mineverse.Aust1n46.chat.database.PlayerData;
import mineverse.Aust1n46.chat.localization.LocalizedMessage; import mineverse.Aust1n46.chat.localization.LocalizedMessage;
import mineverse.Aust1n46.chat.utilities.Format;
public class Chatreload implements VentureCommand { public class Chatreload implements VentureCommand {
private MineverseChat plugin = MineverseChat.getInstance(); private MineverseChat plugin = MineverseChat.getInstance();
@Override @Override
public void execute(CommandSender sender, String command, String[] args) { public void execute(CommandSender sender, String command, String[] args) {
if (sender.hasPermission("venturechat.reload")) { if(sender.hasPermission("venturechat.reload")) {
plugin.reloadConfig(); PlayerData.savePlayerData();
Bukkit.getPluginManager().disablePlugin(plugin); MineverseChatAPI.clearMineverseChatPlayerMap();
Bukkit.getPluginManager().enablePlugin(plugin); MineverseChatAPI.clearNameMap();
plugin.getServer().getLogger().info("[VentureChat] Config reloaded"); MineverseChatAPI.clearOnlineMineverseChatPlayerMap();
for (MineverseChatPlayer player : MineverseChatAPI.getOnlineMineverseChatPlayers()) {
if (player.getPlayer().hasPermission("venturechat.reload")) { plugin.reloadConfig();
player.getPlayer().sendMessage(LocalizedMessage.CONFIG_RELOADED.toString()); MineverseChat.initializeConfigReaders();
}
} PlayerData.loadLegacyPlayerData();
return; PlayerData.loadPlayerData();
} for(Player p : plugin.getServer().getOnlinePlayers()) {
sender.sendMessage(LocalizedMessage.COMMAND_NO_PERMISSION.toString()); MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(p);
return; 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(); 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)) { if(plugin.getConfig().getBoolean("formatcleaner", false)) {
format = format.replace("[]", " "); format = format.replace("[]", " ");
format = format.replace(" ", " ").replace(" ", " ").replace(" ", " "); format = format.replace(" ", " ").replace(" ", " ").replace(" ", " ");

View File

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

View File

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