Configuration fixes

This commit is contained in:
Draycia committed 2020-09-25 01:45:36 -07:00
1 parent f549c47479
commit 3cd6abb6f7
8 files changed
+65 -63

No files matched your search

@@ -49,8 +49,7 @@ public class CarbonSettings {
private @Nullable StorageType storageType = StorageType.JSON;
@Setting(comment = "The credentials used to connect to your database. Requires storageType=MYSQL")
private @NonNull SQLCredentials sqlCredentials =
new SQLCredentials("username", "password", "db", "localhost", 3306);
private @NonNull SQLCredentials sqlCredentials = new SQLCredentials();
@Setting(comment = "Options: NONE, REDIS, BUNGEECORD")
private @NonNull MessagingType messagingType = MessagingType.NONE;
@@ -62,8 +61,7 @@ public class CarbonSettings {
"\n" +
" Note: In order for channels to sync cross server, you'll need to enable is-cross-server for the\n" +
" channel as well as this setting.")
private @NonNull RedisCredentials redisCredentials =
new RedisCredentials("localhost", "", 6379, 0);
private @NonNull RedisCredentials redisCredentials = new RedisCredentials();
@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%")
@@ -3,39 +3,45 @@ 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 java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@ConfigSerializable
public class ChannelSettings {
private String key;
private String color;
private Map<String, Context> contexts;
private Map<String, String> formats;
private String defaultFormatName;
private boolean isDefault;
private boolean ignorable;
private boolean crossServer;
private boolean honorsRecipientList;
private boolean permissionGroupMatching;
private List<String> groupOverrides;
private String name;
private String messagePrefix;
private String switchMessage;
private List<Pattern> itemLinkPatterns;
private String switchOtherMessage;
private List<String> aliases;
private boolean shouldCancelChatEvent;
private boolean primaryGroupOnly;
private String cannotUseMessage;
private String toggleOtherOffMessage;
private String toggleOtherOnMessage;
private String toggleOnMessage;
private String toggleOffMessage;
private String cannotIgnoreMessage;
private String switchFailureMessage;
@Setting private String key = "channel";
@Setting private String color = "#FFFFFF";
@Setting private Map<String, Context> contexts = new HashMap<>(); // TODO: set defaults
@Setting private Map<String, String> formats = new HashMap<>(); // TODO: set defaults
@Setting private String defaultFormatName = "default";
@Setting private boolean isDefault = false;
@Setting private boolean ignorable = true;
@Setting private boolean crossServer = true;
@Setting private boolean honorsRecipientList = false;
@Setting private boolean permissionGroupMatching = false;
@Setting private List<String> groupOverrides = new ArrayList<>();
@Setting private String name;
@Setting private String messagePrefix;
@Setting private List<Pattern> itemLinkPatterns = Collections.singletonList(Pattern.compile(Pattern.quote("[item]")));
@Setting private List<String> aliases;
@Setting private boolean shouldCancelChatEvent = false;
@Setting private boolean primaryGroupOnly = false;
@Setting private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
@Setting private String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
@Setting private String switchFailureMessage = "<red>You cannot use channel <channel>!";
@Setting private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
@Setting private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
@Setting private String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
@Setting private String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
@Setting private String cannotUseMessage = "You cannot use that channel!";
@Setting private String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
@NonNull
public String key() {
@@ -1,5 +1,8 @@
package net.draycia.carbon.api.config;
import org.spongepowered.configurate.serialize.ConfigSerializable;
@ConfigSerializable
public enum MessagingType {
NONE,
REDIS,
@@ -2,20 +2,16 @@ 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;
@ConfigSerializable
public class RedisCredentials {
private final @NonNull String host;
private final @Nullable String password;
private final int port;
private final int database;
public RedisCredentials(final @NonNull String host, final @Nullable String password, final int port, final int database) {
this.host = host;
this.password = password;
this.port = port;
this.database = database;
}
@Setting private @NonNull String host = "localhost";
@Setting private @Nullable String password = "";
@Setting private int port = 6379;
@Setting private int database = 0;
public @NonNull String host() {
return this.host;
@@ -1,23 +1,17 @@
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;
@ConfigSerializable
public class SQLCredentials {
private final @NonNull String username;
private final @NonNull String password;
private final @NonNull String database;
private final @NonNull String host;
private final int port;
public SQLCredentials(final @NonNull String username, final @NonNull String password,
final @NonNull String database, final @NonNull String host, final int port) {
this.username = username;
this.password = password;
this.database = database;
this.host = host;
this.port = port;
}
@Setting private @NonNull String username = "username";
@Setting private @NonNull String password = "password";
@Setting private @NonNull String database = "database";
@Setting private @NonNull String host = "host";
@Setting private int port = 3306;
public @NonNull String username() {
return this.username;
@@ -1,5 +1,8 @@
package net.draycia.carbon.api.config;
import org.spongepowered.configurate.serialize.ConfigSerializable;
@ConfigSerializable
public enum StorageType {
MYSQL,
JSON
@@ -8,10 +8,8 @@ import org.spongepowered.configurate.serialize.ConfigSerializable;
@ConfigSerializable
public final class WhisperPings {
@Setting
private boolean enabled = true;
@Setting private @NonNull
Key sound = Key.of(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
@Setting private boolean enabled = true;
@Setting private @NonNull Key sound = Key.of(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
@Setting private Sound.Source source = Sound.Source.PLAYER;
@Setting private float volume = 10.0F;
@Setting private float pitch = 1.0F;
@@ -232,7 +232,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
final BasicConfigurationNode settingsNode = settingsLoader.load();
this.carbonSettings = CarbonSettings.loadFrom(settingsNode);
settingsLoader.save(settingsNode);
} catch (final IOException | ObjectMappingException ignored) {
} catch (final IOException | ObjectMappingException exception) {
exception.printStackTrace();
}
}
@@ -244,7 +245,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
final BasicConfigurationNode languageNode = languageLoader.load();
this.translations = CarbonTranslations.loadFrom(languageNode);
languageLoader.save(languageNode);
} catch (final IOException | ObjectMappingException ignored) {
} catch (final IOException | ObjectMappingException exception) {
exception.printStackTrace();
}
}
@@ -256,7 +258,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
final BasicConfigurationNode moderationNode = moderationLoader.load();
this.moderationSettings = ModerationSettings.loadFrom(moderationNode);
moderationLoader.save(moderationNode);
} catch (final IOException | ObjectMappingException ignored) {
} catch (final IOException | ObjectMappingException exception) {
exception.printStackTrace();
}
}
@@ -275,7 +278,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
final BasicConfigurationNode commandSettingsNode = commandSettingsLoader.load();
this.commandSettings = CommandSettingsRegistry.loadFrom(commandSettingsNode);
commandSettingsLoader.save(commandSettingsNode);
} catch (final IOException | ObjectMappingException ignored) {
} catch (final IOException | ObjectMappingException exception) {
exception.printStackTrace();
}
}