From fd018885f560be3c785be8616cd754db8b89f49e Mon Sep 17 00:00:00 2001 From: Draycia Date: Fri, 10 Dec 2021 15:25:33 -0800 Subject: [PATCH] Register 'global' channel by default --- .../common/channels/CarbonChannelRegistry.java | 12 ++++++------ .../carbon/common/channels/ConfigChatChannel.java | 4 ++-- .../draycia/carbon/common/config/PrimaryConfig.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java b/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java index c1effde6..127e277f 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java @@ -152,10 +152,12 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry public void loadConfigChannels() { this.defaultKey = this.configFactory.primaryConfig().defaultChannel(); - if (!Files.exists(this.configChannelDir) || this.isPathEmpty(this.configChannelDir)) { + if (!Files.exists(this.configChannelDir)) { // no channels to register, register default channel this.registerDefaultChannel(); return; + } else if (this.isPathEmpty(this.configChannelDir)) { + this.register(this.basicChannel.key(), this.basicChannel); } // otherwise, register all channels found @@ -218,19 +220,17 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry try { Files.createDirectories(this.configChannelDir); - this.register(this.basicChannel.key(), this.basicChannel); - - final Path configFile = this.configChannelDir.resolve("basic-channel.conf.example"); + final Path configFile = this.configChannelDir.resolve("global.conf"); final var loader = this.configLoader.configurationLoader(configFile); final var node = loader.load(); final var configChannel = this.injector.getInstance(ConfigChatChannel.class); - node.set(ConfigChatChannel.class, configChannel); + node.set(ConfigChatChannel.class, configChannel); loader.save(node); - this.logger.info("No custom channels defined! Using basic handler."); + this.register(configChannel.key(), configChannel); } catch (final IOException exception) { exception.printStackTrace(); } diff --git a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java index 921bb25b..5f2241ce 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java @@ -68,14 +68,14 @@ public final class ConfigChatChannel implements ChatChannel { You only need to change the second part of the key. "global" by default. The value is what's used in commands, this is probably what you want to change. """) - private @Nullable Key key = Key.key("carbon", "basic"); + private @Nullable Key key = Key.key("carbon", "global"); @Comment(""" The permission required to use the channel. To read messages you must have the permission carbon.channel.basic.see To send messages you must have the permission carbon.channel.basic.speak """) - private @Nullable String permission = "carbon.channel.basic"; + private @Nullable String permission = "carbon.channel.global"; @Setting("format") @Comment("The chat formats for this channel.") diff --git a/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java b/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java index 7afb330e..2fdaa527 100644 --- a/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java +++ b/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java @@ -38,7 +38,7 @@ public class PrimaryConfig { The default channel that new players will be in when they join. If the channel is not found or the player cannot use the channel, they will speak in basic non-channel chat. """) - private Key defaultChannel = Key.key("carbon", "basic"); + private Key defaultChannel = Key.key("carbon", "global"); @Comment("The service that will be used to store and load player information.") private StorageType storageType = StorageType.JSON;