mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Complete some TODOs
This commit is contained in:
1 parent
548955134e
commit
4d547f80c7
27 files changed
+155
-67
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package net.draycia.carbon.api;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import net.draycia.carbon.api.config.CarbonTranslations;
|
||||
import net.draycia.carbon.api.adventure.MessageProcessor;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
@@ -8,6 +9,7 @@ import net.draycia.carbon.api.config.CarbonSettings;
|
||||
import net.draycia.carbon.api.config.ChannelSettings;
|
||||
import net.draycia.carbon.api.config.ModerationSettings;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
@@ -53,4 +55,6 @@ public interface CarbonChat {
|
||||
|
||||
@NonNull GsonComponentSerializer gsonSerializer();
|
||||
|
||||
@NonNull CommandManager<CarbonUser> commandManager();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.draycia.carbon.api;
|
||||
|
||||
import net.kyori.registry.DefaultedRegistryGetter;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* An extension of the DefaultedRegistryGetter that declares a defaultValue method
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
public interface DefaultedKeyValueRegistry<K,V> extends DefaultedRegistryGetter<K, V> {
|
||||
|
||||
/**
|
||||
* Gets the default value.
|
||||
*
|
||||
* @return the default value
|
||||
*/
|
||||
@NonNull V defaultValue();
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.kyori.registry.DefaultedRegistry;
|
||||
import net.draycia.carbon.api.DefaultedKeyValueRegistry;
|
||||
import net.kyori.registry.Registry;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -11,7 +11,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChannelRegistry implements Registry<String, ChatChannel>, DefaultedRegistry<String, ChatChannel> {
|
||||
public class ChannelRegistry implements Registry<String, ChatChannel>, DefaultedKeyValueRegistry<String, ChatChannel> {
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull ChatChannel> registry = new HashMap<>();
|
||||
|
||||
@@ -37,6 +37,12 @@ public class ChannelRegistry implements Registry<String, ChatChannel>, Defaulted
|
||||
|
||||
@Override
|
||||
public @Nullable String key(@NonNull final ChatChannel value) {
|
||||
for (final Map.Entry<String, ChatChannel> entry : this.registry.entrySet()) {
|
||||
if (entry.getValue().equals(value)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -50,17 +56,18 @@ public class ChannelRegistry implements Registry<String, ChatChannel>, Defaulted
|
||||
return this.registry.values().iterator();
|
||||
}
|
||||
|
||||
public @MonotonicNonNull ChatChannel defaultChannel() {
|
||||
return this.defaultChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String defaultKey() {
|
||||
return this.defaultChannel.key();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChatChannel defaultValue() {
|
||||
return this.defaultChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChatChannel getOrDefault(@NonNull final String key) {
|
||||
return this.registry.getOrDefault(key, this.defaultChannel());
|
||||
return this.registry.getOrDefault(key, this.defaultValue());
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// TODO: rename this to something that's less... weird?
|
||||
public interface TextChannel extends ChatChannel, ForwardingAudience {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ConfigSerializable
|
||||
public class CarbonSettings {
|
||||
public final class CarbonSettings {
|
||||
|
||||
private static final ObjectMapper<CarbonSettings> MAPPER;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.spongepowered.configurate.objectmapping.ObjectMappingException;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@ConfigSerializable
|
||||
public class CarbonTranslations {
|
||||
public final class CarbonTranslations {
|
||||
|
||||
private static final ObjectMapper<CarbonTranslations> MAPPER;
|
||||
|
||||
@@ -27,8 +27,9 @@ public class CarbonTranslations {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
@Setting
|
||||
private String reloaded = "<yellow>Chat config has been reloaded!";
|
||||
private ExceptionMessages exceptionMessages = new ExceptionMessages();
|
||||
|
||||
@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!";
|
||||
@@ -64,6 +65,10 @@ public class CarbonTranslations {
|
||||
@Setting private String clearExempt = "<yellow>You were exempt from the clear due to your permissions!";
|
||||
@Setting private String cannotWhisperSelf = "<yellow>You cannot whisper yourself!";
|
||||
|
||||
public ExceptionMessages exceptionMessages() {
|
||||
return this.exceptionMessages;
|
||||
}
|
||||
|
||||
public String reloaded() {
|
||||
return this.reloaded;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ChannelOptions {
|
||||
public final class ChannelOptions {
|
||||
|
||||
@Setting
|
||||
@Comment("What this channel is identified as. This will be what's typed ingame to use the channel.")
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ChannelSettings {
|
||||
public final class ChannelSettings {
|
||||
|
||||
private static final ObjectMapper<ChannelSettings> MAPPER;
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.draycia.carbon.api.config;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@ConfigSerializable
|
||||
public final class ExceptionMessages {
|
||||
|
||||
@Setting private @NonNull String channelNotFound = "Channel not found!";
|
||||
@Setting private @NonNull String channelNotPublic = "Channel is not public!";
|
||||
@Setting private @NonNull String playerNotFound = "Player not found!";
|
||||
|
||||
public String channelNotFound() {
|
||||
return this.channelNotFound;
|
||||
}
|
||||
|
||||
public String channelNotPublic() {
|
||||
return this.channelNotPublic;
|
||||
}
|
||||
|
||||
public String playerNotFound() {
|
||||
return this.playerNotFound;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ModerationSettings {
|
||||
public final class ModerationSettings {
|
||||
|
||||
private static final ObjectMapper<ModerationSettings> MAPPER;
|
||||
|
||||
@@ -34,8 +34,8 @@ public class ModerationSettings {
|
||||
MAPPER.save(this, node);
|
||||
}
|
||||
|
||||
// TODO: comment this
|
||||
@Setting
|
||||
@Comment("The text that's prepended to someone else's shadowmuted messages.")
|
||||
private String shadowMutePrefix = "[SM] ";
|
||||
|
||||
public String shadowMutePrefix() {
|
||||
@@ -86,19 +86,19 @@ public class ModerationSettings {
|
||||
@ConfigSerializable
|
||||
public static class CapsProtection {
|
||||
@Setting
|
||||
@Comment("If caps protection is enabled")
|
||||
@Comment("If caps protection is enabled")
|
||||
private boolean enabled = true;
|
||||
|
||||
@Setting
|
||||
@Comment("The minimum message length for caps protection to activate")
|
||||
@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")
|
||||
@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")
|
||||
@Comment("If true, stops message from sending. If false, simply changes the message to lowercase")
|
||||
private boolean blockMessage = false;
|
||||
|
||||
public boolean enabled() {
|
||||
@@ -127,12 +127,11 @@ public class ModerationSettings {
|
||||
|
||||
@ConfigSerializable
|
||||
public static class Filters {
|
||||
|
||||
@Setting
|
||||
private boolean enabled = true;
|
||||
|
||||
@Setting
|
||||
@Comment("The keys (\"****\" for example) are what the text is replaced with.\n" +
|
||||
@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).")
|
||||
@@ -143,7 +142,7 @@ public class ModerationSettings {
|
||||
};
|
||||
|
||||
@Setting
|
||||
@Comment("Anything in blocked-words will prevent the message from being sent at all.\n" +
|
||||
@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"));
|
||||
|
||||
@@ -158,7 +157,6 @@ public class ModerationSettings {
|
||||
public List<Pattern> blockedPatterns() {
|
||||
return this.blockedPatterns;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@ConfigSerializable
|
||||
public class RedisCredentials {
|
||||
public final class RedisCredentials {
|
||||
|
||||
@Setting private @NonNull String host = "localhost";
|
||||
@Setting private @Nullable String password = "";
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@ConfigSerializable
|
||||
public class SQLCredentials {
|
||||
public final class SQLCredentials {
|
||||
|
||||
@Setting private @NonNull String username = "username";
|
||||
@Setting private @NonNull String password = "password";
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ConfigSerializable
|
||||
public class SharedChannelOptions {
|
||||
public final class SharedChannelOptions {
|
||||
|
||||
@Setting private String color = "#FFFFFF";
|
||||
@Setting private Map<String, Context> contexts = new HashMap<>(); // TODO: set defaults
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@ConfigSerializable
|
||||
public class WhisperOptions {
|
||||
public final class WhisperOptions {
|
||||
|
||||
@Setting
|
||||
@Comment("Plays a sound when receiving private messages with /whisper /msg")
|
||||
|
||||
Reference in new issue
Block a user