Skip to content

Commit

Permalink
Fix issues with updated chat channel system
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisguffens committed Nov 16, 2024
1 parent 0495324 commit dda3737
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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()) ) {
Expand All @@ -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) {
Expand Down

0 comments on commit dda3737

Please sign in to comment.