mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Update configurate
This commit is contained in:
1 parent
8b0549ac9b
commit
13ac18bb36
16 files changed
+186
-114
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ChannelRegistry implements Registry<String, ChatChannel> {
|
||||
return this.registry.values().iterator();
|
||||
}
|
||||
|
||||
public @Nullable ChatChannel defaultChannel() {
|
||||
public @MonotonicNonNull ChatChannel defaultChannel() {
|
||||
return this.defaultChannel;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
|
||||
+8
-8
@@ -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<String, CommandSettings> {
|
||||
|
||||
@Setting
|
||||
private @NonNull final Map<@NonNull String, @NonNull CommandSettings> registry = new HashMap<>();
|
||||
|
||||
private static final ObjectMapper<CommandSettingsRegistry> 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);
|
||||
|
||||
@@ -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 = "<color>[SPY] ";
|
||||
|
||||
@Setting(comment = "Used for <server> placeholder in channel formats")
|
||||
@Setting
|
||||
@Comment("Used for <server> 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, <group> wil be replaced with <green>%vault_group%")
|
||||
private @NonNull Map<@Nullable String, @NonNull String> customPlaceholders = new HashMap<String, String>() {
|
||||
{
|
||||
@@ -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<Pattern> itemLinkPatterns =
|
||||
Collections.singletonList(Pattern.compile(Pattern.quote("[item]")));
|
||||
|
||||
|
||||
@@ -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 = "<yellow>Chat config has been reloaded!";
|
||||
@Setting
|
||||
private String reloaded = "<yellow>Chat config has been reloaded!";
|
||||
@Setting private String otherPlayerOffline = "<red>That player is offline!";
|
||||
@Setting private String spyWhispers = "<yellow>Spy [<gray><sender><reset> <gold>-> <gray><target><reset><yellow>] <message>";
|
||||
@Setting private String noReplyTarget = "<red>You have no one to reply to!";
|
||||
|
||||
@@ -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 <color> placeholder will typically be replaced with.\n" +
|
||||
@Setting
|
||||
@Comment("This is what the <color> 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 <color> 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<String, Context> 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<String, String> 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<String> 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<String> 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() {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
+24
-14
@@ -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<Pattern> blockedPatterns = Collections.singletonList(Pattern.compile("pineapple doesn't belong on pizza"));
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -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 = "<gray>You are now in <color><channel> <gray>chat!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String switchFailureMessage = "<red>You cannot use channel <channel>!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String cannotUseMessage = "You cannot use that channel!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String senderFormat = "<gold>[<white>Me <gray>-> <white><receiver><gold>] <message>";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String receiverFormat = "<gold>[<white><sender> <gray>-> <white>Me<gold>] <message>";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String consoleFormat = "<gold>[<white><sender> <gray>-> <white><receiver><gold>] <message>";
|
||||
|
||||
@Setting(comment = "")
|
||||
@Setting
|
||||
@Comment("")
|
||||
private boolean logToConsole = true;
|
||||
|
||||
public boolean logToConsole() {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -14,7 +14,7 @@ public class UserEvent implements CarbonEvent, Cancellable {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public ChatUser user() {
|
||||
public @NonNull ChatUser user() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user