cleanup project

This commit is contained in:
Draycia committed 2021-05-07 15:37:17 -07:00
1 parent 1231946184
commit 6681c22288
106 files changed
+10 -9601

No files matched your search

@@ -1,72 +1,5 @@
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;
import net.draycia.carbon.api.commands.settings.CommandSettingsRegistry;
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;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import java.io.File;
import java.nio.file.Path;
import java.util.UUID;
public interface CarbonChat {
LegacyComponentSerializer LEGACY =
LegacyComponentSerializer.builder()
.extractUrls()
.hexColors()
.character(LegacyComponentSerializer.SECTION_CHAR)
.useUnusualXRepeatedCharacterHexFormat()
.build();
void reload();
@NonNull File dataDirectory();
@NonNull UUID resolveUUID(@NonNull String name);
void cacheUUID(@NonNull String name, @NonNull UUID uuid);
@NonNull String resolveName(@NonNull UUID uuid);
@NonNull Logger logger();
@NonNull Path dataFolder();
@NonNull <T extends PlayerUser> UserService<T> userService();
@NonNull MessageProcessor messageProcessor();
@NonNull MessageService messageService();
@NonNull CarbonSettings carbonSettings();
@NonNull ChannelSettings channelSettings();
@NonNull ChannelRegistry channelRegistry();
@NonNull CommandSettingsRegistry commandSettings();
@NonNull CarbonTranslations translations();
@NonNull ModerationSettings moderationSettings();
@NonNull GsonComponentSerializer gsonSerializer();
@NonNull CommandManager<CarbonUser> commandManager();
@NonNull String version();
}
@@ -1,141 +0,0 @@
package net.draycia.carbon.api;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import java.util.Arrays;
import java.util.List;
@ConfigSerializable
public class Context {
@Setting private final @NonNull String key;
@Setting private final @NonNull String value;
public Context(final @NonNull String key, final @NonNull String value) {
this.key = key;
this.value = value;
}
public @NonNull String key() {
return this.key;
}
public @NonNull String value() {
return this.value;
}
public boolean isFloat() {
try {
Float.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public boolean isDouble() {
try {
Double.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public boolean isByte() {
try {
Byte.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public boolean isInteger() {
try {
Integer.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public boolean isLong() {
try {
Long.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public boolean isString() {
return true;
}
public boolean isBoolean() {
try {
Boolean.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public boolean isList() {
return true;
}
public boolean isListChecked(final Class<?> type) {
if (!this.isList()) {
return false;
}
final List<?> list = this.asList();
if (list.size() > 0) {
final Object value = list.get(0);
if (value != null) {
return value.getClass().isAssignableFrom(type);
}
}
return false;
}
public boolean isNumber() {
try {
Double.valueOf(this.value);
} catch (final NumberFormatException ignored) {
return false;
}
return true;
}
public String asString() {
return this.value();
}
public Boolean asBoolean() {
return Boolean.valueOf(this.value());
}
public List<String> asList() {
return Arrays.asList(this.value.split(","));
}
public Number asNumber() {
return Double.valueOf(this.value());
}
}
@@ -1,14 +0,0 @@
package net.draycia.carbon.api.adventure;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface MessageProcessor {
@NonNull Component processMessage(final @Nullable String input, final @NonNull String @NonNull ... placeholders);
@NonNull AudienceProvider audiences();
}
@@ -1,77 +0,0 @@
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.DefaultedKeyValueRegistry;
import net.kyori.registry.Registry;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class ChannelRegistry implements Registry<String, ChatChannel>, DefaultedKeyValueRegistry<String, ChatChannel> {
private final @NonNull Map<@NonNull String, @NonNull ChatChannel> registry = new HashMap<>();
private @NonNull ChatChannel defaultChannel = new EmptyTextChannel();
@Override
public @NonNull ChatChannel register(final @NonNull String key, final @NonNull ChatChannel value) {
this.registry.putIfAbsent(key, value);
if (value instanceof TextChannel) {
if (this.defaultChannel instanceof EmptyTextChannel && ((TextChannel) value).isDefault()) {
this.defaultChannel = value;
}
}
return value;
}
@Override
public @Nullable ChatChannel get(final @NonNull String key) {
return this.registry.get(key);
}
@Override
public @Nullable String key(final @NonNull ChatChannel value) {
for (final Map.Entry<String, ChatChannel> entry : this.registry.entrySet()) {
if (entry.getValue().equals(value)) {
return entry.getKey();
}
}
return null;
}
@Override
public @NonNull Set<String> keySet() {
return (Set<String>) this.registry.keySet(); // https://github.com/typetools/checker-framework/issues/3638
}
@Override
public @NonNull Iterator<ChatChannel> iterator() {
return this.registry.values().iterator();
}
@Override
public @NonNull String defaultKey() {
return this.defaultChannel.key();
}
@Override
public @NonNull ChatChannel defaultValue() {
return this.defaultChannel;
}
@Override
public @NonNull ChatChannel getOrDefault(final @NonNull String key) {
return this.registry.getOrDefault(key, this.defaultValue());
}
public void clear() {
this.registry.clear();
}
}
@@ -1,80 +0,0 @@
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.config.ChannelOptions;
import net.draycia.carbon.api.users.CarbonUser;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public interface ChatChannel extends Audience {
/**
* Gets the {@link TextColor} the supplied {@link CarbonUser} has set for this channel.
* If none is set, returns this channel's set color with the "color" config option.
* @param user The user that may have a color set.
* @return The color the user may have set, otherwise the channel's color.
*/
@NonNull TextColor channelColor(@NonNull CarbonUser user);
@NonNull
Map<CarbonUser, Component> parseMessage(@NonNull PlayerUser user, @NonNull String message);
@NonNull
Map<CarbonUser, Component> parseMessage(@NonNull PlayerUser user, @NonNull Collection<@NonNull PlayerUser> recipients,
@NonNull String message);
boolean canPlayerUse(@NonNull PlayerUser user);
boolean canPlayerSee(@NonNull PlayerUser sender, @NonNull PlayerUser target, boolean checkSpying);
boolean canPlayerSee(@NonNull PlayerUser target, boolean checkSpying);
void sendComponents(final @NonNull Identity identity,
final @NonNull Map<? extends CarbonUser, Component> components);
void sendComponentsAndLog(final @NonNull Identity identity,
final @NonNull Map<? extends CarbonUser, Component> components);
@NonNull String name();
@NonNull String key();
/**
* If this channel can be ignored, such as through the /toggle command.
* @return IF this channel can be ignored / toggled.
*/
boolean ignorable();
@NonNull List<@NonNull Pattern> itemLinkPatterns();
@NonNull String switchMessage();
@NonNull String switchOtherMessage();
@NonNull String switchFailureMessage();
@NonNull String cannotIgnoreMessage();
@NonNull String toggleOffMessage();
@NonNull String toggleOnMessage();
@NonNull String toggleOtherOnMessage();
@NonNull String toggleOtherOffMessage();
@NonNull String cannotUseMessage();
@NonNull ChannelOptions options();
void options(@NonNull ChannelOptions options);
}
@@ -1,207 +0,0 @@
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.Context;
import net.draycia.carbon.api.config.ChannelOptions;
import net.draycia.carbon.api.users.CarbonUser;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.luckperms.api.model.group.Group;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public class EmptyTextChannel implements TextChannel {
@Override
public @NonNull List<@NonNull PlayerUser> audiences() {
return Collections.emptyList();
}
@Override
public @NonNull ChannelOptions options() {
return ChannelOptions.defaultChannel();
}
@Override
public void options(final @NonNull ChannelOptions options) {
}
@Override
public @Nullable String format(final @NonNull Group group) {
return null;
}
@Override
public @Nullable String format(final @NonNull String group) {
return null;
}
@Override
public boolean isDefault() {
return true;
}
@Override
public boolean crossServer() {
return false;
}
@Override
public @Nullable String messagePrefix() {
return null;
}
@Override
public @NonNull List<String> aliases() {
return Collections.emptyList();
}
@Override
public boolean primaryGroupOnly() {
return false;
}
@Override
public boolean honorsRecipientList() {
return false;
}
@Override
public boolean permissionGroupMatching() {
return false;
}
@Override
public boolean testContext(final @NonNull PlayerUser sender, final @NonNull PlayerUser target) {
return false;
}
@Override
public @Nullable Context context(final @NonNull String key) {
return null;
}
@Override
public @NonNull List<@NonNull String> groupOverrides() {
return Collections.emptyList();
}
@Override
public void sendComponent(final @NonNull PlayerUser user, final @NonNull Component component) {
}
@Override
public @NonNull TextColor channelColor(final @NonNull CarbonUser user) {
return NamedTextColor.WHITE;
}
@Override
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user, final @NonNull String message) {
return Collections.emptyMap();
}
@Override
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message) {
return Collections.emptyMap();
}
@Override
public boolean canPlayerUse(final @NonNull PlayerUser user) {
return false;
}
@Override
public boolean canPlayerSee(final @NonNull PlayerUser sender, final @NonNull PlayerUser target, final boolean checkSpying) {
return false;
}
@Override
public boolean canPlayerSee(final @NonNull PlayerUser target, final boolean checkSpying) {
return false;
}
@Override
public void sendComponents(final @NonNull Identity identity, final @NonNull Map<? extends CarbonUser, Component> components) {
}
@Override
public void sendComponentsAndLog(final @NonNull Identity identity, final @NonNull Map<? extends CarbonUser, Component> components) {
}
@Override
public @NonNull String name() {
return "default";
}
@Override
public @NonNull String key() {
return "default";
}
@Override
public boolean ignorable() {
return false;
}
@Override
public @NonNull List<@NonNull Pattern> itemLinkPatterns() {
return Collections.emptyList();
}
@Override
public @NonNull String switchMessage() {
return "";
}
@Override
public @NonNull String switchOtherMessage() {
return "";
}
@Override
public @NonNull String switchFailureMessage() {
return "";
}
@Override
public @NonNull String cannotIgnoreMessage() {
return "";
}
@Override
public @NonNull String toggleOffMessage() {
return "";
}
@Override
public @NonNull String toggleOnMessage() {
return "";
}
@Override
public @NonNull String toggleOtherOnMessage() {
return "";
}
@Override
public @NonNull String toggleOtherOffMessage() {
return "";
}
@Override
public @NonNull String cannotUseMessage() {
return "";
}
}
@@ -1,16 +0,0 @@
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.users.CarbonUser;
import net.kyori.adventure.audience.ForwardingAudience;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
public interface GroupChannel extends ChatChannel, ForwardingAudience {
@NonNull CarbonUser owner();
@Override
@NonNull Collection<@NonNull CarbonUser> audiences();
}
@@ -1,63 +0,0 @@
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.Context;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.adventure.audience.ForwardingAudience;
import net.kyori.adventure.text.Component;
import net.luckperms.api.model.group.Group;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.List;
public interface TextChannel extends ChatChannel, ForwardingAudience {
@Override
@NonNull List<@NonNull PlayerUser> audiences();
/**
* Gets the string format for the specified group.
* @param group The group.
* @return The string format for the specified group.
*/
@Nullable String format(@NonNull Group group);
/**
* Gets the string format for the specified group.
* @param group The group.
* @return The string format for the specified group.
*/
@Nullable String format(@NonNull String group);
/**
* If this channel is the channel players get when they join for the first time.
* Also the fallback channel in case the code is unable to find any given channel.
* @return If this is the default channel.
*/
boolean isDefault();
/**
* If this channel syncs between servers, typically through the messaging service.
* @return If this channel syncs between servers, typically through the messaging service.
*/
boolean crossServer();
@Nullable String messagePrefix();
@NonNull List<String> aliases();
boolean primaryGroupOnly();
boolean honorsRecipientList();
boolean permissionGroupMatching();
boolean testContext(@NonNull PlayerUser sender, @NonNull PlayerUser target);
@Nullable Context context(@NonNull String key);
@NonNull List<@NonNull String> groupOverrides();
void sendComponent(@NonNull PlayerUser user, @NonNull Component component);
}
@@ -1,28 +0,0 @@
package net.draycia.carbon.api.channels;
import net.draycia.carbon.api.users.CarbonUser;
import net.kyori.adventure.audience.ForwardingAudience;
import org.checkerframework.checker.nullness.qual.NonNull;
public interface WhisperChannel extends ChatChannel, ForwardingAudience.Single {
@NonNull CarbonUser sender();
/**
* The recipient for this channel, where messages are sent to.
* @return The channel recipient.
*/
@Override
@NonNull CarbonUser audience();
@Override
default @NonNull String name() {
return "Whisper";
}
@Override
default @NonNull String key() {
return "whisper";
}
}
@@ -1,33 +0,0 @@
package net.draycia.carbon.api.commands.settings;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import java.util.Collections;
import java.util.Set;
@ConfigSerializable
public class CommandSettings {
@Setting
private boolean enabled = true;
@Setting
private @NonNull String name = "command";
@Setting
private @NonNull Set<@NonNull String> aliases = Collections.emptySet();
public @NonNull Set<@NonNull String> aliases() {
return this.aliases;
}
public @NonNull String name() {
return this.name;
}
public boolean enabled() {
return this.enabled;
}
}
@@ -1,73 +0,0 @@
package net.draycia.carbon.api.commands.settings;
import net.draycia.carbon.api.channels.ChatChannel;
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.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ConfigSerializable
public class CommandSettingsRegistry implements Registry<String, CommandSettings> {
@Setting
private final @NonNull Map<@NonNull String, @NonNull CommandSettings> registry = new HashMap<>();
private static final ObjectMapper<CommandSettingsRegistry> MAPPER;
static {
try {
MAPPER = ObjectMapper.factory().get(CommandSettingsRegistry.class);
} catch (final SerializationException e) {
throw new ExceptionInInitializerError(e);
}
}
public static CommandSettingsRegistry loadFrom(final CommentedConfigurationNode node) throws SerializationException {
return MAPPER.load(node);
}
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node);
}
@Override
public @NonNull CommandSettings register(final @NonNull String key, final @NonNull CommandSettings value) {
this.registry.putIfAbsent(key, value);
return value;
}
@Override
public @Nullable CommandSettings get(final @NonNull String key) {
return this.registry.get(key);
}
public @Nullable CommandSettings get(final @NonNull ChatChannel channel) {
return this.get(channel.key());
}
@Override
public @Nullable String key(final @NonNull CommandSettings value) {
return null;
}
@Override
public @NonNull Set<String> keySet() {
return (Set<String>) this.registry.keySet(); // https://github.com/typetools/checker-framework/issues/3638
}
@Override
public @NonNull Iterator<CommandSettings> iterator() {
return this.registry.values().iterator();
}
}
@@ -1,134 +0,0 @@
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.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
@ConfigSerializable
public final class CarbonSettings {
private static final ObjectMapper<CarbonSettings> MAPPER;
static {
try {
MAPPER = ObjectMapper.factory().get(CarbonSettings.class);
} catch (final SerializationException e) {
throw new ExceptionInInitializerError(e);
}
}
public static CarbonSettings loadFrom(final CommentedConfigurationNode node) throws SerializationException {
return MAPPER.load(node);
}
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node);
}
@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")
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.")
private boolean showTips = true;
@Setting
@Comment("Options: JSON, MYSQL")
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();
@Setting
@Comment("Options: NONE, REDIS, BUNGEECORD\n" +
" 'BUNGEECORD' - Uses bungee plugin messaging, requires BungeeCord or another proxy which supports it (Velocity, Waterfall!)\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" +
"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 MessagingType messagingType = MessagingType.NONE;
@Setting
@Comment("The credentials necessary to connect to your redis server")
private @NonNull RedisCredentials redisCredentials = new RedisCredentials();
@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")
private @NonNull WhisperOptions whisperOptions = new WhisperOptions();
@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. '\\\\Q' and '\\\\E' just denote that the content isn't regex.")
private List<Pattern> itemLinkPatterns =
Collections.singletonList(Pattern.compile(Pattern.quote("[item]")));
public @NonNull List<@NonNull Pattern> itemLinkPatterns() {
return this.itemLinkPatterns;
}
public @NonNull String spyPrefix() {
return this.spyPrefix;
}
public @NonNull String serverName() {
return this.serverName;
}
public boolean showTips() {
return this.showTips;
}
public @Nullable StorageType storageType() {
return this.storageType;
}
public SQLCredentials sqlCredentials() {
return this.sqlCredentials;
}
public @NonNull MessagingType messagingType() {
return this.messagingType;
}
public @NonNull RedisCredentials redisCredentials() {
return this.redisCredentials;
}
public @Nullable String channelOnJoin() {
return this.channelOnJoin;
}
public @NonNull ChannelPings channelPings() {
return this.channelPings;
}
public @NonNull WhisperOptions whisperOptions() {
return this.whisperOptions;
}
}
@@ -1,227 +0,0 @@
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.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
@ConfigSerializable
public final class CarbonTranslations {
private static final ObjectMapper<CarbonTranslations> MAPPER;
static {
try {
MAPPER = ObjectMapper.factory().get(CarbonTranslations.class);
} catch (final SerializationException e) {
throw new ExceptionInInitializerError(e);
}
}
public static CarbonTranslations loadFrom(final CommentedConfigurationNode node) throws SerializationException {
return MAPPER.load(node);
}
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node);
}
private ExceptionMessages exceptionMessages = new ExceptionMessages();
private ContextMessages contextMessages = new ContextMessages();
@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!";
@Setting private String otherNicknameSet = "<green><user><reset>''s nickname was set to <nickname><green>!";
@Setting private String otherNicknameReset = "<green><user><reset>'s nickname was reset!";
@Setting private String availableChannelsList = "<green>Available Channels:<reset> <list>.";
@Setting private String unavailableChannelsList = "<red>Unavailable Channels:<reset> <list>.";
@Setting private String channelListSeparator = ", ";
@Setting private String userMustBeOnline = "<red><player> must be online!";
@Setting private String replyMessageBlank = "<red>Your reply message was blank!";
@Setting private String invalidColor = "<red>The input <input> is not a valid color!";
@Setting private String cannotSetColor = "<red>You do not have permission to set a color for this channel!";
@Setting private String roleplayFormat = "<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>";
@Setting private String ignoringUser = "<green>You are now ignoring <gold><player><reset><green>!";
@Setting private String notIgnoringUser = "<green>You are no longer ignoring <gold><player><reset><green>!";
@Setting private String ignoreExempt = "<red>User <player> <red>is exempt from being ignored!";
@Setting private String channelColorSet = "<green>You have set <color><channel> <green>color to <hex>!";
@Setting private String spyToggledOn = "<gray>You are now spying on <color><channel> <gray>chat!";
@Setting private String spyToggledOff = "<gray>You are no longer spying on <color><channel> <gray>chat!";
@Setting private String spyWhispersOn = "<gray>You are now spying on whispers!";
@Setting private String spyWhispersOff = "<gray>You are no longer spying on whispers!";
@Setting private String spyEverythingOn = "<gray>All spying toggled on!";
@Setting private String spyEverythingOff = "<gray>All spying toggled off!";
@Setting private String nicknameSet = "<green>Your nickname was set to <nickname><reset><green>!";
@Setting private String nicknameReset = "<green>Your nickname was reset!";
@Setting private String nowShadowMuted = "<yellow>Player <player> is now shadow muted!";
@Setting private String noLongerShadowMuted = "<yellow>Player <player> is no longer shadow muted!";
@Setting private String shadowMuteExempt = "<red>Player <player> is exempt from being shadow muted!";
@Setting private String nowMuted = "<yellow>Player <player> is now muted!";
@Setting private String noLongerMuted = "<yellow>Player <player> is no longer muted!";
@Setting private String muteExempt = "<red>Player <player> is exempt from being muted!";
@Setting private String clearNotify = "<yellow>Chat has been cleared by <player>.";
@Setting private String clearExempt = "<yellow>You were exempt from the clear due to your permissions!";
@Setting private String cannotWhisperSelf = "<yellow>You cannot whisper yourself!";
@Setting private String whisperPingChanged = "<green>Whisper ping settings changed!";
@Setting private String channelPingChanged = "<green>Channel ping settings changed!";
public ExceptionMessages exceptionMessages() {
return this.exceptionMessages;
}
public ContextMessages contextMessages() {
return this.contextMessages;
}
public String reloaded() {
return this.reloaded;
}
public String otherPlayerOffline() {
return this.otherPlayerOffline;
}
public String spyWhispers() {
return this.spyWhispers;
}
public String noReplyTarget() {
return this.noReplyTarget;
}
public String otherNicknameSet() {
return this.otherNicknameSet;
}
public String otherNicknameReset() {
return this.otherNicknameReset;
}
public String availableChannelsList() {
return this.availableChannelsList;
}
public String unavailableChannelsList() {
return this.unavailableChannelsList;
}
public String channelListSeparator() {
return this.channelListSeparator;
}
public String userMustBeOnline() {
return this.userMustBeOnline;
}
public String replyMessageBlank() {
return this.replyMessageBlank;
}
public String invalidColor() {
return this.invalidColor;
}
public String cannotSetColor() {
return this.cannotSetColor;
}
public String roleplayFormat() {
return this.roleplayFormat;
}
public String ignoringUser() {
return this.ignoringUser;
}
public String notIgnoringUser() {
return this.notIgnoringUser;
}
public String ignoreExempt() {
return this.ignoreExempt;
}
public String channelColorSet() {
return this.channelColorSet;
}
public String spyToggledOn() {
return this.spyToggledOn;
}
public String spyToggledOff() {
return this.spyToggledOff;
}
public String spyWhispersOn() {
return this.spyWhispersOn;
}
public String spyWhispersOff() {
return this.spyWhispersOff;
}
public String spyEverythingOn() {
return this.spyEverythingOn;
}
public String spyEverythingOff() {
return this.spyEverythingOff;
}
public String nicknameSet() {
return this.nicknameSet;
}
public String nicknameReset() {
return this.nicknameReset;
}
public String nowShadowMuted() {
return this.nowShadowMuted;
}
public String noLongerShadowMuted() {
return this.noLongerShadowMuted;
}
public String shadowMuteExempt() {
return this.shadowMuteExempt;
}
public String nowMuted() {
return this.nowMuted;
}
public String noLongerMuted() {
return this.noLongerMuted;
}
public String muteExempt() {
return this.muteExempt;
}
public String clearNotify() {
return this.clearNotify;
}
public String clearExempt() {
return this.clearExempt;
}
public String cannotWhisperSelf() {
return this.cannotWhisperSelf;
}
public String channelPingChanged() {
return this.channelPingChanged;
}
public String whisperPingChanged() {
return this.whisperPingChanged;
}
}
@@ -1,402 +0,0 @@
package net.draycia.carbon.api.config;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import net.draycia.carbon.api.CarbonChatProvider;
import net.draycia.carbon.api.Context;
import net.kyori.adventure.text.format.NamedTextColor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ConfigSerializable
@SuppressWarnings("initialization.fields.uninitialized")
public final class ChannelOptions {
@Setting
@Comment("What this channel is identified as. This is used in command arguments (/channel global)")
private @NonNull String key = "channel";
@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 @Nullable String color = NamedTextColor.WHITE.asHexString();
@Setting
@Comment("The contexts for this channel, which can modify the behaviour of channels and how/when players can use them.")
private @Nullable Map<@NonNull String, @NonNull Context> contexts = new HashMap<>();
@Setting
@Comment("The formats for this channel. The key is the name of the group as your permissions plugin reports it.")
private @Nullable Map<String, String> formats = ImmutableMap.of("default", "<color><<displayname><reset><color>> <message>");
@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 @Nullable String defaultFormatName;
@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")
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")
private Boolean crossServer;
@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")
private Boolean permissionGroupMatching;
@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 (\"You switched to the Global channel\")")
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")
private String messagePrefix = "";
@Setting
@Comment("The command aliases for this channel (/global /g)")
private List<String> aliases = new ArrayList<>();
@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")
private Boolean primaryGroupOnly;
@Setting
@Comment("The message that's sent when switching to this channel")
private String switchMessage;
@Setting
@Comment("The message that's sent when forcing other players to switch to this channel")
private String switchOtherMessage;
@Setting
@Comment("The message that's sent when you're unable to switch to a channel")
private String switchFailureMessage;
@Setting
@Comment("The message that's sent when you are now able to see messages in a channel")
private String toggleOnMessage;
@Setting
@Comment("The message that's sent when you can no longer see messages in a channel")
private String toggleOffMessage;
@Setting
@Comment("The message that's sent when you toggle another player's channel visibility on")
private String toggleOtherOnMessage;
@Setting
@Comment("The message that's sent when you toggle another player's channel visibility off")
private String toggleOtherOffMessage;
@Setting
@Comment("The message that's sent when you cannot speak in a channel")
private String cannotUseMessage;
@Setting
@Comment("The message that's sent when you attempt to ignore a channel but are unable to do so")
private String cannotIgnoreMessage;
@Setting
@Comment("The order in which colors are chosen for the <color> tag.\n" +
"Options:\n" +
" PLAYER: The color the player has set with /setcolor\n" +
" CUSTOM: The color the player has set with /setchannelcolor\n" +
" CHANNEL: The color the channel has set in its settings")
private List<@NonNull ColorPriority> colorPriorities = ImmutableList.of(
ColorPriority.PLAYER, ColorPriority.CUSTOM, ColorPriority.CHANNEL);
private @NonNull SharedChannelOptions defaultOptions() {
return CarbonChatProvider.carbonChat().channelSettings().defaultChannelOptions();
}
public static ChannelOptions defaultChannel() {
final ChannelOptions settings = new ChannelOptions();
settings.key = "global";
settings.isDefault = true;
settings.name = "Global";
settings.color = "#FFFFFF";
settings.defaultFormatName = "default";
settings.formats = Collections.singletonMap("default", "<color><<displayname><reset><color>> <message>");
settings.aliases = Lists.newArrayList("global", "g");
settings.contexts = Collections.singletonMap("distance", new Context("filter", "true"));
return settings;
}
public @NonNull String key() {
return this.key;
}
public @NonNull String color() {
if (this.color == null) {
return this.defaultOptions().color();
}
return this.color;
}
public @Nullable Context context(final @NonNull String key) {
final Context localContext;
if (this.contexts != null) {
localContext = this.contexts.get(key);
} else {
localContext = null;
}
if (localContext == null) {
return this.defaultOptions().contexts().get(key);
}
return localContext;
}
public @NonNull Map<String, Context> contexts() {
if (this.contexts == null) {
return this.defaultOptions().contexts();
}
return this.contexts;
}
public @NonNull Map<String, Context> contextsAndDefault() {
if (this.contexts == null) {
return this.defaultOptions().contexts();
}
final Map<String, Context> contexts = new HashMap<>(this.defaultOptions().contexts());
if (this.contexts != null) {
contexts.putAll(this.contexts);
}
return contexts;
}
public @Nullable String format(final @NonNull String key) {
final String localFormat = this.formats().get(key);
if (localFormat == null) {
return this.defaultOptions().formats().get(key);
}
return localFormat;
}
public @NonNull Map<@NonNull String, @NonNull String> formats() {
if (this.formats == null) {
return this.defaultOptions().formats();
}
return this.formats;
}
public @NonNull Map<@NonNull String, @NonNull String> formatsAndDefault() {
if (this.formats == null) {
return this.defaultOptions().formats();
}
final Map<String, String> formats = new HashMap<>(this.defaultOptions().formats());
if (this.formats != null) {
formats.putAll(this.formats);
}
return formats;
}
public @NonNull String defaultFormatName() {
if (this.defaultFormatName == null || this.defaultFormatName.isEmpty()) {
return this.defaultOptions().defaultFormatName();
}
return this.defaultFormatName;
}
public boolean isDefault() {
return this.isDefault;
}
public Boolean ignorable() {
if (this.ignorable == null) {
return this.defaultOptions().ignorable();
}
return this.ignorable;
}
public Boolean crossServer() {
if (this.crossServer == null) {
return this.defaultOptions().crossServer();
}
return this.crossServer;
}
public Boolean honorsRecipientList() {
if (this.honorsRecipientList == null) {
return this.defaultOptions().honorsRecipientList();
}
return this.honorsRecipientList;
}
public Boolean permissionGroupMatching() {
if (this.permissionGroupMatching == null) {
return this.defaultOptions().permissionGroupMatching();
}
return this.permissionGroupMatching;
}
public @NonNull List<@NonNull String> groupOverrides() {
if (this.groupOverrides == null || this.groupOverrides.isEmpty()) {
return this.defaultOptions().groupOverrides();
}
return this.groupOverrides;
}
public @NonNull String name() {
if (this.name == null) {
return this.key;
}
return this.name;
}
public @Nullable String messagePrefix() {
return this.messagePrefix;
}
public @NonNull String switchMessage() {
if (this.switchMessage == null) {
return this.defaultOptions().switchMessage();
}
return this.switchMessage;
}
public @NonNull String switchOtherMessage() {
if (this.switchOtherMessage == null) {
return this.defaultOptions().switchOtherMessage();
}
return this.switchOtherMessage;
}
public @NonNull String switchFailureMessage() {
if (this.switchFailureMessage == null) {
return this.defaultOptions().switchFailureMessage();
}
return this.switchFailureMessage;
}
public @NonNull String cannotIgnoreMessage() {
if (this.cannotIgnoreMessage == null) {
return this.defaultOptions().cannotIgnoreMessage();
}
return this.cannotIgnoreMessage;
}
public @NonNull String toggleOffMessage() {
if (this.toggleOffMessage == null) {
return this.defaultOptions().toggleOffMessage();
}
return this.toggleOffMessage;
}
public @NonNull String toggleOnMessage() {
if (this.toggleOnMessage == null) {
return this.defaultOptions().toggleOnMessage();
}
return this.toggleOnMessage;
}
public @NonNull String toggleOtherOnMessage() {
if (this.toggleOtherOnMessage == null) {
return this.defaultOptions().toggleOtherOnMessage();
}
return this.toggleOtherOnMessage;
}
public @NonNull String toggleOtherOffMessage() {
if (this.toggleOtherOffMessage == null) {
return this.defaultOptions().toggleOtherOffMessage();
}
return this.toggleOtherOffMessage;
}
public @NonNull String cannotUseMessage() {
if (this.cannotUseMessage == null) {
return this.defaultOptions().cannotUseMessage();
}
return this.cannotUseMessage;
}
public Boolean primaryGroupOnly() {
if (this.primaryGroupOnly == null) {
return this.defaultOptions().primaryGroupOnly();
}
return this.primaryGroupOnly;
}
public Boolean shouldCancelChatEvent() {
if (this.shouldCancelChatEvent == null) {
return this.defaultOptions().shouldCancelChatEvent();
}
return this.shouldCancelChatEvent;
}
public List<ColorPriority> colorPriorities() {
if (this.colorPriorities == null) {
return this.defaultOptions().colorPriorities();
}
return this.colorPriorities;
}
public @NonNull List<String> aliases() {
return this.aliases;
}
}
@@ -1,58 +0,0 @@
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.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")
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")
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")
private boolean caseSensitive = false;
@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,
10.0F,
1.0F
);
@Setting
@Comment("The way players will see the ping")
private @NonNull String display = "<bold><red><ping></red><bold>";
public boolean enabled() {
return this.enabled;
}
public String prefix() {
return this.prefix;
}
public boolean caseSensitive() {
return this.caseSensitive;
}
public Sound sound() {
return this.sound;
}
public String display() {
return this.display;
}
}
@@ -1,68 +0,0 @@
package net.draycia.carbon.api.config;
import com.google.common.collect.ImmutableMap;
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.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collections;
import java.util.Map;
@ConfigSerializable
public final class ChannelSettings {
private static final ObjectMapper<ChannelSettings> MAPPER;
static {
try {
MAPPER = ObjectMapper.factory().get(ChannelSettings.class);
} catch (final SerializationException e) {
throw new ExceptionInInitializerError(e);
}
}
public static ChannelSettings loadFrom(final CommentedConfigurationNode node) throws SerializationException {
return MAPPER.load(node);
}
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node);
}
@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();
@Setting
private Map<@NonNull String, @NonNull ChannelOptions> channelOptions =
Collections.singletonMap("global", ChannelOptions.defaultChannel());
@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<@NonNull String, @NonNull String> customPlaceholders =
ImmutableMap.of("prefix", "<gray>[<group><gray>]", "group", "<green>%vault_group%");
public SharedChannelOptions defaultChannelOptions() {
return this.sharedChannelOptions;
}
public Map<String, ChannelOptions> channelOptions() {
return this.channelOptions;
}
public Map<String, String> customPlaceholders() {
return this.customPlaceholders;
}
public @Nullable ChannelOptions channelOptions(final @NonNull String name) {
return this.channelOptions.get(name);
}
}
@@ -1,7 +0,0 @@
package net.draycia.carbon.api.config;
public enum ColorPriority {
PLAYER,
CUSTOM,
CHANNEL
}
@@ -1,31 +0,0 @@
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 ContextMessages {
@Setting private @NonNull String vaultBalanceNotEnough = "<red>You do not have enough balance, required: <balance><red>.";
@Setting private @NonNull String vaultCostNotEnough = "<red>You do not have enough balance, cost: <balance><red>.";
@Setting private @NonNull String mcmmoPartyNotInParty = "<red>You are not in a party!";
@Setting private @NonNull String townyTownNotInTown = "<red>You are not in a town!";
public String vaultBalanceNotEnough() {
return this.vaultBalanceNotEnough;
}
public String vaultCostNotEnough() {
return this.vaultCostNotEnough;
}
public String mcmmoPartyNotInParty() {
return this.mcmmoPartyNotInParty;
}
public String townyTownNotInTown() {
return this.townyTownNotInTown;
}
}
@@ -1,26 +0,0 @@
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;
}
}
@@ -1,7 +0,0 @@
package net.draycia.carbon.api.config;
public enum MessagingType {
NONE,
REDIS,
BUNGEECORD
}
@@ -1,158 +0,0 @@
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.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import org.spongepowered.configurate.serialize.SerializationException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@ConfigSerializable
public final class ModerationSettings {
private static final ObjectMapper<ModerationSettings> MAPPER;
static {
try {
MAPPER = ObjectMapper.factory().get(ModerationSettings.class);
} catch (final SerializationException e) {
throw new ExceptionInInitializerError(e);
}
}
public static ModerationSettings loadFrom(final CommentedConfigurationNode node) throws SerializationException {
return MAPPER.load(node);
}
public void saveTo(final CommentedConfigurationNode node) throws SerializationException {
MAPPER.save(this, node);
}
@Setting
@Comment("The text that's prepended to someone else's shadowmuted messages.")
private String shadowMutePrefix = "[SM] ";
public String shadowMutePrefix() {
return this.shadowMutePrefix;
}
@Setting
@Comment("If true, muted users will be unable to use /whisper /msg")
private boolean muteStopsWhispers = true;
public boolean muteStopsWhispers() {
return this.muteStopsWhispers;
}
@Setting
private ClearChat clearChat = new ClearChat();
public ClearChat clearChat() {
return this.clearChat;
}
@ConfigSerializable
public static class ClearChat {
@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")
private int messageCount = 100;
public String message() {
return this.message;
}
public int messageCount() {
return this.messageCount;
}
}
@Setting
private CapsProtection capsProtection = new CapsProtection();
public CapsProtection capsProtection() {
return this.capsProtection;
}
@ConfigSerializable
public static class CapsProtection {
@Setting
@Comment("If caps protection is enabled")
private boolean enabled = true;
@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")
private float percentCaps = 0.80F;
@Setting
@Comment("If true, stops message from sending. If false, simply changes the message to lowercase")
private boolean blockMessage = false;
public boolean enabled() {
return this.enabled;
}
public int minimumLength() {
return this.minimumLength;
}
public float percentCaps() {
return this.percentCaps;
}
public boolean blockMessage() {
return this.blockMessage;
}
}
@Setting
private Filters filters = new Filters();
public Filters filters() {
return this.filters;
}
@ConfigSerializable
public static class Filters {
@Setting
private boolean enabled = true;
@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).")
private Map<String, List<Pattern>> replacements =
Collections.singletonMap("****", Collections.singletonList(Pattern.compile("la[g]+")));
@Setting
@Comment("Anything in blocked-words will prevent the message from being sent at all.\n" +
"Set to blocked-patterns: [] if you want to disable the blocked words feature.")
private List<Pattern> blockedPatterns = Collections.singletonList(Pattern.compile("pineapple doesn't belong on pizza"));
public boolean enabled() {
return this.enabled;
}
public Map<String, List<Pattern>> replacements() {
return this.replacements;
}
public List<Pattern> blockedPatterns() {
return this.blockedPatterns;
}
}
}
@@ -1,32 +0,0 @@
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.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
@ConfigSerializable
public final class RedisCredentials {
@Setting private @NonNull String host = "localhost";
@Setting private @Nullable String password = "";
@Setting private int port = 6379;
@Setting private @Nullable Integer database = null;
public @NonNull String host() {
return this.host;
}
public @Nullable String password() {
return this.password;
}
public int port() {
return this.port;
}
public @Nullable Integer database() {
return this.database;
}
}
@@ -1,36 +0,0 @@
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 SQLCredentials {
@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;
}
public @NonNull String password() {
return this.password;
}
public @NonNull String database() {
return this.database;
}
public @NonNull String host() {
return this.host;
}
public int port() {
return this.port;
}
}
@@ -1,124 +0,0 @@
package net.draycia.carbon.api.config;
import com.google.common.collect.ImmutableMap;
import net.draycia.carbon.api.Context;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ConfigSerializable
public final class SharedChannelOptions {
@Setting private @NonNull String color = "#FFFFFF";
@Setting private @NonNull Map<String, Context> contexts = new HashMap<>();
@Setting private @NonNull Map<@NonNull String, @NonNull String> formats =
ImmutableMap.of("default", "<color><<displayname><reset><color>> <message>",
"staff", "<#00CED1>[Staff] <color><<displayname><reset><color>> <message>");
@Setting private @NonNull String defaultFormatName = "default";
@Setting private boolean ignorable = true;
@Setting private boolean crossServer = true;
@Setting private boolean honorsRecipientList = false;
@Setting private boolean permissionGroupMatching = false;
@Setting private @NonNull List<String> groupOverrides = new ArrayList<>();
@Setting private boolean shouldCancelChatEvent = false;
@Setting private boolean primaryGroupOnly = false;
@Setting private @NonNull String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
@Setting private @NonNull String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
@Setting private @NonNull String switchFailureMessage = "<red>You cannot use channel <channel>!";
@Setting private @NonNull String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
@Setting private @NonNull String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
@Setting private @NonNull String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
@Setting private @NonNull String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
@Setting private @NonNull String cannotUseMessage = "You cannot use that channel!";
@Setting private @NonNull String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
@Setting private @NonNull List<@NonNull ColorPriority> colorPriorities = new ArrayList<>();
public @NonNull String color() {
return this.color;
}
public @NonNull Map<String, Context> contexts() {
return this.contexts;
}
public @NonNull Map<String, String> formats() {
return this.formats;
}
public @NonNull String defaultFormatName() {
return this.defaultFormatName;
}
public boolean ignorable() {
return this.ignorable;
}
public boolean crossServer() {
return this.crossServer;
}
public boolean honorsRecipientList() {
return this.honorsRecipientList;
}
public boolean permissionGroupMatching() {
return this.permissionGroupMatching;
}
public @NonNull List<@NonNull String> groupOverrides() {
return this.groupOverrides;
}
public @NonNull String switchMessage() {
return this.switchMessage;
}
public @NonNull String switchOtherMessage() {
return this.switchOtherMessage;
}
public @NonNull String switchFailureMessage() {
return this.switchFailureMessage;
}
public @NonNull String cannotIgnoreMessage() {
return this.cannotIgnoreMessage;
}
public @NonNull String toggleOffMessage() {
return this.toggleOffMessage;
}
public @NonNull String toggleOnMessage() {
return this.toggleOnMessage;
}
public @NonNull String toggleOtherOnMessage() {
return this.toggleOtherOnMessage;
}
public @NonNull String toggleOtherOffMessage() {
return this.toggleOtherOffMessage;
}
public @NonNull String cannotUseMessage() {
return this.cannotUseMessage;
}
public boolean primaryGroupOnly() {
return this.primaryGroupOnly;
}
public boolean shouldCancelChatEvent() {
return this.shouldCancelChatEvent;
}
public @NonNull List<@NonNull ColorPriority> colorPriorities() {
return this.colorPriorities;
}
}
@@ -1,6 +0,0 @@
package net.draycia.carbon.api.config;
public enum StorageType {
MYSQL,
JSON
}
@@ -1,156 +0,0 @@
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.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;
@ConfigSerializable
public final class WhisperOptions {
@Setting
@Comment("Plays a sound when receiving private messages with /whisper /msg")
private @NonNull WhisperPings pings = new WhisperPings();
@Setting
@Comment("If enabled, players will be able to whisper other players as if they had their own private channel, " +
"without the need to type /r or /msg each message. /msg [player]")
private boolean useEnhancedWhispers = false;
@Setting
@Comment("")
private @NonNull String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
@Setting
@Comment("")
private @NonNull String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
@Setting
@Comment("")
private @NonNull String switchFailureMessage = "<red>You cannot use channel <channel>!";
@Setting
@Comment("")
private @NonNull String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
@Setting
@Comment("")
private @NonNull String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
@Setting
@Comment("")
private @NonNull String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
@Setting
@Comment("")
private @NonNull String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
@Setting
@Comment("")
private @NonNull String cannotUseMessage = "You cannot use that channel!";
@Setting
@Comment("")
private @NonNull String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
@Setting
@Comment("")
private @NonNull String senderFormat = "<gold>[<white>Me <gray>-> <white><receiver><gold>] <message>";
@Setting
@Comment("")
private @NonNull String receiverFormat = "<gold>[<white><sender> <gray>-> <white>Me<gold>] <message>";
@Setting
@Comment("")
private @NonNull String consoleFormat = "<gold>[<white><sender> <gray>-> <white><receiver><gold>] <message>";
@Setting
@Comment("")
private @NonNull String nowWhisperingPlayer = "<white>You are now whispering <green><player><white>!";
@Setting
@Comment("The message that's sent when attempting to message someone when you have whispers toggled off.")
private @NonNull String senderToggledOff = "<red>You have whispers toggled off!";
@Setting
@Comment("The message that's sent when attempting to message someone who has whispers toggled off.")
private @NonNull String receiverToggledOff = "<red><receiver> <red>has whispers toggled off!";
@Setting
@Comment("")
private boolean logToConsole = true;
public boolean logToConsole() {
return this.logToConsole;
}
public @NonNull WhisperPings pings() {
return this.pings;
}
public boolean useEnhancedWhispers() {
return this.useEnhancedWhispers;
}
public @NonNull String consoleFormat() {
return this.consoleFormat;
}
public @NonNull String senderFormat() {
return this.senderFormat;
}
public @NonNull String receiverFormat() {
return this.receiverFormat;
}
public @NonNull String switchMessage() {
return this.switchMessage;
}
public @NonNull String switchOtherMessage() {
return this.switchOtherMessage;
}
public @NonNull String switchFailureMessage() {
return this.switchFailureMessage;
}
public @NonNull String cannotIgnoreMessage() {
return this.cannotIgnoreMessage;
}
public @NonNull String toggleOffMessage() {
return this.toggleOffMessage;
}
public @NonNull String toggleOnMessage() {
return this.toggleOnMessage;
}
public @NonNull String toggleOtherOnMessage() {
return this.toggleOtherOnMessage;
}
public @NonNull String toggleOtherOffMessage() {
return this.toggleOtherOffMessage;
}
public @NonNull String cannotUseMessage() {
return this.cannotUseMessage;
}
public @NonNull String nowWhisperingPlayer() {
return this.nowWhisperingPlayer;
}
public @NonNull String senderToggledOff() {
return this.senderToggledOff;
}
public @NonNull String receiverToggledOff() {
return this.receiverToggledOff;
}
}
@@ -1,29 +0,0 @@
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.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Setting;
@ConfigSerializable
public final class WhisperPings {
@Setting private boolean enabled = true;
@Setting private @NonNull Sound sound = Sound.sound(
Key.key(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup"),
Sound.Source.PLAYER,
10.0F,
1.0F
);
public boolean enabled() {
return this.enabled;
}
public Sound sound() {
return this.sound;
}
}
@@ -1,28 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.kyori.registry.Registry;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
public class ChannelRegisterEvent implements CarbonEvent {
private final @NonNull List<@NonNull ChatChannel> registeredChannels;
private final @NonNull Registry<String, ChatChannel> registry;
public ChannelRegisterEvent(final @NonNull List<@NonNull ChatChannel> registeredChannels, final @NonNull Registry<String, ChatChannel> registry) {
this.registeredChannels = registeredChannels;
this.registry = registry;
}
public void register(final @NonNull ChatChannel chatChannel) {
this.registry.register(chatChannel.key(), chatChannel);
}
public @NonNull List<@NonNull ChatChannel> registeredChannels() {
return this.registeredChannels;
}
}
@@ -1,48 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
public class ChannelSwitchEvent implements CarbonEvent, Cancellable {
private final @NonNull ChatChannel channel;
private final @NonNull PlayerUser user;
private @NonNull String failureMessage;
private boolean cancelled = false;
public ChannelSwitchEvent(final @NonNull ChatChannel channel, final @NonNull PlayerUser user, final @NonNull String failureMessage) {
this.channel = channel;
this.user = user;
this.failureMessage = failureMessage;
}
public @NonNull PlayerUser user() {
return this.user;
}
public @NonNull ChatChannel channel() {
return this.channel;
}
public @NonNull String failureMessage() {
return this.failureMessage;
}
public void failureMessage(final @NonNull String failureMessage) {
this.failureMessage = failureMessage;
}
@Override
public boolean cancelled() {
return this.cancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.cancelled = cancelled;
}
}
@@ -1,70 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.CarbonUser;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.adventure.text.TextComponent;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChatComponentEvent implements CarbonEvent, Cancellable {
private boolean isCancelled = false;
private final @NonNull PlayerUser sender;
private final @Nullable CarbonUser target;
private @NonNull ChatChannel chatChannel;
private @NonNull TextComponent component;
private final @NonNull String originalMessage;
public ChatComponentEvent(final @NonNull PlayerUser sender, final @Nullable CarbonUser target,
final @NonNull ChatChannel chatChannel, final @NonNull TextComponent component,
final @NonNull String originalMessage) {
this.sender = sender;
this.target = target;
this.chatChannel = chatChannel;
this.component = component;
this.originalMessage = originalMessage;
}
@Override
public boolean cancelled() {
return this.isCancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.isCancelled = cancelled;
}
public @NonNull PlayerUser sender() {
return this.sender;
}
public @Nullable CarbonUser target() {
return this.target;
}
public @NonNull ChatChannel channel() {
return this.chatChannel;
}
public void channel(final @NonNull ChatChannel chatChannel) {
this.chatChannel = chatChannel;
}
public @NonNull TextComponent component() {
return this.component;
}
public void component(final @NonNull TextComponent component) {
this.component = component;
}
public @NonNull String originalMessage() {
return this.originalMessage;
}
}
@@ -1,74 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.CarbonUser;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ChatFormatEvent implements CarbonEvent, Cancellable {
private boolean isCancelled = false;
private final @NonNull PlayerUser sender;
private final @Nullable CarbonUser target;
private @NonNull ChatChannel chatChannel;
private @NonNull String format;
private @NonNull String message;
public ChatFormatEvent(final @NonNull PlayerUser sender, final @Nullable CarbonUser target,
final @NonNull ChatChannel chatChannel, final @NonNull String format,
final @NonNull String message) {
this.sender = sender;
this.target = target;
this.chatChannel = chatChannel;
this.format = format;
this.message = message;
}
@Override
public boolean cancelled() {
return this.isCancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.isCancelled = cancelled;
}
public @NonNull PlayerUser sender() {
return this.sender;
}
public @Nullable CarbonUser target() {
return this.target;
}
public @NonNull ChatChannel channel() {
return this.chatChannel;
}
public void channel(final @NonNull ChatChannel chatChannel) {
this.chatChannel = chatChannel;
}
public @NonNull String format() {
return this.format;
}
public void format(final @NonNull String format) {
this.format = format;
}
public @NonNull String message() {
return this.message;
}
public void message(final @NonNull String message) {
this.message = message;
}
}
@@ -1,44 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.TextChannel;
import net.draycia.carbon.api.Context;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class MessageContextEvent implements CarbonEvent, Cancellable {
private final @NonNull TextChannel channel;
private final @NonNull PlayerUser user;
private boolean cancelled = false;
public MessageContextEvent(final @NonNull TextChannel channel, final @NonNull PlayerUser user) {
this.channel = channel;
this.user = user;
}
@Override
public boolean cancelled() {
return this.cancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.cancelled = cancelled;
}
public @Nullable Context context(final @NonNull String key) {
return this.channel.context(key);
}
public @NonNull TextChannel channel() {
return this.channel;
}
public @NonNull PlayerUser user() {
return this.user;
}
}
@@ -1,64 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
public class PreChatFormatEvent implements CarbonEvent, Cancellable {
private boolean isCancelled = false;
private final @NonNull PlayerUser user;
private @NonNull ChatChannel chatChannel;
private @NonNull String format;
private @NonNull String message;
public PreChatFormatEvent(final @NonNull PlayerUser user, final @NonNull ChatChannel chatChannel,
final @NonNull String format, final @NonNull String message) {
this.user = user;
this.chatChannel = chatChannel;
this.format = format;
this.message = message;
}
@Override
public boolean cancelled() {
return this.isCancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.isCancelled = cancelled;
}
public @NonNull PlayerUser user() {
return this.user;
}
public @NonNull ChatChannel channel() {
return this.chatChannel;
}
public void channel(final @NonNull ChatChannel chatChannel) {
this.chatChannel = chatChannel;
}
public @NonNull String format() {
return this.format;
}
public void format(final @NonNull String format) {
this.format = format;
}
public @NonNull String message() {
return this.message;
}
public void message(final @NonNull String message) {
this.message = message;
}
}
@@ -1,59 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.adventure.text.Component;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
public class PrivateMessageEvent implements CarbonEvent, Cancellable {
private final @NonNull PlayerUser sender;
private final @NonNull PlayerUser target;
private final @NonNull Component senderComponent;
private final @NonNull Component targetComponent;
private final @NonNull String message;
private boolean cancelled = false;
public PrivateMessageEvent(final @NonNull PlayerUser sender, final @NonNull PlayerUser target,
final @NonNull Component senderComponent, final @NonNull Component targetComponent,
final @NonNull String message) {
this.sender = sender;
this.target = target;
this.senderComponent = senderComponent;
this.targetComponent = targetComponent;
this.message = message;
}
@Override
public boolean cancelled() {
return this.cancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.cancelled = cancelled;
}
public @NonNull PlayerUser sender() {
return this.sender;
}
public @NonNull PlayerUser target() {
return this.target;
}
public @NonNull Component senderComponent() {
return this.senderComponent;
}
public @NonNull Component targetComponent() {
return this.targetComponent;
}
public @NonNull String message() {
return this.message;
}
}
@@ -1,51 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.channels.TextChannel;
import net.draycia.carbon.api.Context;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
public class ReceiverContextEvent implements CarbonEvent, Cancellable {
private final @NonNull TextChannel channel;
private final @NonNull PlayerUser sender;
private final @NonNull PlayerUser recipient;
private boolean cancelled = false;
public ReceiverContextEvent(final @NonNull TextChannel channel, final @NonNull PlayerUser sender,
final @NonNull PlayerUser recipient) {
this.channel = channel;
this.sender = sender;
this.recipient = recipient;
}
public @Nullable Context context(final @NonNull String key) {
return this.channel.context(key);
}
@Override
public boolean cancelled() {
return this.cancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.cancelled = cancelled;
}
public @NonNull TextChannel channel() {
return this.channel;
}
public @NonNull PlayerUser sender() {
return this.sender;
}
public @NonNull PlayerUser recipient() {
return this.recipient;
}
}
@@ -1,43 +0,0 @@
package net.draycia.carbon.api.events;
import net.draycia.carbon.api.events.misc.CarbonEvent;
import net.draycia.carbon.api.users.PlayerUser;
import net.kyori.event.Cancellable;
import org.checkerframework.checker.nullness.qual.NonNull;
public class UserEvent implements CarbonEvent, Cancellable {
private final @NonNull PlayerUser user;
private boolean cancelled = false;
public UserEvent(final @NonNull PlayerUser user) {
this.user = user;
}
public @NonNull PlayerUser user() {
return this.user;
}
@Override
public boolean cancelled() {
return this.cancelled;
}
@Override
public void cancelled(final boolean cancelled) {
this.cancelled = cancelled;
}
public static class Join extends UserEvent {
public Join(final @NonNull PlayerUser user) {
super(user);
}
}
public static class Leave extends UserEvent {
public Leave(final @NonNull PlayerUser user) {
super(user);
}
}
}
@@ -1,5 +0,0 @@
package net.draycia.carbon.api.events.misc;
public interface CarbonEvent {
}
@@ -1,48 +0,0 @@
package net.draycia.carbon.api.events.misc;
import net.kyori.event.EventSubscriber;
import net.kyori.event.PostResult;
import net.kyori.event.SimpleEventBus;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.function.Consumer;
public final class CarbonEvents {
private CarbonEvents() {
}
private static final SimpleEventBus<CarbonEvent> EVENT_BUS = new SimpleEventBus<>(CarbonEvent.class);
public static <T extends CarbonEvent> void register(final @NonNull Class<T> clazz, final @NonNull EventSubscriber<T> subscriber) {
EVENT_BUS.register(clazz, subscriber);
}
public static <T extends CarbonEvent> void register(final @NonNull Class<T> clazz, final int priority, final boolean consumeCancelled, final @NonNull Consumer<T> consumer) {
EVENT_BUS.register(clazz, new EventSubscriber<T>() {
@Override
public int postOrder() {
return priority;
}
@Override
public boolean consumeCancelledEvents() {
return consumeCancelled;
}
@Override
public void invoke(final @NonNull T event) {
consumer.accept(event);
}
});
}
public static void unregister(final @NonNull EventSubscriber<? super CarbonEvent> subscriber) {
EVENT_BUS.unregister(subscriber);
}
public static PostResult post(final @NonNull CarbonEvent event) {
return EVENT_BUS.post(event);
}
}
@@ -1,22 +0,0 @@
package net.draycia.carbon.api.messaging;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import net.draycia.carbon.api.users.PlayerUser;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
public interface MessageService {
void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener);
void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener);
void unregisterMessageListener(final @NonNull String key);
void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer);
}
@@ -1,13 +0,0 @@
package net.draycia.carbon.api.users;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identified;
import org.checkerframework.checker.nullness.qual.NonNull;
public interface CarbonUser extends Audience, Identified {
boolean hasPermission(@NonNull String permission);
@NonNull String name();
}
@@ -1,4 +0,0 @@
package net.draycia.carbon.api.users;
public interface ConsoleUser extends CarbonUser {
}
@@ -1,126 +0,0 @@
package net.draycia.carbon.api.users;
import net.draycia.carbon.api.channels.ChatChannel;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.format.TextColor;
import net.luckperms.api.model.group.Group;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.Map;
import java.util.UUID;
public interface PlayerUser extends CarbonUser {
@NonNull UUID uuid();
boolean online();
@NonNull String nickname();
void nickname(@Nullable String nickname);
@NonNull String displayName();
void displayName(@Nullable String displayName);
@NonNull String name();
@Nullable TextColor customChatColor();
void customChatColor(@Nullable TextColor customChatColor);
@NonNull String parsePlaceholders(@NonNull String input);
@NonNull UserChannelSettings channelSettings(@NonNull ChatChannel channel);
@NonNull Map<@NonNull String, @NonNull ? extends UserChannelSettings> channelSettings();
boolean spyingWhispers();
void spyingWhispers(boolean spyingWhispers);
boolean muted();
void muted(boolean muted);
boolean shadowMuted();
void shadowMuted(boolean shadowMuted);
@Nullable UUID replyTarget();
default void replyTarget(final @Nullable PlayerUser user) {
if (user == null) {
this.replyTarget((UUID) null);
} else {
this.replyTarget(user.uuid());
}
}
void replyTarget(@Nullable UUID target);
boolean ignoringUser(@NonNull UUID uuid);
void ignoringUser(@NonNull UUID uuid, boolean ignoring);
default boolean ignoringUser(final @NonNull PlayerUser user) {
return this.ignoringUser(user.uuid());
}
default void ignoringUser(final @NonNull PlayerUser user, boolean ignoring) {
this.ignoringUser(user.uuid(), ignoring);
}
@NonNull Iterable<CarbonUser> ignoredChatUsers();
@NonNull Iterable<UUID> ignoredUsers();
boolean hasGroup(@NonNull String group);
boolean hasGroup(@NonNull Group group);
@NonNull Collection<@NonNull Group> groups();
@Nullable Group primaryGroup();
void sendMessage(@NonNull PlayerUser sender, @NonNull String message);
@Nullable ChatChannel selectedChannel();
void selectedChannel(@NonNull ChatChannel channel);
void clearSelectedChannel();
@NonNull PingOptions pingOptions();
void pingOptions(@NonNull PingOptions pingOptions);
class PingOptions {
public @Nullable Sound whisperSound;
public @Nullable Sound pingSound;
public PingOptions(final @Nullable Sound whisperSound, final @Nullable Sound pingSound) {
this.whisperSound = whisperSound;
this.pingSound = pingSound;
}
public @Nullable Sound whisperSound() {
return this.whisperSound;
}
public void whisperSound(final @Nullable Sound whisperSound) {
this.whisperSound = whisperSound;
}
public @Nullable Sound pingSound() {
return this.pingSound;
}
public void pingSound(final @Nullable Sound pingSound) {
this.pingSound = pingSound;
}
}
}
@@ -1,21 +0,0 @@
package net.draycia.carbon.api.users;
import net.kyori.adventure.text.format.TextColor;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface UserChannelSettings {
boolean spying();
void spying(boolean spying);
boolean ignored();
void ignoring(boolean ignored);
@Nullable
TextColor color();
void color(@Nullable TextColor color);
}
@@ -1,32 +0,0 @@
package net.draycia.carbon.api.users;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public interface UserService<T extends PlayerUser> {
@Nullable <C extends ConsoleUser> C consoleUser();
@NonNull T wrap(@NonNull UUID uuid);
@NonNull CompletableFuture<T> wrapLater(@NonNull UUID uuid);
@Nullable T wrapIfLoaded(@NonNull UUID uuid);
@Nullable T refreshUser(@NonNull UUID uuid);
void onDisable();
void invalidate(@NonNull T user);
void validate(@NonNull T user);
@NonNull Collection<@NonNull T> onlineUsers();
@NonNull Collection<@NonNull String> proxyPlayers();
}