mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Remove channel reloading, add filter reloading
This commit is contained in:
1 parent
70fd7c2cd9
commit
0807506045
5 files changed
+16
-9
No files matched your search
@@ -41,6 +41,8 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
private YamlConfiguration languageConfig;
|
private YamlConfiguration languageConfig;
|
||||||
private YamlConfiguration commandsConfig;
|
private YamlConfiguration commandsConfig;
|
||||||
|
|
||||||
|
private FilterHandler filterHandler;
|
||||||
|
|
||||||
public static final LegacyComponentSerializer LEGACY =
|
public static final LegacyComponentSerializer LEGACY =
|
||||||
LegacyComponentSerializer.builder()
|
LegacyComponentSerializer.builder()
|
||||||
.extractUrls()
|
.extractUrls()
|
||||||
@@ -143,7 +145,10 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new WhisperPingHandler(this), this);
|
pluginManager.registerEvents(new WhisperPingHandler(this), this);
|
||||||
|
|
||||||
pluginManager.registerEvents(new CapsHandler(this), this);
|
pluginManager.registerEvents(new CapsHandler(this), this);
|
||||||
pluginManager.registerEvents(new FilterHandler(this), this);
|
|
||||||
|
filterHandler = new FilterHandler(this);
|
||||||
|
pluginManager.registerEvents(filterHandler, this);
|
||||||
|
|
||||||
pluginManager.registerEvents(new MuteHandler(), this);
|
pluginManager.registerEvents(new MuteHandler(), this);
|
||||||
pluginManager.registerEvents(new ShadowMuteHandler(this), this);
|
pluginManager.registerEvents(new ShadowMuteHandler(this), this);
|
||||||
}
|
}
|
||||||
@@ -155,6 +160,8 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
loadModConfig();
|
loadModConfig();
|
||||||
loadLanguage();
|
loadLanguage();
|
||||||
loadCommandsConfig();
|
loadCommandsConfig();
|
||||||
|
|
||||||
|
filterHandler.reloadFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadModConfig() {
|
private void loadModConfig() {
|
||||||
|
|||||||
@@ -36,16 +36,11 @@ public class ChatReloadCommand {
|
|||||||
private void execute(CommandSender sender, Object[] args) {
|
private void execute(CommandSender sender, Object[] args) {
|
||||||
carbonChat.reloadConfig();
|
carbonChat.reloadConfig();
|
||||||
|
|
||||||
carbonChat.getChannelManager().reload();
|
|
||||||
|
|
||||||
Component message = carbonChat.getAdventureManager().processMessage(carbonChat.getLanguage().getString("reloaded"),
|
Component message = carbonChat.getAdventureManager().processMessage(carbonChat.getLanguage().getString("reloaded"),
|
||||||
"br", "\n");
|
"br", "\n");
|
||||||
|
|
||||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(message);
|
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(message);
|
||||||
|
|
||||||
// TODO: Ensure the command list is updated when reloading.
|
|
||||||
// If new channels are added, their commands should appear to players.
|
|
||||||
|
|
||||||
// TODO: Ensure moderation filters ETC are updated when reloading.
|
// TODO: Ensure moderation filters ETC are updated when reloading.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,14 @@ public class FilterHandler implements Listener {
|
|||||||
|
|
||||||
public FilterHandler(CarbonChat carbonChat) {
|
public FilterHandler(CarbonChat carbonChat) {
|
||||||
this.carbonChat = carbonChat;
|
this.carbonChat = carbonChat;
|
||||||
|
reloadFilters();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadFilters() {
|
||||||
|
patternReplacements.clear();
|
||||||
|
blockedWords.clear();
|
||||||
|
|
||||||
FileConfiguration config = carbonChat.getModConfig();
|
FileConfiguration config = carbonChat.getModConfig();
|
||||||
|
|
||||||
ConfigurationSection filters = config.getConfigurationSection("filters.filters");
|
ConfigurationSection filters = config.getConfigurationSection("filters.filters");
|
||||||
|
|
||||||
for (String replacement : filters.getKeys(false)) {
|
for (String replacement : filters.getKeys(false)) {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class ChannelManager {
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload() {
|
private void reload() {
|
||||||
registry.clearAll();
|
registry.clearAll();
|
||||||
|
|
||||||
for (String key : carbonChat.getConfig().getConfigurationSection("channels").getKeys(false)) {
|
for (String key : carbonChat.getConfig().getConfigurationSection("channels").getKeys(false)) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class CommandManager {
|
|||||||
reloadCommands(carbonChat);
|
reloadCommands(carbonChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadCommands(CarbonChat carbonChat) {
|
private void reloadCommands(CarbonChat carbonChat) {
|
||||||
new ChannelCommand(carbonChat, getCommandSettings("channel"));
|
new ChannelCommand(carbonChat, getCommandSettings("channel"));
|
||||||
new ChannelListCommand(carbonChat, getCommandSettings("channellist"));
|
new ChannelListCommand(carbonChat, getCommandSettings("channellist"));
|
||||||
new ChatReloadCommand(carbonChat, getCommandSettings("chatreload"));
|
new ChatReloadCommand(carbonChat, getCommandSettings("chatreload"));
|
||||||
|
|||||||
Reference in new issue
Block a user