From dda37373bb66b7fe69d3954c0a82c21f24bd4781 Mon Sep 17 00:00:00 2001 From: Joris Guffens Date: Sat, 16 Nov 2024 16:48:26 +0100 Subject: [PATCH] Fix issues with updated chat channel system --- .../bukkit/KingdomCraftBukkitPlugin.java | 10 +++++----- .../kingdomcraft/common/chat/ChatManagerImpl.java | 15 ++++++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bukkit/src/main/java/com/gufli/kingdomcraft/bukkit/KingdomCraftBukkitPlugin.java b/bukkit/src/main/java/com/gufli/kingdomcraft/bukkit/KingdomCraftBukkitPlugin.java index 8ab9fcaf..e644a0be 100644 --- a/bukkit/src/main/java/com/gufli/kingdomcraft/bukkit/KingdomCraftBukkitPlugin.java +++ b/bukkit/src/main/java/com/gufli/kingdomcraft/bukkit/KingdomCraftBukkitPlugin.java @@ -263,23 +263,23 @@ public void load() { kdc.getConfig().load(new BukkitConfiguration(config)); loadMessages(config.getString("language")); } else { - log("An error occured, cannot load config.yml", Level.WARNING); - kdc.getChatManager().load(getConfigResource("config.yml")); + log("An error occured, cannot load config.yml. Falling back to default values.", Level.WARNING); + kdc.getConfig().load(getConfigResource("config.yml")); } ConfigurationSection permissionsConfig = initConfig("permissions.yml"); if (permissionsConfig != null) { kdc.getPermissionManager().load(new BukkitConfiguration(permissionsConfig)); } else { - log("An error occured, cannot load permissions.yml", Level.WARNING); - kdc.getChatManager().load(getConfigResource("permissions.yml")); + log("An error occured, cannot load permissions.yml. Falling back to default values.", Level.WARNING); + kdc.getPermissionManager().load(getConfigResource("permissions.yml")); } ConfigurationSection chatConfig = initConfig("chat.yml"); if (chatConfig != null) { kdc.getChatManager().load(new BukkitConfiguration(chatConfig)); } else { - log("An error occured, cannot load chat.yml", Level.WARNING); + log("An error occured, cannot load chat.yml. Falling back to default values.", Level.WARNING); kdc.getChatManager().load(getConfigResource("chat.yml")); } diff --git a/common/src/main/java/com/gufli/kingdomcraft/common/chat/ChatManagerImpl.java b/common/src/main/java/com/gufli/kingdomcraft/common/chat/ChatManagerImpl.java index ab3ebdf4..a9c4c75c 100644 --- a/common/src/main/java/com/gufli/kingdomcraft/common/chat/ChatManagerImpl.java +++ b/common/src/main/java/com/gufli/kingdomcraft/common/chat/ChatManagerImpl.java @@ -359,7 +359,7 @@ public void load(Configuration config) { continue; } - if ( (cs.contains("kingdoms") && cs.contains("*")) + if ( (cs.contains("kingdoms") && cs.get("kingdoms").equals("*")) || (cs.contains("clone-per-kingdom") && cs.getBoolean("clone-per-kingdom")) ) { createPerKingdomChatChannel(name, cs); continue; @@ -384,7 +384,7 @@ public void load(Configuration config) { } private void createPerKingdomChatChannel(String name, Configuration section) { - managers.add(new ChatChannelManager() { + ChatChannelManager ccm = new ChatChannelManager() { @Override public void onCreate(Kingdom kingdom) { ChatChannel ch = new KingdomChatChannel(name + "-" + kingdom.getName(), kingdom); @@ -399,7 +399,9 @@ public void onDelete(Kingdom kingdom) { removeChatChannel(ch); } } - }); + }; + managers.add(ccm); + kdc.getKingdoms().forEach(ccm::onCreate); } private void createKingdomGroupChatChannel(String name, Configuration section) { @@ -416,7 +418,7 @@ private void createKingdomGroupChatChannel(String name, Configuration section) { setup(ch, section); addChatChannel(ch); - managers.add(new ChatChannelManager() { + ChatChannelManager ccm = new ChatChannelManager() { @Override public void onCreate(Kingdom kingdom) { if ( !kingdoms.contains(kingdom.getName().toLowerCase()) ) { @@ -433,7 +435,10 @@ public void onDelete(Kingdom kingdom) { removeChatChannel(ch); } } - }); + }; + + managers.add(ccm); + kdc.getKingdoms().forEach(ccm::onCreate); } private void setup(ChatChannel channel, Configuration section) {