Add error handling for missing default chat channel.

This commit is contained in:
Aust1n46 2021-07-30 23:17:31 -04:00
parent 408fe7c90d
commit dba9ab7d12
2 changed files with 13 additions and 1 deletions

View File

@ -42,6 +42,8 @@ Done###Add hex color support to message remover configuration
Done###Fix /chatreload Done###Fix /chatreload
Done###Add check for missing default channel
@ -105,4 +107,4 @@ Add custom JSON hovers to any placeholder
Add clans channel from SimpleClans Add clans channel from SimpleClans
Add check for missing default channel Look into changing Bukkit chat event to not be cancelled.

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -82,6 +83,15 @@ public class ChatChannel {
defaultColor = color; defaultColor = color;
} }
} }
// Error handling for missing default channel in the config.
if(defaultChatChannel == null) {
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&e - &cNo default channel found!"));
defaultChatChannel = new ChatChannel("MissingDefault", "red", "red", "None", "None", false,
true, true, "md", 0, true, false, 0, "&f[&cMissingDefault&f] {vault_prefix} {player_displayname}&c:");
defaultColor = defaultChatChannel.getColor();
chatChannels.put("missingdefault", defaultChatChannel);
chatChannels.put("md", defaultChatChannel);
}
} }
public static boolean areAliasesRegisteredAsCommands() { public static boolean areAliasesRegisteredAsCommands() {