From 13ac18bb362b1ea4e02a17e74bbe746b3760c63d Mon Sep 17 00:00:00 2001 From: Draycia Date: Sat, 3 Oct 2020 00:21:52 -0700 Subject: [PATCH] Update configurate --- .../java/net/draycia/carbon/api/Context.java | 4 +- .../carbon/api/channels/ChannelRegistry.java | 2 +- .../commands/settings/CommandSettings.java | 4 +- .../settings/CommandSettingsRegistry.java | 16 ++-- .../carbon/api/config/CarbonSettings.java | 47 +++++++---- .../carbon/api/config/CarbonTranslations.java | 13 +-- .../carbon/api/config/ChannelOptions.java | 80 ++++++++++++------- .../carbon/api/config/ChannelPings.java | 17 ++-- .../carbon/api/config/ChannelSettings.java | 14 ++-- .../carbon/api/config/ModerationSettings.java | 38 +++++---- .../carbon/api/config/RedisCredentials.java | 4 +- .../carbon/api/config/SQLCredentials.java | 4 +- .../api/config/SharedChannelOptions.java | 4 +- .../carbon/api/config/WhisperOptions.java | 47 +++++++---- .../carbon/api/config/WhisperPings.java | 4 +- .../draycia/carbon/api/events/UserEvent.java | 2 +- 16 files changed, 186 insertions(+), 114 deletions(-) diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/Context.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/Context.java index dfbcf64e..0087aa47 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/Context.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/Context.java @@ -1,8 +1,8 @@ package net.draycia.carbon.api; import org.checkerframework.checker.nullness.qual.NonNull; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.List; diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChannelRegistry.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChannelRegistry.java index 7f85aa80..e0884261 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChannelRegistry.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/channels/ChannelRegistry.java @@ -53,7 +53,7 @@ public class ChannelRegistry implements Registry { return this.registry.values().iterator(); } - public @Nullable ChatChannel defaultChannel() { + public @MonotonicNonNull ChatChannel defaultChannel() { return this.defaultChannel; } diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettings.java index c17f18c8..9cacab16 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettings.java @@ -2,8 +2,8 @@ package net.draycia.carbon.api.commands.settings; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.NonNull; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.Set; diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettingsRegistry.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettingsRegistry.java index 0e8798b9..67724cbd 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettingsRegistry.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/commands/settings/CommandSettingsRegistry.java @@ -5,10 +5,10 @@ import net.kyori.registry.Registry; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.configurate.CommentedConfigurationNode; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMappingException; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.HashMap; import java.util.Iterator; @@ -18,27 +18,27 @@ import java.util.Set; @ConfigSerializable public class CommandSettingsRegistry implements Registry { + @Setting + private @NonNull final Map<@NonNull String, @NonNull CommandSettings> registry = new HashMap<>(); + private static final ObjectMapper MAPPER; static { try { - MAPPER = ObjectMapper.forClass(CommandSettingsRegistry.class); // We hold on to the instance of our ObjectMapper + MAPPER = ObjectMapper.factory().get(CommandSettingsRegistry.class); } catch (final ObjectMappingException e) { throw new ExceptionInInitializerError(e); } } public static CommandSettingsRegistry loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException { - return MAPPER.bindToNew().populate(node); + return MAPPER.load(node); } public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { - MAPPER.bind(this).serialize(node); + MAPPER.save(this, node); } - @Setting - private @NonNull final Map<@NonNull String, @NonNull CommandSettings> registry = new HashMap<>(); - @Override public @NonNull CommandSettings register(@NonNull final String key, @NonNull final CommandSettings value) { this.registry.put(key, value); diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonSettings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonSettings.java index aa393b82..9ecc5b84 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonSettings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonSettings.java @@ -3,10 +3,11 @@ package net.draycia.carbon.api.config; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.configurate.CommentedConfigurationNode; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMappingException; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.Collections; import java.util.HashMap; @@ -21,39 +22,46 @@ public class CarbonSettings { static { try { - MAPPER = ObjectMapper.forClass(CarbonSettings.class); // We hold on to the instance of our ObjectMapper + MAPPER = ObjectMapper.factory().get(CarbonSettings.class); } catch (final ObjectMappingException e) { throw new ExceptionInInitializerError(e); } } public static CarbonSettings loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException { - return MAPPER.bindToNew().populate(node); + return MAPPER.load(node); } public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { - MAPPER.bind(this).serialize(node); + MAPPER.save(this, node); } - @Setting(comment = "The prefix shown when spying on a user's message") + @Setting + @Comment("The prefix shown when spying on a user's message") private @NonNull String spyPrefix = "[SPY] "; - @Setting(comment = "Used for placeholder in channel formats") + @Setting + @Comment("Used for placeholder in channel formats") private @NonNull String serverName = "Server"; - @Setting(comment = "Set this to false to disable warnings and tips when the plugin thinks there may be configuration issues.") + @Setting + @Comment("Set this to false to disable warnings and tips when the plugin thinks there may be configuration issues.") private boolean showTips = true; - @Setting(comment = "Options: JSON, MYSQL") + @Setting + @Comment("Options: JSON, MYSQL") private @Nullable StorageType storageType = StorageType.JSON; - @Setting(comment = "The credentials used to connect to your database. Requires storageType=MYSQL") + @Setting + @Comment("The credentials used to connect to your database. Requires storageType=MYSQL") private @NonNull SQLCredentials sqlCredentials = new SQLCredentials(); - @Setting(comment = "Options: NONE, REDIS, BUNGEECORD") + @Setting + @Comment("Options: NONE, REDIS, BUNGEECORD") private @NonNull MessagingType messagingType = MessagingType.NONE; - @Setting(comment = " Options:\n" + + @Setting + @Comment(" Options:\n" + " 'bungee' - Uses bungee plugin messaging, requires BungeeCord or another proxy which supports it (Velocity!)\n" + " 'redis' - Uses redis for cross server syncing, does not require a server proxy\n" + " 'none' - Do not sync anything cross server, this is the default\n" + @@ -62,7 +70,8 @@ public class CarbonSettings { " channel as well as this setting.") private @NonNull RedisCredentials redisCredentials = new RedisCredentials(); - @Setting(comment = "Used for message formats - custom tags that are replaced in descending order" + + @Setting + @Comment("Used for message formats - custom tags that are replaced in descending order" + "\nFor example, in the default config, wil be replaced with %vault_group%") private @NonNull Map<@Nullable String, @NonNull String> customPlaceholders = new HashMap() { { @@ -71,20 +80,24 @@ public class CarbonSettings { } }; - @Setting(comment = "Plays a sound and highlights the message when someone types your name") + @Setting + @Comment("Plays a sound and highlights the message when someone types your name") private @NonNull ChannelPings channelPings = new ChannelPings(); - @Setting(comment = "Various options relating to the /whisper command") + @Setting + @Comment("Various options relating to the /whisper command") private @NonNull WhisperOptions whisperOptions = new WhisperOptions(); - @Setting(comment = "Sets the player's channel to the specified channel when they join" + + @Setting + @Comment("Sets the player's channel to the specified channel when they join" + "\nSet to \"\" or remove to disable" + "\nSet to DEFAULT to set the player's channel to the default channel on join" + "\nOtherwise, set to a channel to set the player's channel to it on join" + "\nFor example, channel-on-join: \"global\" sets their channel to global on join") private @Nullable String channelOnJoin = ""; - @Setting(comment = "The list of regex patterns to show items in chat") + @Setting + @Comment("The list of regex patterns to show items in chat") private List itemLinkPatterns = Collections.singletonList(Pattern.compile(Pattern.quote("[item]"))); diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonTranslations.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonTranslations.java index 6aa1bdd9..b4a71171 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonTranslations.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/CarbonTranslations.java @@ -1,10 +1,10 @@ package net.draycia.carbon.api.config; import org.spongepowered.configurate.CommentedConfigurationNode; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMappingException; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; @ConfigSerializable public class CarbonTranslations { @@ -13,21 +13,22 @@ public class CarbonTranslations { static { try { - MAPPER = ObjectMapper.forClass(CarbonTranslations.class); // We hold on to the instance of our ObjectMapper + MAPPER = ObjectMapper.factory().get(CarbonTranslations.class); } catch (final ObjectMappingException e) { throw new ExceptionInInitializerError(e); } } public static CarbonTranslations loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException { - return MAPPER.bindToNew().populate(node); + return MAPPER.load(node); } public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { - MAPPER.bind(this).serialize(node); + MAPPER.save(this, node); } - @Setting private String reloaded = "Chat config has been reloaded!"; + @Setting + private String reloaded = "Chat config has been reloaded!"; @Setting private String otherPlayerOffline = "That player is offline!"; @Setting private String spyWhispers = "Spy [ -> ] "; @Setting private String noReplyTarget = "You have no one to reply to!"; diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java index f7b4e602..c5d47d5c 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java @@ -4,8 +4,9 @@ import net.draycia.carbon.api.CarbonChatProvider; import net.draycia.carbon.api.Context; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.ArrayList; import java.util.Collections; @@ -16,83 +17,108 @@ import java.util.Map; @ConfigSerializable public class ChannelOptions { - @Setting(comment = "What this channel is identified as. This will be what's typed ingame to use the channel.") + @Setting + @Comment("What this channel is identified as. This will be what's typed ingame to use the channel.") private String key = "channel"; - @Setting(comment = "This is what the placeholder will typically be replaced with.\n" + + @Setting + @Comment("This is what the placeholder will typically be replaced with.\n" + "Hex RGB (#B19CD9), named colors (light_purple), legacy (&d), and legacy RGB (&x&b&1&2&c&d&9) are all supported.\n" + "If on a platform that supports PlaceholderAPI, this option will be ran through that as well.\n" + "Note that the placeholder is also used for personal and global user colors.") private String color; - @Setting(comment = "The contexts for this channel, ") + @Setting + @Comment("The contexts for this channel, ") private Map contexts = new HashMap<>(); // TODO: set defaults - @Setting(comment = "The formats for this channel. The key is the name of the group as your permissions plugin reports it.") + @Setting + @Comment("The formats for this channel. The key is the name of the group as your permissions plugin reports it.") private Map formats = new HashMap<>(); // TODO: set defaults - @Setting(comment = "The name of the format that the plugin will fall back to when it cannot find a matching format for the player's groups.") + @Setting + @Comment("The name of the format that the plugin will fall back to when it cannot find a matching format for the player's groups.") private String defaultFormatName; - @Setting(comment = "If this channel is the default channel players join in.\n" + + @Setting + @Comment("If this channel is the default channel players join in.\n" + "Also used as a fallback in case the player's selected channel cannot be found.") private boolean isDefault = false; // primitive because missing = false - @Setting(comment = "If this channel can be ignored / hidden with the /ignore command") + @Setting + @Comment("If this channel can be ignored / hidden with the /ignore command") private Boolean ignorable; // boxed because missing = use defaults - @Setting(comment = "If this channel syncs to other servers (cross-server chat), requires a messaging system setup") + @Setting + @Comment("If this channel syncs to other servers (cross-server chat), requires a messaging system setup") private Boolean crossServer; - @Setting(comment = "If this channel should respect the bukkit recipient list, you normally shouldn't touch this") + @Setting + @Comment("If this channel should respect the bukkit recipient list, you normally shouldn't touch this") private Boolean honorsRecipientList; - @Setting(comment = "If players with the permission carbonchat.group.groupname are considered to have the group groupname") + @Setting + @Comment("If players with the permission carbonchat.group.groupname are considered to have the group groupname") private Boolean permissionGroupMatching; - @Setting(comment = "A custom (ordered) list of group priorities") + @Setting + @Comment("A custom (ordered) list of group priorities") private List groupOverrides; - @Setting(comment = "The display name of this channel, supports minimessage. Used in command feedback") + @Setting + @Comment("The display name of this channel, supports minimessage. Used in command feedback") private String name = ""; - @Setting(comment = "If the player's chat message starts with whatever this is set to, the player speaks in this channel instead of their selected one") + @Setting + @Comment("If the player's chat message starts with whatever this is set to, the player speaks in this channel instead of their selected one") private String messagePrefix = ""; - @Setting(comment = "The command aliases for this channel") + @Setting + @Comment("The command aliases for this channel") private List aliases = new ArrayList<>(); - @Setting(comment = "If the bukkit chat event should be cancelled, you probably don't want to change this") + @Setting + @Comment("If the bukkit chat event should be cancelled, you probably don't want to change this") private Boolean shouldCancelChatEvent; - @Setting(comment = "If the player's format should be decided by their primary group only") + @Setting + @Comment("If the player's format should be decided by their primary group only") private Boolean primaryGroupOnly; - @Setting(comment = "") + @Setting + @Comment("") private String switchMessage; - @Setting(comment = "") + @Setting + @Comment("") private String switchOtherMessage; - @Setting(comment = "") + @Setting + @Comment("") private String switchFailureMessage; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOnMessage; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOffMessage; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOtherOnMessage; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOtherOffMessage; - @Setting(comment = "") + @Setting + @Comment("") private String cannotUseMessage; - @Setting(comment = "") + @Setting + @Comment("") private String cannotIgnoreMessage; private SharedChannelOptions defaultOptions() { diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelPings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelPings.java index 6917a840..186c338e 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelPings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelPings.java @@ -3,22 +3,27 @@ package net.draycia.carbon.api.config; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; import org.checkerframework.checker.nullness.qual.NonNull; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; @ConfigSerializable public final class ChannelPings { - @Setting(comment = "Determines if this feature is enabled") + @Setting + @Comment("Determines if this feature is enabled") private boolean enabled = true; - @Setting(comment = "The text that pings must begin with. A prefix of '@' means you have to type '@Player' to ping Player") + @Setting + @Comment("The text that pings must begin with. A prefix of '@' means you have to type '@Player' to ping Player") private @NonNull String prefix = ""; - @Setting(comment = "If player names are case sensitive, if true you must type Player to ping Player, 'player' will not work") + @Setting + @Comment("If player names are case sensitive, if true you must type Player to ping Player, 'player' will not work") private boolean caseSensitive = false; - @Setting(comment = "The sound played to the pinged player") + @Setting + @Comment("The sound played to the pinged player") private @NonNull Sound sound = Sound.sound( Key.key(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup"), Sound.Source.PLAYER, diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelSettings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelSettings.java index 5921cd9f..58f926a2 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelSettings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelSettings.java @@ -1,10 +1,11 @@ package net.draycia.carbon.api.config; import org.spongepowered.configurate.CommentedConfigurationNode; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMappingException; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.Collections; import java.util.Map; @@ -16,21 +17,22 @@ public class ChannelSettings { static { try { - MAPPER = ObjectMapper.forClass(ChannelSettings.class); // We hold on to the instance of our ObjectMapper + MAPPER = ObjectMapper.factory().get(ChannelSettings.class); } catch (final ObjectMappingException e) { throw new ExceptionInInitializerError(e); } } public static ChannelSettings loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException { - return MAPPER.bindToNew().populate(node); + return MAPPER.load(node); } public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { - MAPPER.bind(this).serialize(node); + MAPPER.save(this, node); } - @Setting(comment = "All options here act like the defaults for all channels.\n" + + @Setting + @Comment("All options here act like the defaults for all channels.\n" + "Adding any of these options to any channel overrides the relevant defaults.") private SharedChannelOptions sharedChannelOptions = new SharedChannelOptions(); diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ModerationSettings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ModerationSettings.java index eaa717bb..f789d148 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ModerationSettings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ModerationSettings.java @@ -1,10 +1,11 @@ package net.draycia.carbon.api.config; import org.spongepowered.configurate.CommentedConfigurationNode; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; import org.spongepowered.configurate.objectmapping.ObjectMapper; import org.spongepowered.configurate.objectmapping.ObjectMappingException; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.Collections; import java.util.HashMap; @@ -19,18 +20,18 @@ public class ModerationSettings { static { try { - MAPPER = ObjectMapper.forClass(ModerationSettings.class); // We hold on to the instance of our ObjectMapper + MAPPER = ObjectMapper.factory().get(ModerationSettings.class); } catch (final ObjectMappingException e) { throw new ExceptionInInitializerError(e); } } public static ModerationSettings loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException { - return MAPPER.bindToNew().populate(node); + return MAPPER.load(node); } public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException { - MAPPER.bind(this).serialize(node); + MAPPER.save(this, node); } // TODO: comment this @@ -41,7 +42,8 @@ public class ModerationSettings { return this.shadowMutePrefix; } - @Setting(comment = "If true, muted users will be unable to use /whisper /msg") + @Setting + @Comment("If true, muted users will be unable to use /whisper /msg") private boolean muteStopsWhispers = true; public boolean muteStopsWhispers() { @@ -57,10 +59,12 @@ public class ModerationSettings { @ConfigSerializable public static class ClearChat { - @Setting(comment = "The message sent to clear chat, you probably want to leave this blank") + @Setting + @Comment("The message sent to clear chat, you probably want to leave this blank") private String message = ""; - @Setting(comment = "How many messages will be sent in order to clear chat") + @Setting + @Comment("How many messages will be sent in order to clear chat") private int messageCount = 100; public String message() { @@ -81,16 +85,20 @@ public class ModerationSettings { @ConfigSerializable public static class CapsProtection { - @Setting(comment = "If caps protection is enabled") + @Setting + @Comment("If caps protection is enabled") private boolean enabled = true; - @Setting(comment = "The minimum message length for caps protection to activate") + @Setting + @Comment("The minimum message length for caps protection to activate") private int minimumLength = 10; - @Setting(comment = "The amount of letters in the message for it to trigger the protection") + @Setting + @Comment("The amount of letters in the message for it to trigger the protection") private float percentCaps = 0.80F; - @Setting(comment = "If true, stops message from sending. If false, simply changes the message to lowercase") + @Setting + @Comment("If true, stops message from sending. If false, simply changes the message to lowercase") private boolean blockMessage = false; public boolean enabled() { @@ -123,7 +131,8 @@ public class ModerationSettings { @Setting private boolean enabled = true; - @Setting(comment = "The keys (\"****\" for example) are what the text is replaced with.\n" + + @Setting + @Comment("The keys (\"****\" for example) are what the text is replaced with.\n" + "The strings in the lists (\"lag\" etc) are what's replaced.\n" + "Set to filters: {} if you want to disable the filter feature.\n" + "Set the key to \"_\" for the replacement to be blank (remove the filtered pattern).") @@ -133,7 +142,8 @@ public class ModerationSettings { } }; - @Setting(comment = "Anything in blocked-words will prevent the message from being sent at all.\n" + + @Setting + @Comment("Anything in blocked-words will prevent the message from being sent at all.\n" + "Set to blocked-words: [] if you want to disable the blocked words feature.") private List blockedPatterns = Collections.singletonList(Pattern.compile("pineapple doesn't belong on pizza")); diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/RedisCredentials.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/RedisCredentials.java index af114ebb..9565f06f 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/RedisCredentials.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/RedisCredentials.java @@ -2,8 +2,8 @@ package net.draycia.carbon.api.config; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; @ConfigSerializable public class RedisCredentials { diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SQLCredentials.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SQLCredentials.java index 4f5c403d..6c4d47bf 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SQLCredentials.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SQLCredentials.java @@ -1,8 +1,8 @@ package net.draycia.carbon.api.config; import org.checkerframework.checker.nullness.qual.NonNull; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; @ConfigSerializable public class SQLCredentials { diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java index 86a842a3..49393a69 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java @@ -3,8 +3,8 @@ package net.draycia.carbon.api.config; import net.draycia.carbon.api.Context; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; import java.util.ArrayList; import java.util.HashMap; diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperOptions.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperOptions.java index 92fe6975..c9a1ba67 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperOptions.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperOptions.java @@ -2,52 +2,67 @@ package net.draycia.carbon.api.config; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Comment; +import org.spongepowered.configurate.objectmapping.meta.Setting; @ConfigSerializable public class WhisperOptions { - @Setting(comment = "Plays a sound when receiving private messages with /whisper /msg") + @Setting + @Comment("Plays a sound when receiving private messages with /whisper /msg") private @NonNull WhisperPings pings = new WhisperPings(); - @Setting(comment = "") + @Setting + @Comment("") private String switchMessage = "You are now in chat!"; - @Setting(comment = "") + @Setting + @Comment("") private String switchOtherMessage = " is now in chat!"; - @Setting(comment = "") + @Setting + @Comment("") private String switchFailureMessage = "You cannot use channel !"; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOnMessage = "You can now see chat!"; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOffMessage = "You can no longer see chat!"; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOtherOnMessage = " can now see chat!"; - @Setting(comment = "") + @Setting + @Comment("") private String toggleOtherOffMessage = " can no longer see chat!"; - @Setting(comment = "") + @Setting + @Comment("") private String cannotUseMessage = "You cannot use that channel!"; - @Setting(comment = "") + @Setting + @Comment("") private String cannotIgnoreMessage = "You cannot ignore that channel!"; - @Setting(comment = "") + @Setting + @Comment("") private String senderFormat = "[Me -> ] "; - @Setting(comment = "") + @Setting + @Comment("") private String receiverFormat = "[ -> Me] "; - @Setting(comment = "") + @Setting + @Comment("") private String consoleFormat = "[ -> ] "; - @Setting(comment = "") + @Setting + @Comment("") private boolean logToConsole = true; public boolean logToConsole() { diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperPings.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperPings.java index b3b67cff..a8f822bb 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperPings.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/WhisperPings.java @@ -3,8 +3,8 @@ package net.draycia.carbon.api.config; import net.kyori.adventure.key.Key; import net.kyori.adventure.sound.Sound; import org.checkerframework.checker.nullness.qual.NonNull; -import org.spongepowered.configurate.objectmapping.Setting; -import org.spongepowered.configurate.serialize.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.ConfigSerializable; +import org.spongepowered.configurate.objectmapping.meta.Setting; @ConfigSerializable public final class WhisperPings { diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/events/UserEvent.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/events/UserEvent.java index 30bcd667..fd130464 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/events/UserEvent.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/events/UserEvent.java @@ -14,7 +14,7 @@ public class UserEvent implements CarbonEvent, Cancellable { this.user = user; } - public ChatUser user() { + public @NonNull ChatUser user() { return this.user; }