mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Add checkerframework compilation checking (#109)
* Reorder nullability annotations again * Add checker validation to API module * Add checker validation to Common module * Begin checker validation for Bukkit module * It compiles!
This commit is contained in:
1 parent
3314a51df8
commit
d9ab711adc
83 files changed
+1127
-717
No files matched your search
@@ -5,7 +5,7 @@ plugins {
|
||||
description 'CarbonChat-API'
|
||||
|
||||
dependencies {
|
||||
compile 'org.checkerframework:checker-qual:3.6.1'
|
||||
compile 'org.checkerframework:checker-qual:3.7.0'
|
||||
|
||||
compile 'net.kyori:adventure-api:4.1.1'
|
||||
compile 'net.kyori:adventure-nbt:4.1.1'
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
package net.draycia.carbon.api;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class CarbonChatProvider {
|
||||
|
||||
private CarbonChatProvider() {
|
||||
|
||||
}
|
||||
|
||||
private static CarbonChat instance;
|
||||
private static @Nullable CarbonChat instance;
|
||||
|
||||
public static void register(@NonNull final CarbonChat carbonChat) {
|
||||
public static void register(final @NonNull CarbonChat carbonChat) {
|
||||
CarbonChatProvider.instance = carbonChat;
|
||||
}
|
||||
|
||||
public static CarbonChat carbonChat() {
|
||||
public static @NonNull CarbonChat carbonChat() {
|
||||
if (CarbonChatProvider.instance == null) {
|
||||
throw new IllegalStateException("CarbonChat not initialized!"); // LuckPerms design go brrrr
|
||||
}
|
||||
|
||||
return CarbonChatProvider.instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import java.util.List;
|
||||
@ConfigSerializable
|
||||
public class Context {
|
||||
|
||||
@Setting private @NonNull final String key;
|
||||
@Setting private @NonNull final Object value;
|
||||
@Setting private final @NonNull String key;
|
||||
@Setting private final @NonNull Object value;
|
||||
|
||||
public Context(@NonNull final String key, @NonNull final Object value) {
|
||||
public Context(final @NonNull String key, final @NonNull Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class Context {
|
||||
final Object value = list.get(0);
|
||||
|
||||
if (value != null) {
|
||||
return list.get(0).getClass().isAssignableFrom(type);
|
||||
return value.getClass().isAssignableFrom(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface MessageProcessor {
|
||||
|
||||
@NonNull Component processMessage(@Nullable final String input, @NonNull final String @NonNull ... placeholders);
|
||||
@NonNull Component processMessage(final @Nullable String input, final @NonNull String @NonNull ... placeholders);
|
||||
|
||||
@NonNull AudienceProvider audiences();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.draycia.carbon.api.channels;
|
||||
|
||||
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;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -13,16 +12,16 @@ import java.util.Set;
|
||||
|
||||
public class ChannelRegistry implements Registry<String, ChatChannel>, DefaultedKeyValueRegistry<String, ChatChannel> {
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull ChatChannel> registry = new HashMap<>();
|
||||
private final @NonNull Map<@NonNull String, @NonNull ChatChannel> registry = new HashMap<>();
|
||||
|
||||
private @MonotonicNonNull ChatChannel defaultChannel = null;
|
||||
private @NonNull ChatChannel defaultChannel = new EmptyTextChannel();
|
||||
|
||||
@Override
|
||||
public @NonNull ChatChannel register(@NonNull final String key, @NonNull final ChatChannel value) {
|
||||
public @NonNull ChatChannel register(final @NonNull String key, final @NonNull ChatChannel value) {
|
||||
this.registry.putIfAbsent(key, value);
|
||||
|
||||
if (value instanceof TextChannel) {
|
||||
if (this.defaultChannel == null && ((TextChannel) value).isDefault()) {
|
||||
if (this.defaultChannel instanceof EmptyTextChannel && ((TextChannel) value).isDefault()) {
|
||||
this.defaultChannel = value;
|
||||
}
|
||||
}
|
||||
@@ -31,12 +30,12 @@ public class ChannelRegistry implements Registry<String, ChatChannel>, Defaulted
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ChatChannel get(@NonNull final String key) {
|
||||
public @Nullable ChatChannel get(final @NonNull String key) {
|
||||
return this.registry.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String key(@NonNull final ChatChannel value) {
|
||||
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();
|
||||
@@ -48,7 +47,7 @@ public class ChannelRegistry implements Registry<String, ChatChannel>, Defaulted
|
||||
|
||||
@Override
|
||||
public @NonNull Set<String> keySet() {
|
||||
return this.registry.keySet();
|
||||
return (Set<String>) this.registry.keySet(); // https://github.com/typetools/checker-framework/issues/3638
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +66,7 @@ public class ChannelRegistry implements Registry<String, ChatChannel>, Defaulted
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChatChannel getOrDefault(@NonNull final String key) {
|
||||
public @NonNull ChatChannel getOrDefault(final @NonNull String key) {
|
||||
return this.registry.getOrDefault(key, this.defaultValue());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ 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 org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -22,7 +21,7 @@ public interface ChatChannel extends Audience {
|
||||
* @param user The user that may have a color set.
|
||||
* @return The color the user may have set, otherwise the channel's color.
|
||||
*/
|
||||
@Nullable TextColor channelColor(@NonNull CarbonUser user);
|
||||
@NonNull TextColor channelColor(@NonNull CarbonUser user);
|
||||
|
||||
@NonNull
|
||||
Map<CarbonUser, Component> parseMessage(@NonNull PlayerUser user, @NonNull String message, boolean fromRemote);
|
||||
@@ -37,11 +36,11 @@ public interface ChatChannel extends Audience {
|
||||
|
||||
boolean canPlayerSee(@NonNull PlayerUser target, boolean checkSpying);
|
||||
|
||||
void sendComponents(@NonNull final Identity identity,
|
||||
@NonNull final Map<? extends CarbonUser, Component> components);
|
||||
void sendComponents(final @NonNull Identity identity,
|
||||
final @NonNull Map<? extends CarbonUser, Component> components);
|
||||
|
||||
void sendComponentsAndLog(@NonNull final Identity identity,
|
||||
@NonNull final Map<? extends CarbonUser, Component> components);
|
||||
void sendComponentsAndLog(final @NonNull Identity identity,
|
||||
final @NonNull Map<? extends CarbonUser, Component> components);
|
||||
|
||||
@NonNull String name();
|
||||
|
||||
@@ -55,22 +54,22 @@ public interface ChatChannel extends Audience {
|
||||
|
||||
@NonNull List<@NonNull Pattern> itemLinkPatterns();
|
||||
|
||||
@Nullable String switchMessage();
|
||||
@NonNull String switchMessage();
|
||||
|
||||
@Nullable String switchOtherMessage();
|
||||
@NonNull String switchOtherMessage();
|
||||
|
||||
@Nullable String switchFailureMessage();
|
||||
@NonNull String switchFailureMessage();
|
||||
|
||||
@Nullable String cannotIgnoreMessage();
|
||||
@NonNull String cannotIgnoreMessage();
|
||||
|
||||
@Nullable String toggleOffMessage();
|
||||
@NonNull String toggleOffMessage();
|
||||
|
||||
@Nullable String toggleOnMessage();
|
||||
@NonNull String toggleOnMessage();
|
||||
|
||||
@Nullable String toggleOtherOnMessage();
|
||||
@NonNull String toggleOtherOnMessage();
|
||||
|
||||
@Nullable String toggleOtherOffMessage();
|
||||
@NonNull String toggleOtherOffMessage();
|
||||
|
||||
@Nullable String cannotUseMessage();
|
||||
@NonNull String cannotUseMessage();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.Context;
|
||||
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 @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 @Nullable List<String> aliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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, final boolean fromRemote) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message, final boolean fromRemote) {
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,23 +1,23 @@
|
||||
package net.draycia.carbon.api.commands.settings;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
@ConfigSerializable
|
||||
public class CommandSettings {
|
||||
|
||||
@Setting
|
||||
private boolean enabled;
|
||||
private boolean enabled = true;
|
||||
|
||||
@Setting
|
||||
private @MonotonicNonNull String name;
|
||||
private @NonNull String name = "command";
|
||||
|
||||
@Setting
|
||||
private @MonotonicNonNull Set<@NonNull String> aliases;
|
||||
private @NonNull Set<@NonNull String> aliases = Collections.emptySet();
|
||||
|
||||
public @NonNull Set<@NonNull String> aliases() {
|
||||
return this.aliases;
|
||||
|
||||
+7
-7
@@ -19,7 +19,7 @@ import java.util.Set;
|
||||
public class CommandSettingsRegistry implements Registry<String, CommandSettings> {
|
||||
|
||||
@Setting
|
||||
private @NonNull final Map<@NonNull String, @NonNull CommandSettings> registry = new HashMap<>();
|
||||
private final @NonNull Map<@NonNull String, @NonNull CommandSettings> registry = new HashMap<>();
|
||||
|
||||
private static final ObjectMapper<CommandSettingsRegistry> MAPPER;
|
||||
|
||||
@@ -40,29 +40,29 @@ public class CommandSettingsRegistry implements Registry<String, CommandSettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CommandSettings register(@NonNull final String key, @NonNull final CommandSettings value) {
|
||||
this.registry.put(key, value);
|
||||
public @NonNull CommandSettings register(final @NonNull String key, final @NonNull CommandSettings value) {
|
||||
this.registry.putIfAbsent(key, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CommandSettings get(@NonNull final String key) {
|
||||
public @Nullable CommandSettings get(final @NonNull String key) {
|
||||
return this.registry.get(key);
|
||||
}
|
||||
|
||||
public @Nullable CommandSettings get(@NonNull final ChatChannel channel) {
|
||||
public @Nullable CommandSettings get(final @NonNull ChatChannel channel) {
|
||||
return this.get(channel.key());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String key(@NonNull final CommandSettings value) {
|
||||
public @Nullable String key(final @NonNull CommandSettings value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Set<String> keySet() {
|
||||
return this.registry.keySet();
|
||||
return (Set<String>) this.registry.keySet(); // https://github.com/typetools/checker-framework/issues/3638
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.draycia.carbon.api.config;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
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;
|
||||
@@ -15,32 +17,31 @@ 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 will be what's typed ingame to use the channel.")
|
||||
private String key = "channel";
|
||||
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 String color;
|
||||
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 Map<String, Context> contexts = new HashMap<>();
|
||||
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 Map<String, String> formats = new HashMap<String, String>() {{
|
||||
put("default", "<color><<displayname><reset><color>> <message>");
|
||||
}};
|
||||
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 String defaultFormatName;
|
||||
private @Nullable String defaultFormatName;
|
||||
|
||||
@Setting
|
||||
@Comment("If this channel is the default channel players join in.\n" +
|
||||
@@ -123,7 +124,7 @@ public final class ChannelOptions {
|
||||
@Comment("The message that's sent when you attempt to ignore a channel but are unable to do so")
|
||||
private String cannotIgnoreMessage;
|
||||
|
||||
private SharedChannelOptions defaultOptions() {
|
||||
private @NonNull SharedChannelOptions defaultOptions() {
|
||||
return CarbonChatProvider.carbonChat().channelSettings().defaultChannelOptions();
|
||||
}
|
||||
|
||||
@@ -151,7 +152,7 @@ public final class ChannelOptions {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public @Nullable Context context(@NonNull final String key) {
|
||||
public @Nullable Context context(final @NonNull String key) {
|
||||
final Context localContext;
|
||||
|
||||
if (this.contexts != null) {
|
||||
@@ -161,8 +162,10 @@ public final class ChannelOptions {
|
||||
}
|
||||
|
||||
if (localContext == null) {
|
||||
if (this.defaultOptions().contexts() != null) {
|
||||
return this.defaultOptions().contexts().get(key);
|
||||
final Map<String, Context> defaultContexts = this.defaultOptions().contexts();
|
||||
|
||||
if (defaultContexts != null) {
|
||||
return defaultContexts.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -184,28 +187,37 @@ public final class ChannelOptions {
|
||||
return this.defaultOptions().contexts();
|
||||
}
|
||||
|
||||
if (this.defaultOptions().contexts() == null) {
|
||||
final Map<String, Context> defaultContexts = this.defaultOptions().contexts();
|
||||
|
||||
if (defaultContexts == null) {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
final Map<String, Context> contexts = new HashMap<>(this.defaultOptions().contexts());
|
||||
contexts.putAll(this.contexts);
|
||||
final Map<String, Context> contexts = new HashMap<>(defaultContexts);
|
||||
|
||||
if (this.contexts != null) {
|
||||
contexts.putAll(this.contexts);
|
||||
}
|
||||
|
||||
return contexts;
|
||||
}
|
||||
|
||||
public @Nullable String format(@NonNull final String key) {
|
||||
public @Nullable String format(final @NonNull String key) {
|
||||
final String localFormat;
|
||||
|
||||
if (this.formats() != null) {
|
||||
localFormat = this.formats().get(key);
|
||||
final Map<String, String> localFormats = this.formats();
|
||||
|
||||
if (localFormats != null) {
|
||||
localFormat = localFormats.get(key);
|
||||
} else {
|
||||
localFormat = null;
|
||||
}
|
||||
|
||||
if (localFormat == null) {
|
||||
if (this.defaultOptions().formats() != null) {
|
||||
return this.defaultOptions().formats().get(key);
|
||||
final Map<String, String> defaultFormats = this.defaultOptions().formats();
|
||||
|
||||
if (defaultFormats != null) {
|
||||
return defaultFormats.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -214,7 +226,7 @@ public final class ChannelOptions {
|
||||
return localFormat;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> formats() {
|
||||
public @Nullable Map<@NonNull String, @NonNull String> formats() {
|
||||
if (this.formats == null) {
|
||||
return this.defaultOptions().formats();
|
||||
}
|
||||
@@ -222,17 +234,22 @@ public final class ChannelOptions {
|
||||
return this.formats;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> formatsAndDefault() {
|
||||
public @Nullable Map<@NonNull String, @NonNull String> formatsAndDefault() {
|
||||
if (this.formats == null) {
|
||||
return this.defaultOptions().formats();
|
||||
}
|
||||
|
||||
if (this.defaultOptions().formats() == null) {
|
||||
final Map<String, String> defaultFormats = this.defaultOptions().formats();
|
||||
|
||||
if (defaultFormats == null) {
|
||||
return this.formats;
|
||||
}
|
||||
|
||||
final Map<String, String> formats = new HashMap<>(this.defaultOptions().formats());
|
||||
formats.putAll(this.formats);
|
||||
final Map<String, String> formats = new HashMap<>(defaultFormats);
|
||||
|
||||
if (this.formats != null) {
|
||||
formats.putAll(this.formats);
|
||||
}
|
||||
|
||||
return formats;
|
||||
}
|
||||
@@ -301,7 +318,7 @@ public final class ChannelOptions {
|
||||
return this.messagePrefix;
|
||||
}
|
||||
|
||||
public @Nullable String switchMessage() {
|
||||
public @NonNull String switchMessage() {
|
||||
if (this.switchMessage == null) {
|
||||
return this.defaultOptions().switchMessage();
|
||||
}
|
||||
@@ -309,7 +326,7 @@ public final class ChannelOptions {
|
||||
return this.switchMessage;
|
||||
}
|
||||
|
||||
public @Nullable String switchOtherMessage() {
|
||||
public @NonNull String switchOtherMessage() {
|
||||
if (this.switchOtherMessage == null) {
|
||||
return this.defaultOptions().switchOtherMessage();
|
||||
}
|
||||
@@ -317,7 +334,7 @@ public final class ChannelOptions {
|
||||
return this.switchOtherMessage;
|
||||
}
|
||||
|
||||
public @Nullable String switchFailureMessage() {
|
||||
public @NonNull String switchFailureMessage() {
|
||||
if (this.switchFailureMessage == null) {
|
||||
return this.defaultOptions().switchFailureMessage();
|
||||
}
|
||||
@@ -325,7 +342,7 @@ public final class ChannelOptions {
|
||||
return this.switchFailureMessage;
|
||||
}
|
||||
|
||||
public @Nullable String cannotIgnoreMessage() {
|
||||
public @NonNull String cannotIgnoreMessage() {
|
||||
if (this.cannotIgnoreMessage == null) {
|
||||
return this.defaultOptions().cannotIgnoreMessage();
|
||||
}
|
||||
@@ -333,7 +350,7 @@ public final class ChannelOptions {
|
||||
return this.cannotIgnoreMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOffMessage() {
|
||||
public @NonNull String toggleOffMessage() {
|
||||
if (this.toggleOffMessage == null) {
|
||||
return this.defaultOptions().toggleOffMessage();
|
||||
}
|
||||
@@ -341,7 +358,7 @@ public final class ChannelOptions {
|
||||
return this.toggleOffMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOnMessage() {
|
||||
public @NonNull String toggleOnMessage() {
|
||||
if (this.toggleOnMessage == null) {
|
||||
return this.defaultOptions().toggleOnMessage();
|
||||
}
|
||||
@@ -349,7 +366,7 @@ public final class ChannelOptions {
|
||||
return this.toggleOnMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOtherOnMessage() {
|
||||
public @NonNull String toggleOtherOnMessage() {
|
||||
if (this.toggleOtherOnMessage == null) {
|
||||
return this.defaultOptions().toggleOtherOnMessage();
|
||||
}
|
||||
@@ -357,7 +374,7 @@ public final class ChannelOptions {
|
||||
return this.toggleOtherOnMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOtherOffMessage() {
|
||||
public @NonNull String toggleOtherOffMessage() {
|
||||
if (this.toggleOtherOffMessage == null) {
|
||||
return this.defaultOptions().toggleOtherOffMessage();
|
||||
}
|
||||
@@ -365,7 +382,7 @@ public final class ChannelOptions {
|
||||
return this.toggleOtherOffMessage;
|
||||
}
|
||||
|
||||
public @Nullable String cannotUseMessage() {
|
||||
public @NonNull String cannotUseMessage() {
|
||||
if (this.cannotUseMessage == null) {
|
||||
return this.defaultOptions().cannotUseMessage();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -10,7 +11,6 @@ import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ConfigSerializable
|
||||
@@ -40,18 +40,14 @@ public final class ChannelSettings {
|
||||
private SharedChannelOptions sharedChannelOptions = new SharedChannelOptions();
|
||||
|
||||
@Setting
|
||||
private Map<String, ChannelOptions> channelOptions =
|
||||
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<@Nullable String, @NonNull String> customPlaceholders = new HashMap<String, String>() {
|
||||
{
|
||||
this.put("prefix", "<gray>[<group><gray>]");
|
||||
this.put("group", "<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;
|
||||
@@ -65,7 +61,7 @@ public final class ChannelSettings {
|
||||
return this.customPlaceholders;
|
||||
}
|
||||
|
||||
public ChannelOptions channelOptions(final String name) {
|
||||
public @Nullable ChannelOptions channelOptions(final @NonNull String name) {
|
||||
return this.channelOptions.get(name);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -135,11 +134,8 @@ public final class ModerationSettings {
|
||||
"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 = new HashMap<String, List<Pattern>>() {
|
||||
{
|
||||
this.put("****", Collections.singletonList(Pattern.compile("la[g]+")));
|
||||
}
|
||||
};
|
||||
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" +
|
||||
|
||||
+30
-31
@@ -1,8 +1,8 @@
|
||||
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.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@@ -14,43 +14,42 @@ import java.util.Map;
|
||||
@ConfigSerializable
|
||||
public final class SharedChannelOptions {
|
||||
|
||||
@Setting private String color = "#FFFFFF";
|
||||
@Setting private Map<String, Context> contexts = new HashMap<>();
|
||||
@Setting private Map<String, String> formats = new HashMap<String, String>() {{
|
||||
put("default", "<color><<displayname><reset><color>> <message>");
|
||||
put("staff", "<#00CED1>[Staff] <color><<displayname><reset><color>> <message>");
|
||||
}};
|
||||
@Setting private String defaultFormatName = "default";
|
||||
@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 List<String> groupOverrides = new ArrayList<>();
|
||||
@Setting private @NonNull List<String> groupOverrides = new ArrayList<>();
|
||||
@Setting private boolean shouldCancelChatEvent = false;
|
||||
@Setting private boolean primaryGroupOnly = false;
|
||||
@Setting private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||
@Setting private String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
|
||||
@Setting private String switchFailureMessage = "<red>You cannot use channel <channel>!";
|
||||
@Setting private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||
@Setting private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||
@Setting private String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
|
||||
@Setting private String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
|
||||
@Setting private String cannotUseMessage = "You cannot use that channel!";
|
||||
@Setting private String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
|
||||
@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!";
|
||||
|
||||
public @Nullable String color() {
|
||||
public @NonNull String color() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, Context> contexts() {
|
||||
public @NonNull Map<String, Context> contexts() {
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> formats() {
|
||||
public @NonNull Map<String, String> formats() {
|
||||
return this.formats;
|
||||
}
|
||||
|
||||
public @Nullable String defaultFormatName() {
|
||||
public @NonNull String defaultFormatName() {
|
||||
return this.defaultFormatName;
|
||||
}
|
||||
|
||||
@@ -74,39 +73,39 @@ public final class SharedChannelOptions {
|
||||
return this.groupOverrides;
|
||||
}
|
||||
|
||||
public @Nullable String switchMessage() {
|
||||
public @NonNull String switchMessage() {
|
||||
return this.switchMessage;
|
||||
}
|
||||
|
||||
public @Nullable String switchOtherMessage() {
|
||||
public @NonNull String switchOtherMessage() {
|
||||
return this.switchOtherMessage;
|
||||
}
|
||||
|
||||
public @Nullable String switchFailureMessage() {
|
||||
public @NonNull String switchFailureMessage() {
|
||||
return this.switchFailureMessage;
|
||||
}
|
||||
|
||||
public @Nullable String cannotIgnoreMessage() {
|
||||
public @NonNull String cannotIgnoreMessage() {
|
||||
return this.cannotIgnoreMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOffMessage() {
|
||||
public @NonNull String toggleOffMessage() {
|
||||
return this.toggleOffMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOnMessage() {
|
||||
public @NonNull String toggleOnMessage() {
|
||||
return this.toggleOnMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOtherOnMessage() {
|
||||
public @NonNull String toggleOtherOnMessage() {
|
||||
return this.toggleOtherOnMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOtherOffMessage() {
|
||||
public @NonNull String toggleOtherOffMessage() {
|
||||
return this.toggleOtherOffMessage;
|
||||
}
|
||||
|
||||
public @Nullable String cannotUseMessage() {
|
||||
public @NonNull String cannotUseMessage() {
|
||||
return this.cannotUseMessage;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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.Comment;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
@@ -15,55 +14,55 @@ public final class WhisperOptions {
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||
private @NonNull String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
|
||||
private @NonNull String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String switchFailureMessage = "<red>You cannot use channel <channel>!";
|
||||
private @NonNull String switchFailureMessage = "<red>You cannot use channel <channel>!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||
private @NonNull String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||
private @NonNull String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
|
||||
private @NonNull String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
|
||||
private @NonNull String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String cannotUseMessage = "You cannot use that channel!";
|
||||
private @NonNull String cannotUseMessage = "You cannot use that channel!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
|
||||
private @NonNull String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String senderFormat = "<gold>[<white>Me <gray>-> <white><receiver><gold>] <message>";
|
||||
private @NonNull String senderFormat = "<gold>[<white>Me <gray>-> <white><receiver><gold>] <message>";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String receiverFormat = "<gold>[<white><sender> <gray>-> <white>Me<gold>] <message>";
|
||||
private @NonNull String receiverFormat = "<gold>[<white><sender> <gray>-> <white>Me<gold>] <message>";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String consoleFormat = "<gold>[<white><sender> <gray>-> <white><receiver><gold>] <message>";
|
||||
private @NonNull String consoleFormat = "<gold>[<white><sender> <gray>-> <white><receiver><gold>] <message>";
|
||||
|
||||
@Setting
|
||||
@Comment("")
|
||||
private String nowWhisperingPlayer = "<white>You are now whispering <green><player><white>!";
|
||||
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.")
|
||||
@@ -85,55 +84,55 @@ public final class WhisperOptions {
|
||||
return this.pings;
|
||||
}
|
||||
|
||||
public @Nullable String consoleFormat() {
|
||||
public @NonNull String consoleFormat() {
|
||||
return this.consoleFormat;
|
||||
}
|
||||
|
||||
public @Nullable String senderFormat() {
|
||||
public @NonNull String senderFormat() {
|
||||
return this.senderFormat;
|
||||
}
|
||||
|
||||
public @Nullable String receiverFormat() {
|
||||
public @NonNull String receiverFormat() {
|
||||
return this.receiverFormat;
|
||||
}
|
||||
|
||||
public @Nullable String switchMessage() {
|
||||
public @NonNull String switchMessage() {
|
||||
return this.switchMessage;
|
||||
}
|
||||
|
||||
public @Nullable String switchOtherMessage() {
|
||||
public @NonNull String switchOtherMessage() {
|
||||
return this.switchOtherMessage;
|
||||
}
|
||||
|
||||
public @Nullable String switchFailureMessage() {
|
||||
public @NonNull String switchFailureMessage() {
|
||||
return this.switchFailureMessage;
|
||||
}
|
||||
|
||||
public @Nullable String cannotIgnoreMessage() {
|
||||
public @NonNull String cannotIgnoreMessage() {
|
||||
return this.cannotIgnoreMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOffMessage() {
|
||||
public @NonNull String toggleOffMessage() {
|
||||
return this.toggleOffMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOnMessage() {
|
||||
public @NonNull String toggleOnMessage() {
|
||||
return this.toggleOnMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOtherOnMessage() {
|
||||
public @NonNull String toggleOtherOnMessage() {
|
||||
return this.toggleOtherOnMessage;
|
||||
}
|
||||
|
||||
public @Nullable String toggleOtherOffMessage() {
|
||||
public @NonNull String toggleOtherOffMessage() {
|
||||
return this.toggleOtherOffMessage;
|
||||
}
|
||||
|
||||
public @Nullable String cannotUseMessage() {
|
||||
public @NonNull String cannotUseMessage() {
|
||||
return this.cannotUseMessage;
|
||||
}
|
||||
|
||||
public @Nullable String nowWhisperingPlayer() {
|
||||
public @NonNull String nowWhisperingPlayer() {
|
||||
return this.nowWhisperingPlayer;
|
||||
}
|
||||
|
||||
@@ -141,7 +140,7 @@ public final class WhisperOptions {
|
||||
return this.senderToggledOff;
|
||||
}
|
||||
|
||||
public @Nullable String receiverToggledOff() {
|
||||
public @NonNull String receiverToggledOff() {
|
||||
return this.receiverToggledOff;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -9,15 +9,15 @@ import java.util.List;
|
||||
|
||||
public class ChannelRegisterEvent implements CarbonEvent {
|
||||
|
||||
private @NonNull final List<@NonNull ChatChannel> registeredChannels;
|
||||
private @NonNull final Registry<String, ChatChannel> registry;
|
||||
private final @NonNull List<@NonNull ChatChannel> registeredChannels;
|
||||
private final @NonNull Registry<String, ChatChannel> registry;
|
||||
|
||||
public ChannelRegisterEvent(@NonNull final List<@NonNull ChatChannel> registeredChannels, @NonNull final 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(@NonNull final ChatChannel chatChannel) {
|
||||
public void register(final @NonNull ChatChannel chatChannel) {
|
||||
this.registry.register(chatChannel.key(), chatChannel);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,16 +5,15 @@ 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 ChannelSwitchEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final ChatChannel channel;
|
||||
private @NonNull final PlayerUser user;
|
||||
private final @NonNull ChatChannel channel;
|
||||
private final @NonNull PlayerUser user;
|
||||
private @NonNull String failureMessage;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public ChannelSwitchEvent(@NonNull final ChatChannel channel, @NonNull final PlayerUser user, @Nullable final String failureMessage) {
|
||||
public ChannelSwitchEvent(final @NonNull ChatChannel channel, final @NonNull PlayerUser user, final @NonNull String failureMessage) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.failureMessage = failureMessage;
|
||||
@@ -28,11 +27,11 @@ public class ChannelSwitchEvent implements CarbonEvent, Cancellable {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public @Nullable String failureMessage() {
|
||||
public @NonNull String failureMessage() {
|
||||
return this.failureMessage;
|
||||
}
|
||||
|
||||
public void failureMessage(@Nullable final String failureMessage) {
|
||||
public void failureMessage(final @NonNull String failureMessage) {
|
||||
this.failureMessage = failureMessage;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class ChatComponentEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private @NonNull final PlayerUser sender;
|
||||
private @NonNull final PlayerUser target;
|
||||
private final @NonNull PlayerUser sender;
|
||||
private final @Nullable PlayerUser target;
|
||||
private @NonNull ChatChannel chatChannel;
|
||||
private @NonNull TextComponent component;
|
||||
private @NonNull final String originalMessage;
|
||||
private final @NonNull String originalMessage;
|
||||
|
||||
public ChatComponentEvent(@NonNull final PlayerUser sender, @Nullable final PlayerUser target,
|
||||
@NonNull final ChatChannel chatChannel, @NonNull final TextComponent component,
|
||||
@NonNull final String originalMessage) {
|
||||
public ChatComponentEvent(final @NonNull PlayerUser sender, final @Nullable PlayerUser target,
|
||||
final @NonNull ChatChannel chatChannel, final @NonNull TextComponent component,
|
||||
final @NonNull String originalMessage) {
|
||||
|
||||
this.sender = sender;
|
||||
this.target = target;
|
||||
@@ -50,7 +50,7 @@ public class ChatComponentEvent implements CarbonEvent, Cancellable {
|
||||
return this.chatChannel;
|
||||
}
|
||||
|
||||
public void channel(@NonNull final ChatChannel chatChannel) {
|
||||
public void channel(final @NonNull ChatChannel chatChannel) {
|
||||
this.chatChannel = chatChannel;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ChatComponentEvent implements CarbonEvent, Cancellable {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
public void component(@NonNull final TextComponent component) {
|
||||
public void component(final @NonNull TextComponent component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,15 +10,15 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class ChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private @NonNull final PlayerUser sender;
|
||||
private @NonNull final PlayerUser target;
|
||||
private final @NonNull PlayerUser sender;
|
||||
private final @Nullable PlayerUser target;
|
||||
private @NonNull ChatChannel chatChannel;
|
||||
private @NonNull String format;
|
||||
private @NonNull String message;
|
||||
|
||||
public ChatFormatEvent(@NonNull final PlayerUser sender, @Nullable final PlayerUser target,
|
||||
@NonNull final ChatChannel chatChannel, @Nullable final String format,
|
||||
@NonNull final String message) {
|
||||
public ChatFormatEvent(final @NonNull PlayerUser sender, final @Nullable PlayerUser target,
|
||||
final @NonNull ChatChannel chatChannel, final @NonNull String format,
|
||||
final @NonNull String message) {
|
||||
|
||||
this.sender = sender;
|
||||
this.target = target;
|
||||
@@ -50,15 +50,15 @@ public class ChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
return this.chatChannel;
|
||||
}
|
||||
|
||||
public void channel(@NonNull final ChatChannel chatChannel) {
|
||||
public void channel(final @NonNull ChatChannel chatChannel) {
|
||||
this.chatChannel = chatChannel;
|
||||
}
|
||||
|
||||
public @Nullable String format() {
|
||||
public @NonNull String format() {
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public void format(@Nullable final String format) {
|
||||
public void format(final @NonNull String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void message(@NonNull final String message) {
|
||||
public void message(final @NonNull String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,15 @@ 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 @NonNull final TextChannel channel;
|
||||
private @NonNull final PlayerUser user;
|
||||
private final @NonNull TextChannel channel;
|
||||
private final @NonNull PlayerUser user;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public MessageContextEvent(@NonNull final TextChannel channel, @NonNull final PlayerUser user) {
|
||||
public MessageContextEvent(final @NonNull TextChannel channel, final @NonNull PlayerUser user) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -28,7 +29,7 @@ public class MessageContextEvent implements CarbonEvent, Cancellable {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public Context context(@NonNull final String key) {
|
||||
public @Nullable Context context(final @NonNull String key) {
|
||||
return this.channel.context(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private @NonNull final PlayerUser user;
|
||||
private final @NonNull PlayerUser user;
|
||||
private @NonNull ChatChannel chatChannel;
|
||||
private @NonNull String format;
|
||||
private @NonNull String message;
|
||||
|
||||
public PreChatFormatEvent(@NonNull final PlayerUser user, @NonNull final ChatChannel chatChannel,
|
||||
@NonNull final String format, @NonNull final 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;
|
||||
@@ -41,7 +41,7 @@ public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
return this.chatChannel;
|
||||
}
|
||||
|
||||
public void channel(@NonNull final ChatChannel chatChannel) {
|
||||
public void channel(final @NonNull ChatChannel chatChannel) {
|
||||
this.chatChannel = chatChannel;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
return this.format;
|
||||
}
|
||||
|
||||
public void format(@NonNull final String format) {
|
||||
public void format(final @NonNull String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void message(@NonNull final String message) {
|
||||
public void message(final @NonNull String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,16 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class PrivateMessageEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final PlayerUser sender;
|
||||
private @NonNull final PlayerUser target;
|
||||
private @NonNull final Component senderComponent;
|
||||
private @NonNull final Component targetComponent;
|
||||
private @NonNull final String message;
|
||||
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(@NonNull final PlayerUser sender, @NonNull final PlayerUser target,
|
||||
@NonNull final Component senderComponent, @NonNull final Component targetComponent,
|
||||
@NonNull final String message) {
|
||||
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;
|
||||
|
||||
+7
-6
@@ -6,22 +6,23 @@ 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 @NonNull final TextChannel channel;
|
||||
private @NonNull final PlayerUser sender;
|
||||
private @NonNull final PlayerUser recipient;
|
||||
private final @NonNull TextChannel channel;
|
||||
private final @NonNull PlayerUser sender;
|
||||
private final @NonNull PlayerUser recipient;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public ReceiverContextEvent(@NonNull final TextChannel channel, @NonNull final PlayerUser sender,
|
||||
@NonNull final PlayerUser recipient) {
|
||||
public ReceiverContextEvent(final @NonNull TextChannel channel, final @NonNull PlayerUser sender,
|
||||
final @NonNull PlayerUser recipient) {
|
||||
this.channel = channel;
|
||||
this.sender = sender;
|
||||
this.recipient = recipient;
|
||||
}
|
||||
|
||||
public Context context(@NonNull final String key) {
|
||||
public @Nullable Context context(final @NonNull String key) {
|
||||
return this.channel.context(key);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class UserEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final PlayerUser user;
|
||||
private final @NonNull PlayerUser user;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public UserEvent(@NonNull final PlayerUser user) {
|
||||
public UserEvent(final @NonNull PlayerUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ public class UserEvent implements CarbonEvent, Cancellable {
|
||||
}
|
||||
|
||||
public static class Join extends UserEvent {
|
||||
public Join(@NonNull final PlayerUser user) {
|
||||
public Join(final @NonNull PlayerUser user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Leave extends UserEvent {
|
||||
public Leave(@NonNull final PlayerUser user) {
|
||||
public Leave(final @NonNull PlayerUser user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ public final class CarbonEvents {
|
||||
|
||||
private static final SimpleEventBus<CarbonEvent> EVENT_BUS = new SimpleEventBus<>(CarbonEvent.class);
|
||||
|
||||
public static <T extends CarbonEvent> void register(@NonNull final Class<T> clazz, @NonNull final EventSubscriber<T> subscriber) {
|
||||
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(@NonNull final Class<T> clazz, final int priority, final boolean consumeCancelled, @NonNull final Consumer<T> consumer) {
|
||||
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() {
|
||||
@@ -31,17 +31,17 @@ public final class CarbonEvents {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NonNull final T event) {
|
||||
public void invoke(final @NonNull T event) {
|
||||
consumer.accept(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void unregister(@NonNull final EventSubscriber<? super CarbonEvent> subscriber) {
|
||||
public static void unregister(final @NonNull EventSubscriber<? super CarbonEvent> subscriber) {
|
||||
EVENT_BUS.unregister(subscriber);
|
||||
}
|
||||
|
||||
public static PostResult post(@NonNull final CarbonEvent event) {
|
||||
public static PostResult post(final @NonNull CarbonEvent event) {
|
||||
return EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface MessageService {
|
||||
|
||||
void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener);
|
||||
void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener);
|
||||
|
||||
void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener);
|
||||
void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener);
|
||||
|
||||
void unregisterMessageListener(@NonNull final String key);
|
||||
void unregisterMessageListener(final @NonNull String key);
|
||||
|
||||
void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer);
|
||||
void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer);
|
||||
|
||||
}
|
||||
@@ -15,18 +15,20 @@ public interface PlayerUser extends CarbonUser {
|
||||
|
||||
boolean online();
|
||||
|
||||
@Nullable String nickname();
|
||||
@NonNull String nickname();
|
||||
|
||||
default void nickname(@Nullable final String nickname) {
|
||||
default void nickname(final @Nullable String nickname) {
|
||||
this.nickname(nickname, false);
|
||||
}
|
||||
|
||||
void nickname(@Nullable String nickname, boolean fromRemote);
|
||||
|
||||
@Nullable String displayName();
|
||||
@NonNull String displayName();
|
||||
|
||||
void displayName(@Nullable String displayName);
|
||||
|
||||
@NonNull String name();
|
||||
|
||||
@NonNull String parsePlaceholders(@NonNull String input);
|
||||
|
||||
@NonNull UserChannelSettings channelSettings(@NonNull ChatChannel channel);
|
||||
@@ -59,37 +61,45 @@ public interface PlayerUser extends CarbonUser {
|
||||
|
||||
@Nullable UUID replyTarget();
|
||||
|
||||
default void replyTarget(@Nullable final UUID target) {
|
||||
default void replyTarget(final @Nullable UUID target) {
|
||||
this.replyTarget(target, false);
|
||||
}
|
||||
|
||||
default void replyTarget(@Nullable final PlayerUser user) {
|
||||
this.replyTarget(user.uuid(), false);
|
||||
default void replyTarget(final @Nullable PlayerUser user) {
|
||||
if (user == null) {
|
||||
this.replyTarget((UUID) null, false);
|
||||
} else {
|
||||
this.replyTarget(user.uuid(), false);
|
||||
}
|
||||
}
|
||||
|
||||
void replyTarget(@Nullable UUID target, boolean fromRemote);
|
||||
|
||||
default void replyTarget(@Nullable final PlayerUser user, final boolean fromRemote) {
|
||||
this.replyTarget(user.uuid(), fromRemote);
|
||||
default void replyTarget(final @Nullable PlayerUser user, final boolean fromRemote) {
|
||||
if (user == null) {
|
||||
this.replyTarget((UUID) null, fromRemote);
|
||||
} else {
|
||||
this.replyTarget(user.uuid(), fromRemote);
|
||||
}
|
||||
}
|
||||
|
||||
boolean ignoringUser(@NonNull UUID uuid);
|
||||
|
||||
void ignoringUser(@NonNull UUID uuid, boolean ignoring, boolean fromRemote);
|
||||
|
||||
default void ignoringUser(@NonNull final UUID uuid, final boolean ignoring) {
|
||||
default void ignoringUser(final @NonNull UUID uuid, final boolean ignoring) {
|
||||
this.ignoringUser(uuid, ignoring, false);
|
||||
}
|
||||
|
||||
default boolean ignoringUser(@NonNull final PlayerUser user) {
|
||||
default boolean ignoringUser(final @NonNull PlayerUser user) {
|
||||
return this.ignoringUser(user.uuid());
|
||||
}
|
||||
|
||||
default void ignoringUser(@NonNull final PlayerUser user, final boolean ignoring, final boolean fromRemote) {
|
||||
default void ignoringUser(final @NonNull PlayerUser user, final boolean ignoring, final boolean fromRemote) {
|
||||
this.ignoringUser(user.uuid(), ignoring, fromRemote);
|
||||
}
|
||||
|
||||
default void ignoringUser(@NonNull final PlayerUser user, final boolean ignoring) {
|
||||
default void ignoringUser(final @NonNull PlayerUser user, final boolean ignoring) {
|
||||
this.ignoringUser(user.uuid(), ignoring, false);
|
||||
}
|
||||
|
||||
@@ -97,19 +107,19 @@ public interface PlayerUser extends CarbonUser {
|
||||
|
||||
@NonNull Iterable<UUID> ignoredUsers();
|
||||
|
||||
boolean hasGroup(@NonNull final String group);
|
||||
boolean hasGroup(final @NonNull String group);
|
||||
|
||||
boolean hasGroup(@NonNull final Group group);
|
||||
boolean hasGroup(final @NonNull Group group);
|
||||
|
||||
@NonNull Collection<@NonNull Group> groups();
|
||||
|
||||
@Nullable Group primaryGroup();
|
||||
|
||||
void sendMessage(@NonNull final PlayerUser sender, @NonNull String message);
|
||||
void sendMessage(final @NonNull PlayerUser sender, @NonNull String message);
|
||||
|
||||
@Nullable ChatChannel selectedChannel();
|
||||
|
||||
default void selectedChannel(@NonNull final ChatChannel channel) {
|
||||
default void selectedChannel(final @NonNull ChatChannel channel) {
|
||||
this.selectedChannel(channel, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface UserChannelSettings {
|
||||
@Nullable
|
||||
TextColor color();
|
||||
|
||||
default void color(@Nullable final TextColor color) {
|
||||
default void color(final @Nullable TextColor color) {
|
||||
this.color(color, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface UserService<T extends PlayerUser> {
|
||||
@Nullable
|
||||
UUID resolve(String name);
|
||||
|
||||
@Nullable
|
||||
@NonNull
|
||||
T wrap(UUID uuid);
|
||||
|
||||
@Nullable // Maybe NonNull?
|
||||
|
||||
@@ -65,8 +65,6 @@ checkstyle {
|
||||
configProperties = [basedir: configRoot.getAbsolutePath()]
|
||||
}
|
||||
|
||||
sourceCompatibility = '1.8'
|
||||
|
||||
// Set output directory and encoding
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
|
||||
@@ -84,6 +84,7 @@ import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@SuppressWarnings("initialization.fields.uninitialized")
|
||||
public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
private static final int BSTATS_PLUGIN_ID = 8720;
|
||||
@@ -215,6 +216,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
new WhisperPingHandler();
|
||||
}
|
||||
|
||||
@SuppressWarnings("return.type.incompatible")
|
||||
private void setupCommands() {
|
||||
try {
|
||||
this.commandManager = new PaperCommandManager<>(this,
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class DistanceContext {
|
||||
|
||||
private @NonNull static final String KEY = "distance";
|
||||
private final static @NonNull String KEY = "distance";
|
||||
|
||||
public DistanceContext() {
|
||||
CarbonEvents.register(ReceiverContextEvent.class, PostOrders.NORMAL, false, event -> {
|
||||
|
||||
+13
-4
@@ -9,16 +9,25 @@ import net.kyori.adventure.identity.Identity;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class EconomyContext {
|
||||
private @NonNull final CarbonChatBukkit carbonChat;
|
||||
private final @NonNull CarbonChatBukkit carbonChat;
|
||||
|
||||
private @NonNull final Economy economy;
|
||||
private final @NonNull Economy economy;
|
||||
|
||||
public EconomyContext(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
public EconomyContext(final @NonNull CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.economy = this.carbonChat.getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||
|
||||
final RegisteredServiceProvider<Economy> provider =
|
||||
this.carbonChat.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
|
||||
if (provider == null) {
|
||||
throw new IllegalArgumentException("Economy provider not found!");
|
||||
}
|
||||
|
||||
this.economy = provider.getProvider();
|
||||
|
||||
CarbonEvents.register(PreChatFormatEvent.class, event -> {
|
||||
if (!(event.channel() instanceof TextChannel)) {
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class PAPIContext {
|
||||
|
||||
private @NonNull static final String KEY = "placeholder";
|
||||
private @NonNull static final String SENDER = "-sender";
|
||||
private @NonNull static final String RECEIVER = "-receiver";
|
||||
private final static @NonNull String KEY = "placeholder";
|
||||
private final static @NonNull String SENDER = "-sender";
|
||||
private final static @NonNull String RECEIVER = "-receiver";
|
||||
|
||||
public PAPIContext() {
|
||||
CarbonEvents.register(ReceiverContextEvent.class, PostOrders.NORMAL, false, event -> {
|
||||
|
||||
+9
-10
@@ -22,11 +22,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class TownyContext implements Listener {
|
||||
|
||||
private @NonNull static final String KEY = "towny-town";
|
||||
private final static @NonNull String KEY = "towny-town";
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public TownyContext(@NonNull final CarbonChat carbonChat) {
|
||||
public TownyContext(final @NonNull CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
CarbonEvents.register(ReceiverContextEvent.class, event -> {
|
||||
@@ -69,8 +69,7 @@ public final class TownyContext implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onResidentRemove(final TownRemoveResidentEvent event) {
|
||||
final String name = event.getResident().getName();
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(Bukkit.getPlayer(name).getUniqueId());
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(event.getResident().getUUID());
|
||||
final ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (!(channel instanceof TextChannel)) {
|
||||
@@ -102,9 +101,9 @@ public final class TownyContext implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInTown(@NonNull final PlayerUser user) {
|
||||
public boolean isInTown(final @NonNull PlayerUser user) {
|
||||
try {
|
||||
return TownyAPI.getInstance().getDataSource().getResident(Bukkit.getPlayer(user.uuid()).getName()).hasTown();
|
||||
return TownyAPI.getInstance().getDataSource().getResident(user.name()).hasTown();
|
||||
} catch (final NotRegisteredException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
@@ -112,16 +111,16 @@ public final class TownyContext implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInSameTown(@NonNull final PlayerUser user1, @NonNull final PlayerUser user2) {
|
||||
public boolean isInSameTown(final @NonNull PlayerUser user1, final @NonNull PlayerUser user2) {
|
||||
if (Bukkit.getPlayer(user1.uuid()) == null || Bukkit.getPlayer(user2.uuid()) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
final Resident resident = TownyAPI.getInstance().getDataSource().getResident(Bukkit.getPlayer(user1.uuid()).getName());
|
||||
final Resident resident = TownyAPI.getInstance().getDataSource().getResident(user1.name());
|
||||
|
||||
if (resident.hasTown()) {
|
||||
return resident.getTown().hasResident(Bukkit.getPlayer(user2.uuid()).getName());
|
||||
return resident.getTown().hasResident(user2.name());
|
||||
}
|
||||
} catch (final NotRegisteredException exception) {
|
||||
exception.printStackTrace();
|
||||
|
||||
+25
-8
@@ -5,6 +5,7 @@ import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
@@ -18,7 +19,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class WorldGuardContext {
|
||||
|
||||
private @NonNull static final String KEY = "worldguard-region";
|
||||
private final static @NonNull String KEY = "worldguard-region";
|
||||
|
||||
public WorldGuardContext() {
|
||||
CarbonEvents.register(ReceiverContextEvent.class, event -> {
|
||||
@@ -29,7 +30,13 @@ public final class WorldGuardContext {
|
||||
return;
|
||||
}
|
||||
|
||||
event.cancelled(this.testContext(senderPlayer, recipientPlayer, event.context(KEY)));
|
||||
final Context context = event.context(KEY);
|
||||
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.cancelled(this.testContext(senderPlayer, recipientPlayer, context));
|
||||
});
|
||||
|
||||
CarbonEvents.register(MessageContextEvent.class, event -> {
|
||||
@@ -46,7 +53,7 @@ public final class WorldGuardContext {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isInRegionOrRegions(@NonNull final Context context, @NonNull final Player player) {
|
||||
private boolean isInRegionOrRegions(final @NonNull Context context, final @NonNull Player player) {
|
||||
if (context.isString()) {
|
||||
return this.isInRegion(context.asString(), player);
|
||||
}
|
||||
@@ -62,7 +69,7 @@ public final class WorldGuardContext {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean testContext(@NonNull final Player sender, @NonNull final Player target, @NonNull final Context context) {
|
||||
public boolean testContext(final @NonNull Player sender, final @NonNull Player target, final @NonNull Context context) {
|
||||
boolean user1InRegion = false;
|
||||
boolean user2InRegion = false;
|
||||
|
||||
@@ -88,7 +95,7 @@ public final class WorldGuardContext {
|
||||
return user1InRegion && user2InRegion;
|
||||
}
|
||||
|
||||
public boolean isInSameRegion(@NonNull final Player user1, @NonNull final Player user2) {
|
||||
public boolean isInSameRegion(final @NonNull Player user1, final @NonNull Player user2) {
|
||||
final Location user1Location = BukkitAdapter.adapt(user1.getLocation());
|
||||
final Location user2Location = BukkitAdapter.adapt(user2.getLocation());
|
||||
|
||||
@@ -107,15 +114,25 @@ public final class WorldGuardContext {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInRegion(@NonNull final String region, @NonNull final Player player) {
|
||||
public boolean isInRegion(final @NonNull String region, final @NonNull Player player) {
|
||||
final RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
final World world = BukkitAdapter.adapt(player.getWorld());
|
||||
final ProtectedRegion protection = container.get(world).getRegion(region);
|
||||
final RegionManager regionManager = container.get(world);
|
||||
|
||||
if (regionManager == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final ProtectedRegion protection = regionManager.getRegion(region);
|
||||
|
||||
if (protection == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.isInRegion(protection, player);
|
||||
}
|
||||
|
||||
public boolean isInRegion(@NonNull final ProtectedRegion region, @NonNull final Player player) {
|
||||
public boolean isInRegion(final @NonNull ProtectedRegion region, final @NonNull Player player) {
|
||||
final org.bukkit.Location location = player.getLocation();
|
||||
|
||||
return region.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
|
||||
+18
-9
@@ -21,11 +21,11 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public final class mcMMOContext implements Listener {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull static final String KEY = "mcmmo-party";
|
||||
private final static @NonNull String KEY = "mcmmo-party";
|
||||
|
||||
public mcMMOContext(@NonNull final CarbonChat carbonChat) {
|
||||
public mcMMOContext(final @NonNull CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
CarbonEvents.register(ReceiverContextEvent.class, PostOrders.NORMAL, false, event -> {
|
||||
@@ -97,16 +97,25 @@ public final class mcMMOContext implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInParty(@NonNull final PlayerUser user) {
|
||||
return PartyAPI.inParty(Bukkit.getPlayer(user.uuid()));
|
||||
}
|
||||
public boolean isInParty(final @NonNull PlayerUser user) {
|
||||
final Player player = Bukkit.getPlayer(user.uuid());
|
||||
|
||||
public boolean isInSameParty(@NonNull final PlayerUser user1, @NonNull final PlayerUser user2) {
|
||||
if (Bukkit.getPlayer(user1.uuid()) == null || Bukkit.getPlayer(user2.uuid()) == null) {
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PartyAPI.inSameParty(Bukkit.getPlayer(user1.uuid()), Bukkit.getPlayer(user2.uuid()));
|
||||
return PartyAPI.inParty(player);
|
||||
}
|
||||
|
||||
public boolean isInSameParty(final @NonNull PlayerUser user1, final @NonNull PlayerUser user2) {
|
||||
final Player player1 = Bukkit.getPlayer(user1.uuid());
|
||||
final Player player2 = Bukkit.getPlayer(user2.uuid());
|
||||
|
||||
if (player1 == null || player2 == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PartyAPI.inSameParty(player1, player2);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-10
@@ -23,23 +23,19 @@ import java.util.Map;
|
||||
|
||||
public class BukkitChatListener implements Listener {
|
||||
|
||||
private @NonNull final CarbonChatBukkit carbonChat;
|
||||
private final @NonNull CarbonChatBukkit carbonChat;
|
||||
|
||||
public BukkitChatListener(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
public BukkitChatListener(final @NonNull CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
// Chat messages
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerchat(@NonNull final AsyncPlayerChatEvent event) {
|
||||
public void onPlayerChat(final @NonNull AsyncPlayerChatEvent event) {
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (channel == null) {
|
||||
if (this.carbonChat.channelRegistry().defaultValue() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
channel = this.carbonChat.channelRegistry().defaultValue();
|
||||
}
|
||||
|
||||
@@ -53,14 +49,15 @@ public class BukkitChatListener implements Listener {
|
||||
}
|
||||
|
||||
final TextChannel textChannel = (TextChannel) entry;
|
||||
final String prefix = textChannel.messagePrefix();
|
||||
|
||||
if (textChannel.messagePrefix() == null || textChannel.messagePrefix().isEmpty()) {
|
||||
if (prefix == null || prefix.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event.getMessage().startsWith(textChannel.messagePrefix())) {
|
||||
if (event.getMessage().startsWith(prefix)) {
|
||||
if (entry.canPlayerUse(user)) {
|
||||
event.setMessage(event.getMessage().substring(textChannel.messagePrefix().length()));
|
||||
event.setMessage(event.getMessage().substring(prefix.length()));
|
||||
channel = entry;
|
||||
break;
|
||||
}
|
||||
|
||||
+5
-2
@@ -3,6 +3,7 @@ package net.draycia.carbon.bukkit.listeners.events;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.PostOrders;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,12 +12,14 @@ public class RelationalPlaceholderHandler {
|
||||
|
||||
public RelationalPlaceholderHandler() {
|
||||
CarbonEvents.register(ChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
if (event.target() == null) {
|
||||
final PlayerUser targetUser = event.target();
|
||||
|
||||
if (targetUser == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player sender = Bukkit.getPlayer(event.sender().uuid());
|
||||
final Player target = Bukkit.getPlayer(event.target().uuid());
|
||||
final Player target = Bukkit.getPlayer(targetUser.uuid());
|
||||
|
||||
if (sender == null || target == null) {
|
||||
return;
|
||||
|
||||
+12
-11
@@ -18,17 +18,18 @@ import java.util.function.Consumer;
|
||||
|
||||
public class BungeeMessageService implements MessageService {
|
||||
|
||||
private @NonNull final CarbonChatBukkit carbonChat;
|
||||
private final @NonNull CarbonChatBukkit carbonChat;
|
||||
|
||||
private @NonNull final BungeeChannelApi api;
|
||||
private final @NonNull BungeeChannelApi api;
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
private final @NonNull Map<@NonNull String, @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
private final @NonNull Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
|
||||
private @NonNull final UUID serverUUID = UUID.randomUUID();
|
||||
private final @NonNull UUID serverUUID = UUID.randomUUID();
|
||||
|
||||
public BungeeMessageService(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
@SuppressWarnings("method.invocation.invalid")
|
||||
public BungeeMessageService(final @NonNull CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
this.carbonChat.getServer().getMessenger().registerOutgoingPluginChannel(carbonChat, "BungeeCord");
|
||||
@@ -60,7 +61,7 @@ public class BungeeMessageService implements MessageService {
|
||||
});
|
||||
}
|
||||
|
||||
private void receiveMessage(@NonNull final UUID uuid, @NonNull final String key, @NonNull final ByteArrayDataInput value) {
|
||||
private void receiveMessage(final @NonNull UUID uuid, final @NonNull String key, final @NonNull ByteArrayDataInput value) {
|
||||
final PlayerUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
|
||||
if (user != null) {
|
||||
@@ -79,23 +80,23 @@ public class BungeeMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userLoadedListeners.put(key, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userNotLoadedListeners.put(key, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
public void unregisterMessageListener(final @NonNull String key) {
|
||||
this.userLoadedListeners.remove(key);
|
||||
this.userNotLoadedListeners.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<ByteArrayDataOutput> consumer) {
|
||||
final ByteArrayDataOutput msg = ByteStreams.newDataOutput();
|
||||
|
||||
msg.writeLong(this.serverUUID.getMostSignificantBits());
|
||||
|
||||
+7
-3
@@ -12,11 +12,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class BukkitConsoleUser implements ConsoleUser, ForwardingAudience.Single {
|
||||
|
||||
private @NonNull final Audience audience;
|
||||
private final @NonNull Audience audience;
|
||||
|
||||
public BukkitConsoleUser(@NonNull final ConsoleCommandSender sender) {
|
||||
public BukkitConsoleUser(final @NonNull ConsoleCommandSender sender) {
|
||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("CarbonChat plugin cannot be found!");
|
||||
}
|
||||
|
||||
this.audience = BukkitAudiences.create(plugin).sender(sender);
|
||||
}
|
||||
|
||||
@@ -35,7 +39,7 @@ public class BukkitConsoleUser implements ConsoleUser, ForwardingAudience.Single
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NonNull final String permission) {
|
||||
public boolean hasPermission(final @NonNull String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+90
-59
@@ -24,24 +24,23 @@ import net.luckperms.api.query.QueryOptions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
|
||||
private @NonNull final transient CarbonChatBukkit carbonChat;
|
||||
private @NonNull final Map<@NonNull String, @NonNull SimpleUserChannelSettings> channelSettings = new HashMap<>();
|
||||
private @NonNull final List<@NonNull UUID> ignoredUsers = new ArrayList<>();
|
||||
private @MonotonicNonNull UUID uuid;
|
||||
private final @NonNull transient CarbonChatBukkit carbonChat;
|
||||
private final @NonNull Map<@NonNull String, @NonNull SimpleUserChannelSettings> channelSettings = new HashMap<>();
|
||||
private final @NonNull List<@NonNull UUID> ignoredUsers = new ArrayList<>();
|
||||
private @NonNull UUID uuid;
|
||||
private boolean muted = false;
|
||||
private boolean shadowMuted = false;
|
||||
private boolean spyingWhispers = false;
|
||||
@@ -51,11 +50,19 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
private @Nullable String selectedChannelKey = null;
|
||||
private transient @Nullable ChatChannel selectedChannel = null;
|
||||
|
||||
@SuppressWarnings("initialization.fields.uninitialized")
|
||||
public BukkitPlayerUser() {
|
||||
this.carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
final CarbonChatBukkit carbonChatBukkit =
|
||||
(CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
|
||||
if (carbonChatBukkit == null) {
|
||||
throw new IllegalArgumentException("CarbonChat plugin not present.");
|
||||
}
|
||||
|
||||
this.carbonChat = carbonChatBukkit;
|
||||
}
|
||||
|
||||
public BukkitPlayerUser(@NonNull final UUID uuid) {
|
||||
public BukkitPlayerUser(final @NonNull UUID uuid) {
|
||||
this();
|
||||
this.uuid = uuid;
|
||||
}
|
||||
@@ -71,7 +78,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String parsePlaceholders(@NonNull final String input) {
|
||||
public @NonNull String parsePlaceholders(final @NonNull String input) {
|
||||
final Player player = Bukkit.getPlayer(this.uuid());
|
||||
|
||||
if (player == null) {
|
||||
@@ -92,14 +99,23 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String nickname() {
|
||||
return this.nickname;
|
||||
public @NonNull String nickname() {
|
||||
if (this.nickname != null) {
|
||||
return this.nickname();
|
||||
}
|
||||
|
||||
return this.displayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NonNull final String permission) {
|
||||
return LuckPermsProvider.get().getUserManager().getUser(this.uuid())
|
||||
.getCachedData().getPermissionData().checkPermission(permission).asBoolean();
|
||||
public boolean hasPermission(final @NonNull String permission) {
|
||||
final User user = LuckPermsProvider.get().getUserManager().getUser(this.uuid());
|
||||
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return user.getCachedData().getPermissionData().checkPermission(permission).asBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +132,9 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
|
||||
final Player onlinePlayer = player.getPlayer();
|
||||
|
||||
onlinePlayer.setDisplayName(newNickname);
|
||||
if (onlinePlayer != null) {
|
||||
onlinePlayer.setDisplayName(newNickname);
|
||||
}
|
||||
|
||||
// if (this.carbonChat.getConfig().getBoolean("nicknames-set-tab-name")) {
|
||||
// onlinePlayer.setPlayerListName(newNickname);
|
||||
@@ -124,19 +142,21 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
if (!fromRemote) {
|
||||
if (this.nickname == null) {
|
||||
final String nick = this.nickname;
|
||||
|
||||
if (nick == null) {
|
||||
this.carbonChat.messageManager().sendMessage("nickname-reset", this.uuid(), byteArray -> {
|
||||
});
|
||||
} else {
|
||||
this.carbonChat.messageManager().sendMessage("nickname", this.uuid(), byteArray -> {
|
||||
byteArray.writeUTF(this.nickname);
|
||||
byteArray.writeUTF(nick);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String displayName() {
|
||||
public @NonNull String displayName() {
|
||||
final Player player = Bukkit.getPlayer(this.uuid());
|
||||
|
||||
if (player != null) {
|
||||
@@ -146,7 +166,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
public void displayName(@Nullable final String displayName) {
|
||||
public void displayName(final @Nullable String displayName) {
|
||||
final Player player = Bukkit.getPlayer(this.uuid());
|
||||
|
||||
if (player != null) {
|
||||
@@ -155,10 +175,18 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
public @NonNull String name() {
|
||||
return Objects.requireNonNull(Bukkit.getOfflinePlayer(this.uuid()).getName());
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(this.uuid());
|
||||
final String name = player.getName();
|
||||
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
return this.uuid.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("argument.type.incompatible")
|
||||
public @Nullable ChatChannel selectedChannel() {
|
||||
if (this.selectedChannel != null) {
|
||||
return this.selectedChannel;
|
||||
@@ -179,7 +207,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectedChannel(@NonNull final ChatChannel chatChannel, final boolean fromRemote) {
|
||||
public void selectedChannel(final @NonNull ChatChannel chatChannel, final boolean fromRemote) {
|
||||
final String failureMessage = chatChannel.switchFailureMessage();
|
||||
|
||||
final ChannelSwitchEvent event = new ChannelSwitchEvent(chatChannel, this, failureMessage);
|
||||
@@ -217,12 +245,12 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoringUser(@NonNull final UUID uuid) {
|
||||
public boolean ignoringUser(final @NonNull UUID uuid) {
|
||||
return this.ignoredUsers.contains(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoringUser(@NonNull final UUID uuid, final boolean ignoring, final boolean fromRemote) {
|
||||
public void ignoringUser(final @NonNull UUID uuid, final boolean ignoring, final boolean fromRemote) {
|
||||
if (ignoring) {
|
||||
this.ignoredUsers.add(uuid);
|
||||
} else {
|
||||
@@ -246,12 +274,18 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
private transient final LuckPerms luckPerms = LuckPermsProvider.get();
|
||||
|
||||
@Override
|
||||
public boolean hasGroup(@NonNull final String groupName) {
|
||||
return this.hasGroup(this.luckPerms.getGroupManager().getGroup(groupName));
|
||||
public boolean hasGroup(final @NonNull String groupName) {
|
||||
final Group group = this.luckPerms.getGroupManager().getGroup(groupName);
|
||||
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.hasGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroup(@NonNull final Group group) {
|
||||
public boolean hasGroup(final @NonNull Group group) {
|
||||
return this.groups().contains(group);
|
||||
}
|
||||
|
||||
@@ -259,13 +293,21 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
public @NonNull Collection<@NonNull Group> groups() {
|
||||
final User user = this.luckPerms.getUserManager().getUser(this.uuid());
|
||||
|
||||
return user.getInheritedGroups(QueryOptions.nonContextual());
|
||||
if (user != null) {
|
||||
return user.getInheritedGroups(QueryOptions.nonContextual());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Group primaryGroup() {
|
||||
final User user = this.luckPerms.getUserManager().getUser(this.uuid());
|
||||
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.luckPerms.getGroupManager().getGroup(user.getPrimaryGroup());
|
||||
}
|
||||
|
||||
@@ -318,19 +360,24 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replyTarget(@Nullable final UUID target, final boolean fromRemote) {
|
||||
public void replyTarget(final @Nullable UUID target, final boolean fromRemote) {
|
||||
this.replyTarget = target;
|
||||
|
||||
if (!fromRemote) {
|
||||
this.carbonChat.messageManager().sendMessage("reply-target", this.uuid(), byteArray -> {
|
||||
byteArray.writeLong(target.getMostSignificantBits());
|
||||
byteArray.writeLong(target.getLeastSignificantBits());
|
||||
});
|
||||
if (target != null) {
|
||||
this.carbonChat.messageManager().sendMessage("reply-target", this.uuid(), byteArray -> {
|
||||
byteArray.writeLong(target.getMostSignificantBits());
|
||||
byteArray.writeLong(target.getLeastSignificantBits());
|
||||
});
|
||||
} else {
|
||||
this.carbonChat.messageManager().sendMessage("reply-target-reset", this.uuid(), byteArray -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull UserChannelSettings channelSettings(@NonNull final ChatChannel channel) {
|
||||
public @NonNull UserChannelSettings channelSettings(final @NonNull ChatChannel channel) {
|
||||
return this.channelSettings.computeIfAbsent(channel.key(), name -> {
|
||||
return new SimpleUserChannelSettings(this.uuid, channel.key());
|
||||
});
|
||||
@@ -357,7 +404,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final PlayerUser sender, @NonNull final String message) {
|
||||
public void sendMessage(final @NonNull PlayerUser sender, final @NonNull String message) {
|
||||
if (this.ignoringUser(sender) || sender.ignoringUser(this)) {
|
||||
return;
|
||||
}
|
||||
@@ -366,28 +413,16 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
final String fromPlayerFormat = this.carbonChat.carbonSettings().whisperOptions().receiverFormat();
|
||||
|
||||
final OfflinePlayer offlineSender = Bukkit.getOfflinePlayer(sender.uuid());
|
||||
String senderName = offlineSender.getName();
|
||||
final String senderOfflineName = senderName;
|
||||
|
||||
if (offlineSender.isOnline()) {
|
||||
senderName = offlineSender.getPlayer().getDisplayName();
|
||||
}
|
||||
final String senderName = sender.nickname();
|
||||
|
||||
final OfflinePlayer offlineTarget = Bukkit.getOfflinePlayer(this.uuid());
|
||||
String targetName = offlineTarget.getName();
|
||||
final String targetOfflineName = targetName;
|
||||
|
||||
if (offlineTarget.isOnline()) {
|
||||
targetName = offlineTarget.getPlayer().getDisplayName();
|
||||
}
|
||||
final String targetName = this.nickname();
|
||||
|
||||
final Component toPlayerComponent = this.carbonChat.messageProcessor().processMessage(toPlayerFormat,
|
||||
"message", message, "targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetName, "sender", senderName);
|
||||
"message", message, "target", targetName, "sender", senderName);
|
||||
|
||||
final Component fromPlayerComponent = this.carbonChat.messageProcessor().processMessage(fromPlayerFormat,
|
||||
"message", message, "targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetName, "sender", senderName);
|
||||
"message", message, "target", targetName, "sender", senderName);
|
||||
|
||||
final PrivateMessageEvent event = new PrivateMessageEvent(sender, this, toPlayerComponent, fromPlayerComponent, message);
|
||||
|
||||
@@ -418,9 +453,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
final String playerOfflineFormat = this.carbonChat.translations().otherPlayerOffline();
|
||||
|
||||
final Component playerOfflineComponent = this.carbonChat.messageProcessor().processMessage(playerOfflineFormat,
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetNameFinal, "sender", senderNameFinal);
|
||||
"message", message, "target", targetNameFinal, "sender", senderNameFinal);
|
||||
|
||||
sender.sendMessage(Identity.nil(), playerOfflineComponent);
|
||||
|
||||
@@ -429,14 +462,13 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
|
||||
BungeeChannelApi.of(this.carbonChat).getPlayerList("ALL").thenAccept(list -> {
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(this.uuid());
|
||||
final String name = player.getName();
|
||||
|
||||
if (!list.contains(player.getName())) {
|
||||
if (name == null || !list.contains(name)) {
|
||||
final String playerOfflineFormat = this.carbonChat.translations().otherPlayerOffline();
|
||||
|
||||
final Component playerOfflineComponent = this.carbonChat.messageProcessor().processMessage(playerOfflineFormat,
|
||||
"message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||
"target", targetNameFinal, "sender", senderNameFinal);
|
||||
"message", message, "target", targetNameFinal, "sender", senderNameFinal);
|
||||
|
||||
sender.sendMessage(Identity.nil(), playerOfflineComponent);
|
||||
|
||||
@@ -466,8 +498,7 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
|
||||
user.sendMessage(sender.identity(), this.carbonChat.messageProcessor()
|
||||
.processMessage(this.carbonChat.translations().spyWhispers(), "message", message,
|
||||
"targetname", targetOfflineName, "sendername", senderOfflineName, "target", targetName,
|
||||
"sender", senderName));
|
||||
"target", targetName, "sender", senderName));
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-12
@@ -5,7 +5,6 @@ import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@@ -13,16 +12,15 @@ import java.util.UUID;
|
||||
|
||||
public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
|
||||
private @NonNull final transient CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
private final transient @NonNull CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
private boolean spying;
|
||||
private boolean ignored;
|
||||
private @NonNull String color;
|
||||
@MonotonicNonNull // @NonNull but not initialised in all constructors.
|
||||
private UUID uuid;
|
||||
@MonotonicNonNull // @NonNull but not initialised in all constructors.
|
||||
private String channel;
|
||||
private @Nullable String color;
|
||||
private @NonNull UUID uuid;
|
||||
private @NonNull String channel;
|
||||
|
||||
public SimpleUserChannelSettings(@NonNull final UUID uuid, @NonNull final String channel) {
|
||||
@SuppressWarnings("initialization.fields.uninitialized")
|
||||
public SimpleUserChannelSettings(final @NonNull UUID uuid, final @NonNull String channel) {
|
||||
this.uuid = uuid;
|
||||
this.channel = channel;
|
||||
}
|
||||
@@ -75,7 +73,7 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void color(@Nullable final TextColor color, final boolean fromRemote) {
|
||||
public void color(final @Nullable TextColor color, final boolean fromRemote) {
|
||||
if (color == null) {
|
||||
this.color = null;
|
||||
} else {
|
||||
@@ -83,9 +81,16 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
}
|
||||
|
||||
if (!fromRemote) {
|
||||
this.carbonChat.messageService().sendMessage("channel-color", this.uuid, byteArray -> {
|
||||
byteArray.writeUTF(color.asHexString());
|
||||
});
|
||||
final String newColor = this.color;
|
||||
|
||||
if (newColor == null || newColor.isEmpty()) {
|
||||
this.carbonChat.messageService().sendMessage("channel-color-reset", this.uuid, byteArray -> {
|
||||
});
|
||||
} else {
|
||||
this.carbonChat.messageService().sendMessage("channel-color", this.uuid, byteArray -> {
|
||||
byteArray.writeUTF(newColor);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -6,13 +6,12 @@ import net.draycia.carbon.bukkit.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
private @NonNull final CarbonChatBukkit carbonChat;
|
||||
private final @NonNull CarbonChatBukkit carbonChat;
|
||||
|
||||
public CarbonPlaceholders(@NonNull final CarbonChatBukkit carbonChat) {
|
||||
public CarbonPlaceholders(final @NonNull CarbonChatBukkit carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
@@ -37,7 +36,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onPlaceholderRequest(@NonNull final Player player, @NonNull final String identifier) {
|
||||
public @NonNull String onPlaceholderRequest(final @NonNull Player player, final @NonNull String identifier) {
|
||||
final String key = identifier.toLowerCase();
|
||||
|
||||
if (key.startsWith("can_use_")) {
|
||||
@@ -82,7 +81,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
return channel == null ? this.carbonChat.channelRegistry().defaultValue().name() : channel.name();
|
||||
}
|
||||
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
|
||||
public final class CarbonUtils {
|
||||
|
||||
private static @NonNull final String @NonNull [] colors;
|
||||
private static final @NonNull String @NonNull [] colors;
|
||||
|
||||
private CarbonUtils() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class CarbonUtils {
|
||||
colors = colorList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public @NonNull static Component createComponent(@NonNull final Player player) {
|
||||
public static @NonNull Component createComponent(final @NonNull Player player) {
|
||||
if (!FunctionalityConstants.HAS_HOVER_EVENT_METHOD) {
|
||||
return net.kyori.adventure.text.Component.empty();
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored") // This is a common pattern in this class.
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "argument.type.incompatible"})
|
||||
public final class FunctionalityConstants {
|
||||
|
||||
public static final boolean HAS_HOVER_EVENT_METHOD = noThrow(() -> ItemFactory.class.getMethod("hoverContentOf", ItemStack.class));
|
||||
@@ -29,7 +29,7 @@ public final class FunctionalityConstants {
|
||||
|
||||
}
|
||||
|
||||
private static boolean noThrow(@NonNull final ThrowingRunnable runnable) {
|
||||
private static boolean noThrow(final @NonNull ThrowingRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
return true;
|
||||
|
||||
@@ -38,7 +38,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
* <p>
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
@SuppressWarnings({"WeakerAccess", "unused"})
|
||||
@SuppressWarnings("ALL")
|
||||
public class Metrics {
|
||||
|
||||
static {
|
||||
|
||||
+7
-7
@@ -14,20 +14,20 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class AdventureManager implements MessageProcessor {
|
||||
|
||||
private @NonNull final AudienceProvider provider;
|
||||
private final @NonNull AudienceProvider provider;
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final FormatType formatType;
|
||||
private final @NonNull FormatType formatType;
|
||||
|
||||
public AdventureManager(@NonNull final AudienceProvider provider, @NonNull final FormatType formatType) {
|
||||
public AdventureManager(final @NonNull AudienceProvider provider, final @NonNull FormatType formatType) {
|
||||
this.provider = provider;
|
||||
this.formatType = formatType;
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Component processMessage(@Nullable final String input, @NonNull final String @NonNull ... placeholders) {
|
||||
public @NonNull Component processMessage(final @Nullable String input, final @NonNull String @NonNull ... placeholders) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
return Component.empty();
|
||||
}
|
||||
@@ -52,11 +52,11 @@ public class AdventureManager implements MessageProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull Component processMojang(@NonNull final String input) {
|
||||
private @NonNull Component processMojang(final @NonNull String input) {
|
||||
return this.carbonChat.gsonSerializer().deserialize(input);
|
||||
}
|
||||
|
||||
private @NonNull String processPlaceholders(@NonNull String input, @NonNull final String @NonNull ... placeholders) {
|
||||
private @NonNull String processPlaceholders(@NonNull String input, final @NonNull String @NonNull ... placeholders) {
|
||||
for (int i = 0; i < placeholders.length; i += 2) {
|
||||
final String placeholder = placeholders[i];
|
||||
final String replacement = placeholders[i + 1];
|
||||
|
||||
+75
-51
@@ -35,11 +35,11 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class CarbonChatChannel implements TextChannel {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final ChannelOptions options;
|
||||
private final @NonNull ChannelOptions options;
|
||||
|
||||
public CarbonChatChannel(@NonNull final CarbonChat carbonChat, @Nullable final ChannelOptions options) {
|
||||
public CarbonChatChannel(final @NonNull CarbonChat carbonChat, final @NonNull ChannelOptions options) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.options = options;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testContext(@NonNull final PlayerUser sender, @NonNull final PlayerUser target) {
|
||||
public boolean testContext(final @NonNull PlayerUser sender, final @NonNull PlayerUser target) {
|
||||
final ReceiverContextEvent event = new ReceiverContextEvent(this, sender, target);
|
||||
|
||||
CarbonEvents.post(event);
|
||||
@@ -62,7 +62,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(@NonNull final PlayerUser user) {
|
||||
public boolean canPlayerUse(final @NonNull PlayerUser user) {
|
||||
return user.hasPermission("carbonchat.channels." + this.name() + ".use");
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return audience;
|
||||
}
|
||||
|
||||
// private void updateUserNickname(@NonNull final ChatUser user) {
|
||||
// private void updateUserNickname(final @NonNull ChatUser user) {
|
||||
// final Player player = Bukkit.getPlayer(user.uuid());
|
||||
//
|
||||
// if (player != null) {
|
||||
@@ -99,7 +99,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
// }
|
||||
|
||||
@Override
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final PlayerUser user, @NonNull final Collection<@NonNull PlayerUser> recipients, @NonNull final String message, final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user, final @NonNull Collection<@NonNull PlayerUser> recipients, final @NonNull String message, final boolean fromRemote) {
|
||||
//this.updateUserNickname(user);
|
||||
|
||||
final MessageContextEvent event = new MessageContextEvent(this, user);
|
||||
@@ -124,13 +124,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
final String displayName;
|
||||
|
||||
if (user.nickname() != null) {
|
||||
displayName = user.nickname();
|
||||
} else {
|
||||
displayName = user.displayName();
|
||||
}
|
||||
final String displayName = user.nickname();
|
||||
|
||||
final Map<CarbonUser, Component> users = new HashMap<>();
|
||||
|
||||
@@ -166,9 +160,14 @@ public class CarbonChatChannel implements TextChannel {
|
||||
|
||||
CarbonEvents.post(newEvent);
|
||||
|
||||
users.put(newEvent.target(), newEvent.component());
|
||||
final PlayerUser targetUser = newEvent.target();
|
||||
|
||||
if (targetUser != null) {
|
||||
users.put(targetUser, newEvent.component());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: ChatFormatEvent ConsoleUser support for target, specify ConsoleUser as target
|
||||
final ChatFormatEvent consoleFormatEvent = new ChatFormatEvent(user, null, this, preFormatEvent.format(),
|
||||
preFormatEvent.message());
|
||||
|
||||
@@ -188,7 +187,11 @@ public class CarbonChatChannel implements TextChannel {
|
||||
CarbonEvents.post(consoleEvent);
|
||||
|
||||
if (!consoleEvent.cancelled()) {
|
||||
users.put(this.carbonChat.userService().consoleUser(), consoleEvent.component());
|
||||
final ConsoleUser consoleUser = this.carbonChat.userService().consoleUser();
|
||||
|
||||
if (consoleUser != null) {
|
||||
users.put(consoleUser, consoleEvent.component());
|
||||
}
|
||||
}
|
||||
|
||||
if (user.online() && !fromRemote && this.crossServer()) {
|
||||
@@ -199,8 +202,8 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponents(@NonNull final Identity identity,
|
||||
@NonNull final Map<? extends CarbonUser, Component> components) {
|
||||
public void sendComponents(final @NonNull Identity identity,
|
||||
final @NonNull Map<? extends CarbonUser, Component> components) {
|
||||
for (final Map.Entry<? extends CarbonUser, Component> entry : components.entrySet()) {
|
||||
if (entry.getValue().equals(Component.empty())) {
|
||||
continue;
|
||||
@@ -211,8 +214,8 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponentsAndLog(@NonNull final Identity identity,
|
||||
@NonNull final Map<? extends CarbonUser, Component> components) {
|
||||
public void sendComponentsAndLog(final @NonNull Identity identity,
|
||||
final @NonNull Map<? extends CarbonUser, Component> components) {
|
||||
for (final Map.Entry<? extends CarbonUser, Component> entry : components.entrySet()) {
|
||||
if (entry.getValue().equals(Component.empty())) {
|
||||
continue;
|
||||
@@ -228,11 +231,11 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final PlayerUser user, @NonNull final String message, final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user, final @NonNull String message, final boolean fromRemote) {
|
||||
return this.parseMessage(user, this.audiences(), message, fromRemote);
|
||||
}
|
||||
|
||||
public @Nullable String format(@NonNull final PlayerUser user) {
|
||||
public @NonNull String format(final @NonNull PlayerUser user) {
|
||||
for (final String group : this.groupOverrides()) {
|
||||
if (this.userHasGroup(user, group)) {
|
||||
final String format = this.format(group);
|
||||
@@ -250,7 +253,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean userHasGroup(@NonNull final PlayerUser user, @NonNull final String group) {
|
||||
private boolean userHasGroup(final @NonNull PlayerUser user, final @NonNull String group) {
|
||||
if (user.hasGroup(group)) {
|
||||
return true;
|
||||
}
|
||||
@@ -262,7 +265,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return false;
|
||||
}
|
||||
|
||||
private @NonNull String firstFoundUserFormat(@NonNull final PlayerUser user) {
|
||||
private @NonNull String firstFoundUserFormat(final @NonNull PlayerUser user) {
|
||||
for (final Group group : user.groups()) {
|
||||
final String groupFormat = this.format(group);
|
||||
|
||||
@@ -274,8 +277,13 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return this.defaultFormat();
|
||||
}
|
||||
|
||||
private @NonNull String primaryGroupFormat(@NonNull final PlayerUser user) {
|
||||
private @NonNull String primaryGroupFormat(final @NonNull PlayerUser user) {
|
||||
final Group primaryGroup = user.primaryGroup();
|
||||
|
||||
if (primaryGroup == null) {
|
||||
return this.defaultFormat();
|
||||
}
|
||||
|
||||
final String primaryGroupFormat = this.format(primaryGroup);
|
||||
|
||||
if (primaryGroupFormat != null) {
|
||||
@@ -286,20 +294,32 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
private @NonNull String defaultFormat() {
|
||||
return this.format(this.defaultFormatName());
|
||||
final String defaultFormatName = this.defaultFormatName();
|
||||
|
||||
if (defaultFormatName == null) {
|
||||
return "<<displayname>> <message>";
|
||||
}
|
||||
|
||||
final String defaultFormat = this.format(defaultFormatName);
|
||||
|
||||
if (defaultFormat == null) {
|
||||
return "<<displayname>> <message>";
|
||||
}
|
||||
|
||||
return defaultFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String format(@NonNull final Group group) {
|
||||
public @Nullable String format(final @NonNull Group group) {
|
||||
return this.format(group.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String format(@NonNull final String group) {
|
||||
public @Nullable String format(final @NonNull String group) {
|
||||
return this.options().format(group);
|
||||
}
|
||||
|
||||
private boolean isUserSpying(@NonNull final PlayerUser sender, @NonNull final PlayerUser target) {
|
||||
private boolean isUserSpying(final @NonNull PlayerUser sender, final @NonNull PlayerUser target) {
|
||||
if (!this.canPlayerSee(sender, target, false)) {
|
||||
return target.channelSettings(this).spying();
|
||||
}
|
||||
@@ -308,7 +328,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponent(@NonNull final PlayerUser player, @NonNull final Component component) {
|
||||
public void sendComponent(final @NonNull PlayerUser player, final @NonNull Component component) {
|
||||
for (final PlayerUser user : this.audiences()) {
|
||||
if (!user.ignoringUser(player)) {
|
||||
user.sendMessage(player.identity(), component);
|
||||
@@ -316,7 +336,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessageToBungee(@NonNull final UUID uuid, @NonNull final Component component) {
|
||||
public void sendMessageToBungee(final @NonNull UUID uuid, final @NonNull Component component) {
|
||||
this.carbonChat.messageService().sendMessage("channel-component", uuid, byteArray -> {
|
||||
byteArray.writeUTF(this.key());
|
||||
byteArray.writeUTF(this.carbonChat.gsonSerializer().serialize(component));
|
||||
@@ -324,7 +344,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull final PlayerUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(final @NonNull PlayerUser target, final boolean checkSpying) {
|
||||
if (checkSpying && target.hasPermission("carbonchat.spy." + this.name())) {
|
||||
if (target.channelSettings(this).spying()) {
|
||||
return true;
|
||||
@@ -342,7 +362,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlayerSee(@NonNull final PlayerUser sender, @NonNull final PlayerUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(final @NonNull PlayerUser sender, final @NonNull PlayerUser target, final boolean checkSpying) {
|
||||
|
||||
if (!this.canPlayerSee(target, checkSpying)) {
|
||||
return false;
|
||||
@@ -356,7 +376,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable TextColor channelColor(@NonNull final CarbonUser user) {
|
||||
public @NonNull TextColor channelColor(final @NonNull CarbonUser user) {
|
||||
if (user instanceof PlayerUser) {
|
||||
final TextColor userColor = ((PlayerUser) user).channelSettings(this).color();
|
||||
|
||||
@@ -367,18 +387,22 @@ public class CarbonChatChannel implements TextChannel {
|
||||
|
||||
final String input = this.options().color();
|
||||
|
||||
final TextColor color = ColorUtils.parseColor(user, input);
|
||||
if (input != null) {
|
||||
final TextColor color = ColorUtils.parseColor(user, input);
|
||||
|
||||
if (color == null) {
|
||||
if (this.carbonChat.carbonSettings().showTips()) {
|
||||
this.carbonChat.logger().error("Tip: Channel color found (" + input + ") is invalid!");
|
||||
this.carbonChat.logger().error("Falling back to #FFFFFF");
|
||||
if (color == null) {
|
||||
if (this.carbonChat.carbonSettings().showTips()) {
|
||||
this.carbonChat.logger().error("Tip: Channel color found (" + input + ") is invalid!");
|
||||
this.carbonChat.logger().error("Falling back to #FFFFFF");
|
||||
}
|
||||
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
return NamedTextColor.WHITE;
|
||||
return color;
|
||||
}
|
||||
|
||||
return color;
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
public @Nullable String defaultFormatName() {
|
||||
@@ -426,47 +450,47 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String switchMessage() {
|
||||
public @NonNull String switchMessage() {
|
||||
return this.options().switchMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String switchOtherMessage() {
|
||||
public @NonNull String switchOtherMessage() {
|
||||
return this.options().switchOtherMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String switchFailureMessage() {
|
||||
public @NonNull String switchFailureMessage() {
|
||||
return this.options().switchFailureMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String cannotIgnoreMessage() {
|
||||
public @NonNull String cannotIgnoreMessage() {
|
||||
return this.options().cannotIgnoreMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOffMessage() {
|
||||
public @NonNull String toggleOffMessage() {
|
||||
return this.options().toggleOffMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOnMessage() {
|
||||
public @NonNull String toggleOnMessage() {
|
||||
return this.options().toggleOnMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOtherOnMessage() {
|
||||
public @NonNull String toggleOtherOnMessage() {
|
||||
return this.options().toggleOtherOnMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOtherOffMessage() {
|
||||
public @NonNull String toggleOtherOffMessage() {
|
||||
return this.options().toggleOtherOffMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String cannotUseMessage() {
|
||||
public @NonNull String cannotUseMessage() {
|
||||
return this.options().cannotUseMessage();
|
||||
}
|
||||
|
||||
@@ -491,7 +515,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Context context(@NonNull final String key) {
|
||||
public @Nullable Context context(final @NonNull String key) {
|
||||
return this.options().context(key);
|
||||
}
|
||||
|
||||
|
||||
+59
-56
@@ -26,12 +26,12 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class CarbonWhisperChannel implements WhisperChannel {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final PlayerUser sender;
|
||||
private @NonNull final PlayerUser audience;
|
||||
private final @NonNull PlayerUser sender;
|
||||
private final @NonNull PlayerUser audience;
|
||||
|
||||
public CarbonWhisperChannel(@NonNull final PlayerUser sender, @NonNull final PlayerUser audience) {
|
||||
public CarbonWhisperChannel(final @NonNull PlayerUser sender, final @NonNull PlayerUser audience) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.sender = sender;
|
||||
this.audience = audience;
|
||||
@@ -48,26 +48,34 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable TextColor channelColor(@NonNull final CarbonUser user) {
|
||||
public @NonNull TextColor channelColor(final @NonNull CarbonUser user) {
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final PlayerUser user, @NonNull final String message,
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user, final @NonNull String message,
|
||||
final boolean fromRemote) {
|
||||
return this.parseMessage(user, Collections.singleton(this.audience()), message, fromRemote);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final PlayerUser user,
|
||||
@NonNull final Collection<@NonNull PlayerUser> recipients,
|
||||
@NonNull final String message, final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(final @NonNull PlayerUser user,
|
||||
final @NonNull Collection<@NonNull PlayerUser> recipients,
|
||||
final @NonNull String message, final boolean fromRemote) {
|
||||
final Map<CarbonUser, Component> result = new HashMap<>();
|
||||
|
||||
// Formats
|
||||
final String senderFormat = this.senderFormat();
|
||||
final String receiverFormat = this.receiverFormat();
|
||||
|
||||
if (senderFormat == null) {
|
||||
throw new IllegalArgumentException("Sender format (whispers) not found!");
|
||||
}
|
||||
|
||||
if (receiverFormat == null) {
|
||||
throw new IllegalArgumentException("Receiver format (whispers) not found!");
|
||||
}
|
||||
|
||||
final ChatFormatEvent senderFormatEvent = new ChatFormatEvent(this.sender, this.sender, this, senderFormat, message);
|
||||
|
||||
CarbonEvents.post(senderFormatEvent);
|
||||
@@ -85,21 +93,8 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
}
|
||||
|
||||
// Display names
|
||||
final String senderName;
|
||||
|
||||
if (this.sender.nickname() != null) {
|
||||
senderName = this.sender.nickname();
|
||||
} else {
|
||||
senderName = this.sender.displayName();
|
||||
}
|
||||
|
||||
final String receiverName;
|
||||
|
||||
if (this.audience.nickname() != null) {
|
||||
receiverName = this.audience.nickname();
|
||||
} else {
|
||||
receiverName = this.audience.displayName();
|
||||
}
|
||||
final String senderName = this.sender.nickname();
|
||||
final String receiverName = this.audience.nickname();
|
||||
|
||||
// Components
|
||||
final TextComponent senderComponent = (TextComponent) this.carbonChat.messageProcessor().processMessage(
|
||||
@@ -134,27 +129,35 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
|
||||
result.put(this.audience, receiverComponentEvent.component());
|
||||
|
||||
final ChatFormatEvent consoleFormatEvent = new ChatFormatEvent(this.sender, null, this,
|
||||
this.consoleFormat(), message);
|
||||
final String consoleFormatString = this.consoleFormat();
|
||||
|
||||
CarbonEvents.post(consoleFormatEvent);
|
||||
if (consoleFormatString != null) {
|
||||
final ChatFormatEvent consoleFormatEvent = new ChatFormatEvent(this.sender, null, this,
|
||||
consoleFormatString, message);
|
||||
|
||||
final TextComponent consoleFormat = (TextComponent) this.carbonChat.messageProcessor().processMessage(
|
||||
consoleFormatEvent.format(),
|
||||
"senderdisplayname", senderName,
|
||||
"sender", this.sender.name(),
|
||||
"receiverdisplayname", receiverName,
|
||||
"receiver", this.audience.name(),
|
||||
"phase", Long.toString(System.currentTimeMillis() % 25),
|
||||
"message", senderFormatEvent.message());
|
||||
CarbonEvents.post(consoleFormatEvent);
|
||||
|
||||
final ChatComponentEvent consoleEvent = new ChatComponentEvent(this.sender, null, this, consoleFormat,
|
||||
consoleFormatEvent.message());
|
||||
final TextComponent consoleFormat = (TextComponent) this.carbonChat.messageProcessor().processMessage(
|
||||
consoleFormatEvent.format(),
|
||||
"senderdisplayname", senderName,
|
||||
"sender", this.sender.name(),
|
||||
"receiverdisplayname", receiverName,
|
||||
"receiver", this.audience.name(),
|
||||
"phase", Long.toString(System.currentTimeMillis() % 25),
|
||||
"message", senderFormatEvent.message());
|
||||
|
||||
CarbonEvents.post(consoleEvent);
|
||||
final ChatComponentEvent consoleEvent = new ChatComponentEvent(this.sender, null, this, consoleFormat,
|
||||
consoleFormatEvent.message());
|
||||
|
||||
if (!consoleEvent.cancelled()) {
|
||||
result.put(this.carbonChat.userService().consoleUser(), consoleEvent.component());
|
||||
CarbonEvents.post(consoleEvent);
|
||||
|
||||
if (!consoleEvent.cancelled()) {
|
||||
final ConsoleUser consoleUser = this.carbonChat.userService().consoleUser();
|
||||
|
||||
if (consoleUser != null) {
|
||||
result.put(consoleUser, consoleEvent.component());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.sender.replyTarget(this.audience);
|
||||
@@ -164,31 +167,31 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(@NonNull final PlayerUser user) {
|
||||
public boolean canPlayerUse(final @NonNull PlayerUser user) {
|
||||
return user.equals(this.sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull final PlayerUser sender, @NonNull final PlayerUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(final @NonNull PlayerUser sender, final @NonNull PlayerUser target, final boolean checkSpying) {
|
||||
return (checkSpying && target.spyingWhispers()) || (sender.equals(this.sender) && target.equals(this.audience));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull final PlayerUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(final @NonNull PlayerUser target, final boolean checkSpying) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponents(@NonNull final Identity identity,
|
||||
@NonNull final Map<? extends CarbonUser, Component> components) {
|
||||
public void sendComponents(final @NonNull Identity identity,
|
||||
final @NonNull Map<? extends CarbonUser, Component> components) {
|
||||
for (final Map.Entry<? extends CarbonUser, Component> entry : components.entrySet()) {
|
||||
entry.getKey().sendMessage(identity, entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponentsAndLog(@NonNull final Identity identity,
|
||||
@NonNull final Map<? extends CarbonUser, Component> components) {
|
||||
public void sendComponentsAndLog(final @NonNull Identity identity,
|
||||
final @NonNull Map<? extends CarbonUser, Component> components) {
|
||||
for (final Map.Entry<? extends CarbonUser, Component> entry : components.entrySet()) {
|
||||
entry.getKey().sendMessage(Identity.nil(), entry.getValue());
|
||||
|
||||
@@ -232,47 +235,47 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String switchMessage() {
|
||||
public @NonNull String switchMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().switchMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String switchOtherMessage() {
|
||||
public @NonNull String switchOtherMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().switchOtherMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String switchFailureMessage() {
|
||||
public @NonNull String switchFailureMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().switchFailureMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String cannotIgnoreMessage() {
|
||||
public @NonNull String cannotIgnoreMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().cannotIgnoreMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOffMessage() {
|
||||
public @NonNull String toggleOffMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().toggleOffMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOnMessage() {
|
||||
public @NonNull String toggleOnMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().toggleOnMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOtherOnMessage() {
|
||||
public @NonNull String toggleOtherOnMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().toggleOtherOnMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String toggleOtherOffMessage() {
|
||||
public @NonNull String toggleOtherOffMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().toggleOtherOffMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String cannotUseMessage() {
|
||||
public @NonNull String cannotUseMessage() {
|
||||
return this.carbonChat.carbonSettings().whisperOptions().cannotUseMessage();
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -16,23 +16,23 @@ import java.util.Map;
|
||||
|
||||
public class ChannelManager {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final ChannelRegistry registry;
|
||||
private final @NonNull ChannelRegistry registry;
|
||||
|
||||
@Nullable
|
||||
@MonotonicNonNull
|
||||
private String defaultChannelKey = null;
|
||||
private @MonotonicNonNull String defaultChannelKey = null;
|
||||
|
||||
public ChannelManager(@NonNull final CarbonChat carbonChat) {
|
||||
@SuppressWarnings("method.invocation.invalid")
|
||||
public ChannelManager(final @NonNull CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.registry = new ChannelRegistry();
|
||||
|
||||
this.carbonChat.logger().info("Loading channels!");
|
||||
this.reload();
|
||||
|
||||
this.loadChannels();
|
||||
}
|
||||
|
||||
public @Nullable ChatChannel loadChannel(@NonNull final ChannelOptions settings) {
|
||||
public @Nullable ChatChannel loadChannel(final @NonNull ChannelOptions settings) {
|
||||
final ChatChannel channel = new CarbonChatChannel(this.carbonChat, settings);
|
||||
|
||||
final String name = settings.name();
|
||||
@@ -46,7 +46,7 @@ public class ChannelManager {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void registerChannel(@NonNull final ChatChannel channel) {
|
||||
public void registerChannel(final @NonNull ChatChannel channel) {
|
||||
this.registry().register(channel.key(), channel);
|
||||
|
||||
if (channel instanceof TextChannel) {
|
||||
@@ -71,7 +71,7 @@ public class ChannelManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable ChatChannel channelOrDefault(@Nullable final String key) {
|
||||
public @Nullable ChatChannel channelOrDefault(final @Nullable String key) {
|
||||
if (key == null) {
|
||||
return this.defaultChannel();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class ChannelManager {
|
||||
return channel;
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
private void loadChannels() {
|
||||
this.carbonChat.logger().info("Channels found: " +
|
||||
this.carbonChat.channelSettings().channelOptions().size());
|
||||
|
||||
|
||||
+7
-6
@@ -13,13 +13,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class AliasedChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final TextChannel chatChannel;
|
||||
private final @NonNull TextChannel chatChannel;
|
||||
|
||||
private @NonNull final String commandName;
|
||||
private final @NonNull String commandName;
|
||||
|
||||
public AliasedChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager, @NonNull final TextChannel chatChannel) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public AliasedChannelCommand(final @NonNull CommandManager<CarbonUser> commandManager, final @NonNull TextChannel chatChannel) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.chatChannel = chatChannel;
|
||||
this.commandName = chatChannel.key();
|
||||
@@ -44,7 +45,7 @@ public class AliasedChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void channel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void channel(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
|
||||
if (user.channelSettings(this.chatChannel()).ignored()) {
|
||||
@@ -58,7 +59,7 @@ public class AliasedChannelCommand {
|
||||
user.selectedChannel(this.chatChannel());
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {
|
||||
context.<String>getOptional("message").ifPresent(message -> {
|
||||
this.chatChannel().sendComponentsAndLog(
|
||||
context.getSender().identity(),
|
||||
|
||||
+6
-5
@@ -16,14 +16,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ChannelCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("channel");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ public class ChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void channel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void channel(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final TextChannel channel = context.get("channel");
|
||||
|
||||
@@ -64,7 +65,7 @@ public class ChannelCommand {
|
||||
user.selectedChannel(channel);
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final ChatChannel channel = context.get("channel");
|
||||
final String message = context.get("message");
|
||||
|
||||
|
||||
+9
-8
@@ -21,14 +21,15 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class ChannelListCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ChannelListCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ChannelListCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("channellist");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,11 +53,11 @@ public class ChannelListCommand {
|
||||
);
|
||||
}
|
||||
|
||||
public void channelListSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
public void channelListSelf(final @NonNull CommandContext<CarbonUser> context) {
|
||||
this.listAndSend(context.getSender(), (PlayerUser) context.getSender(), this.carbonChat.channelRegistry().iterator());
|
||||
}
|
||||
|
||||
public void channelListOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
public void channelListOther(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.get("user");
|
||||
|
||||
@@ -73,8 +74,8 @@ public class ChannelListCommand {
|
||||
this.listAndSend(sender, user, allChannels);
|
||||
}
|
||||
|
||||
private void listAndSend(@NonNull final CarbonUser sender, @NonNull final PlayerUser user,
|
||||
@NonNull final Iterator<ChatChannel> allChannels) {
|
||||
private void listAndSend(final @NonNull CarbonUser sender, final @NonNull PlayerUser user,
|
||||
final @NonNull Iterator<ChatChannel> allChannels) {
|
||||
ChatChannel channel;
|
||||
final List<ChatChannel> canSee = new ArrayList<>();
|
||||
final List<ChatChannel> cannotSee = new ArrayList<>();
|
||||
@@ -114,7 +115,7 @@ public class ChannelListCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void makeList(@NonNull final Iterator<@NonNull ChatChannel> iterator, final TextComponent.@NonNull Builder list) {
|
||||
private void makeList(final @NonNull Iterator<@NonNull ChatChannel> iterator, final TextComponent.@NonNull Builder list) {
|
||||
final String listSeparator = this.carbonChat.translations().channelListSeparator();
|
||||
final Component listSeparatorComponent = Component.text(listSeparator);
|
||||
|
||||
|
||||
+5
-4
@@ -12,14 +12,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ChatReloadCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ChatReloadCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ChatReloadCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("chatreload");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,7 +34,7 @@ public class ChatReloadCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void reloadConfig(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void reloadConfig(final @NonNull CommandContext<CarbonUser> context) {
|
||||
this.carbonChat.reloadConfig();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor()
|
||||
|
||||
+7
-6
@@ -14,14 +14,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ClearChatCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ClearChatCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ClearChatCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("clearchat");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ public class ClearChatCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void clearChat(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void clearChat(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final String sender = context.getSender().name();
|
||||
final String format = this.carbonChat.moderationSettings().clearChat().message();
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n");
|
||||
@@ -55,7 +56,7 @@ public class ClearChatCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void clearChatPlayer(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void clearChatPlayer(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser target = context.get("user");
|
||||
final String sender = context.getSender().name();
|
||||
final String format = this.carbonChat.moderationSettings().clearChat().message();
|
||||
@@ -64,7 +65,7 @@ public class ClearChatCommand {
|
||||
this.clearUserChat(target, component, sender);
|
||||
}
|
||||
|
||||
private void clearUserChat(@NonNull final CarbonUser user, @NonNull final Component component, @NonNull final String sender) {
|
||||
private void clearUserChat(final @NonNull CarbonUser user, final @NonNull Component component, final @NonNull String sender) {
|
||||
if (user.hasPermission("carbonchat.clearchat.exempt")) {
|
||||
final String message = this.carbonChat.translations().clearExempt();
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor()
|
||||
|
||||
+5
-4
@@ -14,14 +14,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class IgnoreCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public IgnoreCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public IgnoreCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("ignore");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ public class IgnoreCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void ignoreUser(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void ignoreUser(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser sender = (PlayerUser) context.getSender();
|
||||
final PlayerUser targetUser = context.get("user");
|
||||
|
||||
|
||||
@@ -13,14 +13,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MeCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public MeCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public MeCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("me");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ public class MeCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void message(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void message(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
|
||||
final String message = context.<String>get("message").replace("</pre>", "");
|
||||
|
||||
+5
-4
@@ -19,15 +19,16 @@ import java.util.Optional;
|
||||
|
||||
public class MessageCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public MessageCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public MessageCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
final CommandSettings commandSettings = carbonChat.commandSettings().get("message");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class MessageCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser sender = (PlayerUser) context.getSender();
|
||||
final PlayerUser receiver = context.get("user");
|
||||
|
||||
|
||||
+14
-5
@@ -15,14 +15,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MsgToggleCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public MsgToggleCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public MsgToggleCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("msgtoggle");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,10 +47,14 @@ public class MsgToggleCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void toggleSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void toggleSelf(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get("whisper");
|
||||
|
||||
if (channel == null) {
|
||||
throw new IllegalArgumentException("Whisper channel not found!");
|
||||
}
|
||||
|
||||
final String message;
|
||||
|
||||
final UserChannelSettings settings = user.channelSettings(channel);
|
||||
@@ -67,11 +72,15 @@ public class MsgToggleCommand {
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(message));
|
||||
}
|
||||
|
||||
private void toggleOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void toggleOther(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.get("user");
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get("whisper");
|
||||
|
||||
if (channel == null) {
|
||||
throw new IllegalArgumentException("Whisper channel not found!");
|
||||
}
|
||||
|
||||
final String message;
|
||||
final String otherMessage;
|
||||
|
||||
|
||||
@@ -14,14 +14,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MuteCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public MuteCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public MuteCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("mute");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ public class MuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void mute(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void mute(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final CarbonUser user = context.getSender();
|
||||
final PlayerUser target = context.get("user");
|
||||
|
||||
|
||||
+6
-5
@@ -14,14 +14,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class NicknameCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public NicknameCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public NicknameCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("nickname");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ public class NicknameCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void nicknameSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void nicknameSelf(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
String nickname = context.get("nickname");
|
||||
|
||||
@@ -70,7 +71,7 @@ public class NicknameCommand {
|
||||
"user", user.name(), "sender", context.getSender().name()));
|
||||
}
|
||||
|
||||
private void nicknameOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void nicknameOther(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser target = context.get("user");
|
||||
String nickname = context.get("nickname");
|
||||
|
||||
|
||||
+14
-7
@@ -12,16 +12,19 @@ import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ReplyCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ReplyCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ReplyCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("reply");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +39,7 @@ public class ReplyCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void reply(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void reply(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final String input = context.get("message");
|
||||
|
||||
@@ -49,7 +52,9 @@ public class ReplyCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.replyTarget() == null) {
|
||||
final UUID replyTarget = user.replyTarget();
|
||||
|
||||
if (replyTarget == null) {
|
||||
final String message = this.carbonChat.translations().noReplyTarget();
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(message, "br", "\n");
|
||||
|
||||
@@ -58,9 +63,11 @@ public class ReplyCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final PlayerUser targetUser = this.carbonChat.userService().wrap(user.replyTarget());
|
||||
final PlayerUser targetUser = this.carbonChat.userService().wrap(replyTarget);
|
||||
|
||||
targetUser.sendMessage(user, input);
|
||||
if (targetUser != null) {
|
||||
targetUser.sendMessage(user, input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+4
-3
@@ -16,14 +16,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class SetColorCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public SetColorCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public SetColorCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("setcolor");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -14,14 +14,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ShadowMuteCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ShadowMuteCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("shadowmute");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ public class ShadowMuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void shadowMute(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void shadowMute(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final CarbonUser user = context.getSender();
|
||||
final PlayerUser target = context.get("user");
|
||||
|
||||
|
||||
+7
-6
@@ -17,14 +17,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class SpyChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public SpyChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public SpyChannelCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("spy");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ public class SpyChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void spyChannel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void spyChannel(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final ChatChannel chatChannel = context.get("channel");
|
||||
|
||||
@@ -81,7 +82,7 @@ public class SpyChannelCommand {
|
||||
"channel", chatChannel.name()));
|
||||
}
|
||||
|
||||
private void spyWhispers(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void spyWhispers(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
|
||||
final String message;
|
||||
@@ -97,7 +98,7 @@ public class SpyChannelCommand {
|
||||
user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage(message));
|
||||
}
|
||||
|
||||
private void spyEverything(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void spyEverything(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final Boolean shouldSpy = context.get("enabled");
|
||||
|
||||
|
||||
+6
-5
@@ -16,14 +16,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class SudoChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public SudoChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public SudoChannelCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("sudochannel");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ public class SudoChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void otherChannel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void otherChannel(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.get("user");
|
||||
final ChatChannel channel = context.get("channel");
|
||||
@@ -70,7 +71,7 @@ public class SudoChannelCommand {
|
||||
"channel", channel.name(), "player", user.name()));
|
||||
}
|
||||
|
||||
private void sendMessageOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void sendMessageOther(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = context.get("user");
|
||||
final ChatChannel channel = context.get("channel");
|
||||
final String message = context.get("message");
|
||||
|
||||
+6
-5
@@ -16,14 +16,15 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ToggleCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public ToggleCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public ToggleCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("toggle");
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ public class ToggleCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void toggleSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void toggleSelf(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser) context.getSender();
|
||||
final ChatChannel channel = context.get("channel");
|
||||
|
||||
@@ -72,7 +73,7 @@ public class ToggleCommand {
|
||||
"channel", channel.name()));
|
||||
}
|
||||
|
||||
private void toggleOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
private void toggleOther(final @NonNull CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.get("user");
|
||||
final ChatChannel channel = context.get("channel");
|
||||
|
||||
+4
-4
@@ -21,8 +21,8 @@ public final class ChannelArgument<C> extends CommandArgument<C, TextChannel> {
|
||||
TextChannel.class, ChannelArgument::suggestions);
|
||||
}
|
||||
|
||||
private static <C> ArgumentParseResult<TextChannel> parser(@NonNull final CommandContext<C> commandContext,
|
||||
@NonNull final Queue<String> inputs) {
|
||||
private static <C> ArgumentParseResult<TextChannel> parser(final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull Queue<String> inputs) {
|
||||
final String input = inputs.poll();
|
||||
|
||||
final ExceptionMessages exceptions = CarbonChatProvider.carbonChat().translations().exceptionMessages();
|
||||
@@ -43,8 +43,8 @@ public final class ChannelArgument<C> extends CommandArgument<C, TextChannel> {
|
||||
}
|
||||
}
|
||||
|
||||
private static <C> List<String> suggestions(@NonNull final CommandContext<C> commandContext,
|
||||
@NonNull final String input) {
|
||||
private static <C> List<String> suggestions(final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull String input) {
|
||||
return CarbonChatProvider.carbonChat().channelRegistry().stream()
|
||||
.map(ChatChannel::key).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
+4
-4
@@ -21,8 +21,8 @@ public final class PlayerUserArgument<C> extends CommandArgument<C, PlayerUser>
|
||||
PlayerUser.class, PlayerUserArgument::suggestions);
|
||||
}
|
||||
|
||||
private static <C> ArgumentParseResult<PlayerUser> parser(@NonNull final CommandContext<C> commandContext,
|
||||
@NonNull final Queue<String> inputs) {
|
||||
private static <C> ArgumentParseResult<PlayerUser> parser(final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull Queue<String> inputs) {
|
||||
final String input = inputs.poll();
|
||||
|
||||
final String playerNotFound = CarbonChatProvider.carbonChat().translations().exceptionMessages()
|
||||
@@ -47,8 +47,8 @@ public final class PlayerUserArgument<C> extends CommandArgument<C, PlayerUser>
|
||||
return ArgumentParseResult.success(user);
|
||||
}
|
||||
|
||||
private static <C> List<String> suggestions(@NonNull final CommandContext<C> commandContext,
|
||||
@NonNull final String input) {
|
||||
private static <C> List<String> suggestions(final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull String input) {
|
||||
return StreamSupport
|
||||
.stream(CarbonChatProvider.carbonChat().userService().onlineUsers().spliterator(), false)
|
||||
.map(PlayerUser::name)
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public final class CommandRegistrar {
|
||||
|
||||
}
|
||||
|
||||
public static void registerCommands(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
public static void registerCommands(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
new ChannelCommand(commandManager);
|
||||
new ChannelListCommand(commandManager);
|
||||
new ChatReloadCommand(commandManager);
|
||||
|
||||
+3
-3
@@ -49,9 +49,9 @@ public final class SoundSerializer implements TypeSerializer<Sound> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Sound deserialize(@NonNull final Type type, @NonNull final ConfigurationNode value) throws SerializationException {
|
||||
public @NonNull Sound deserialize(final @NonNull Type type, final @NonNull ConfigurationNode value) throws SerializationException {
|
||||
if (value.empty()) {
|
||||
return null;
|
||||
throw new SerializationException("Value not found for sound!");
|
||||
}
|
||||
|
||||
final Key name = value.node(NAME).get(KeySerializer.INSTANCE.type());
|
||||
@@ -67,7 +67,7 @@ public final class SoundSerializer implements TypeSerializer<Sound> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NonNull final Type type, @Nullable final Sound obj, @NonNull final ConfigurationNode value) throws SerializationException {
|
||||
public void serialize(final @NonNull Type type, final @Nullable Sound obj, final @NonNull ConfigurationNode value) throws SerializationException {
|
||||
if (obj == null) {
|
||||
value.set(null);
|
||||
return;
|
||||
|
||||
+4
-3
@@ -16,9 +16,10 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class FilterContext {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public FilterContext(@NonNull final CarbonChat carbonChat) {
|
||||
@SuppressWarnings("method.invocation.invalid")
|
||||
public FilterContext(final @NonNull CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
CarbonEvents.register(PreChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
@@ -61,7 +62,7 @@ public class FilterContext {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean channelUsesFilter(@NonNull final ChatChannel chatChannel) {
|
||||
private boolean channelUsesFilter(final @NonNull ChatChannel chatChannel) {
|
||||
if (chatChannel instanceof TextChannel) {
|
||||
final Context context = ((TextChannel) chatChannel).context("filter");
|
||||
|
||||
|
||||
+5
-2
@@ -2,17 +2,20 @@ package net.draycia.carbon.common.listeners.events;
|
||||
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.PostOrders;
|
||||
|
||||
public class IgnoredPlayerHandler {
|
||||
|
||||
public IgnoredPlayerHandler() {
|
||||
CarbonEvents.register(ChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
if (event.target() == null) {
|
||||
final PlayerUser target = event.target();
|
||||
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.target().ignoringUser(event.sender())) {
|
||||
if (target.ignoringUser(event.sender())) {
|
||||
event.cancelled(true);
|
||||
}
|
||||
});
|
||||
|
||||
+6
-3
@@ -4,6 +4,7 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.PostOrders;
|
||||
|
||||
public class PingHandler {
|
||||
@@ -16,11 +17,13 @@ public class PingHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.target() == null) {
|
||||
final PlayerUser target = event.target();
|
||||
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String targetName = event.target().name();
|
||||
final String targetName = target.name();
|
||||
final String prefix = carbonChat.carbonSettings().channelPings().prefix();
|
||||
final boolean caseSensitive = carbonChat.carbonSettings().channelPings().caseSensitive();
|
||||
|
||||
@@ -34,7 +37,7 @@ public class PingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
event.target().playSound(carbonChat.carbonSettings().channelPings().sound());
|
||||
target.playSound(carbonChat.carbonSettings().channelPings().sound());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -7,6 +7,7 @@ import net.kyori.event.PostOrders;
|
||||
|
||||
public class UserFormattingHandler {
|
||||
|
||||
@SuppressWarnings("method.invocation.invalid")
|
||||
public UserFormattingHandler() {
|
||||
CarbonEvents.register(PreChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
if (!event.user().hasPermission("carbonchat.formatting") &&
|
||||
|
||||
+4
-4
@@ -13,22 +13,22 @@ import java.util.function.Consumer;
|
||||
public class EmptyMessageService implements MessageService {
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
public void unregisterMessageListener(final @NonNull String key) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
+45
-18
@@ -16,11 +16,12 @@ import java.util.function.Consumer;
|
||||
|
||||
public class MessageManager {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final MessageService messageService;
|
||||
private final @NonNull MessageService messageService;
|
||||
|
||||
public MessageManager(@NonNull final CarbonChat carbonChat, @NonNull final MessageService messageService) {
|
||||
@SuppressWarnings("method.invocation.invalid")
|
||||
public MessageManager(final @NonNull CarbonChat carbonChat, final @NonNull MessageService messageService) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.messageService = messageService;
|
||||
|
||||
@@ -45,7 +46,11 @@ public class MessageManager {
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("selected-channel", (user, byteArray) -> {
|
||||
user.selectedChannel(this.carbonChat.channelRegistry().get(byteArray.readUTF()), true);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
|
||||
if (channel != null) {
|
||||
user.selectedChannel(channel, true);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("spying-whispers", (user, byteArray) -> {
|
||||
@@ -64,35 +69,55 @@ public class MessageManager {
|
||||
user.replyTarget(new UUID(byteArray.readLong(), byteArray.readLong()), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("reply-target-reset", (user, byteArray) -> {
|
||||
user.replyTarget((UUID) null, true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("ignoring-user", (user, byteArray) -> {
|
||||
user.ignoringUser(new UUID(byteArray.readLong(), byteArray.readLong()), byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("ignoring-channel", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelRegistry().get(byteArray.readUTF()))
|
||||
.ignoring(byteArray.readBoolean(), true);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
|
||||
if (channel != null) {
|
||||
user.channelSettings(channel)
|
||||
.ignoring(byteArray.readBoolean(), true);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("spying-channel", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelRegistry().get(byteArray.readUTF()))
|
||||
.spying(byteArray.readBoolean(), true);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
|
||||
if (channel != null) {
|
||||
user.channelSettings(channel)
|
||||
.spying(byteArray.readBoolean(), true);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("channel-color", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelRegistry().get(byteArray.readUTF()))
|
||||
.color(TextColor.fromHexString(byteArray.readUTF()), true);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
|
||||
if (channel != null) {
|
||||
user.channelSettings(channel)
|
||||
.color(TextColor.fromHexString(byteArray.readUTF()), true);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUserMessageListener("channel-color-reset", (user, byteArray) -> {
|
||||
user.channelSettings(this.carbonChat.channelRegistry().get(byteArray.readUTF()))
|
||||
.color(null, true);
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
|
||||
if (channel != null) {
|
||||
user.channelSettings(channel)
|
||||
.color(null, true);
|
||||
}
|
||||
});
|
||||
|
||||
this.messageService().registerUUIDMessageListener("channel-component", (uuid, byteArray) -> {
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(uuid);
|
||||
|
||||
if (channel instanceof TextChannel) {
|
||||
if (user != null && channel instanceof TextChannel) {
|
||||
final Component component = this.carbonChat.gsonSerializer().deserialize(byteArray.readUTF());
|
||||
|
||||
((TextChannel) channel).sendComponent(user, component);
|
||||
@@ -107,9 +132,11 @@ public class MessageManager {
|
||||
final PlayerUser target = this.carbonChat.userService().wrap(recipient);
|
||||
final String message = byteArray.readUTF();
|
||||
|
||||
if (!target.ignoringUser(uuid)) {
|
||||
target.replyTarget(uuid);
|
||||
target.sendMessage(Identity.identity(uuid), this.carbonChat.gsonSerializer().deserialize(message));
|
||||
if (target != null) {
|
||||
if (!target.ignoringUser(uuid)) {
|
||||
target.replyTarget(uuid);
|
||||
target.sendMessage(Identity.identity(uuid), this.carbonChat.gsonSerializer().deserialize(message));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,8 +145,8 @@ public class MessageManager {
|
||||
return this.messageService;
|
||||
}
|
||||
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid,
|
||||
@NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid,
|
||||
final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
this.messageService().sendMessage(key, uuid, consumer);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -10,23 +10,23 @@ public interface RedisListener extends RedisPubSubListener<String, String> {
|
||||
void message(@NonNull String channel, @NonNull String message);
|
||||
|
||||
@Override
|
||||
default void message(@NonNull final String pattern, @NonNull final String channel, @NonNull final String message) {
|
||||
default void message(final @NonNull String pattern, final @NonNull String channel, final @NonNull String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void subscribed(@NonNull final String channel, final long count) {
|
||||
default void subscribed(final @NonNull String channel, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void psubscribed(@NonNull final String pattern, final long count) {
|
||||
default void psubscribed(final @NonNull String pattern, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void unsubscribed(@NonNull final String channel, final long count) {
|
||||
default void unsubscribed(final @NonNull String channel, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void punsubscribed(@NonNull final String pattern, final long count) {
|
||||
default void punsubscribed(final @NonNull String pattern, final long count) {
|
||||
}
|
||||
|
||||
}
|
||||
+17
-14
@@ -22,26 +22,29 @@ import java.util.function.Consumer;
|
||||
|
||||
public class RedisMessageService implements MessageService {
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
private final @NonNull Map<@NonNull String, @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
private final @NonNull Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
|
||||
private @NonNull final RedisPubSubCommands<@NonNull String, @NonNull String> subscribeSync;
|
||||
private final @NonNull RedisPubSubCommands<@NonNull String, @NonNull String> subscribeSync;
|
||||
|
||||
private @NonNull final RedisPubSubCommands<@NonNull String, @NonNull String> publishSync;
|
||||
private final @NonNull RedisPubSubCommands<@NonNull String, @NonNull String> publishSync;
|
||||
|
||||
private @NonNull final UUID serverUUID = UUID.randomUUID();
|
||||
private final @NonNull UUID serverUUID = UUID.randomUUID();
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
public RedisMessageService(@NonNull final CarbonChat carbonChat, @NonNull final RedisCredentials credentials) {
|
||||
@SuppressWarnings("method.invocation.invalid")
|
||||
public RedisMessageService(final @NonNull CarbonChat carbonChat, final @NonNull RedisCredentials credentials) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
final RedisURI.Builder builder = RedisURI.Builder.redis(credentials.host(), credentials.port())
|
||||
.withDatabase(credentials.database());
|
||||
|
||||
if (credentials.password() != null) {
|
||||
builder.withPassword(credentials.password().toCharArray());
|
||||
final String password = credentials.password();
|
||||
|
||||
if (password != null) {
|
||||
builder.withPassword(password.toCharArray());
|
||||
}
|
||||
|
||||
final RedisClient client = RedisClient.create(builder.build());
|
||||
@@ -67,7 +70,7 @@ public class RedisMessageService implements MessageService {
|
||||
});
|
||||
}
|
||||
|
||||
private void receiveMessage(@NonNull final UUID uuid, @NonNull final String key, @NonNull final ByteArrayDataInput value) {
|
||||
private void receiveMessage(final @NonNull UUID uuid, final @NonNull String key, final @NonNull ByteArrayDataInput value) {
|
||||
final PlayerUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
|
||||
if (user != null) {
|
||||
@@ -86,19 +89,19 @@ public class RedisMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull PlayerUser, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userNotLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
public void unregisterMessageListener(final @NonNull String key) {
|
||||
this.userLoadedListeners.remove(key);
|
||||
this.userNotLoadedListeners.remove(key);
|
||||
|
||||
@@ -106,7 +109,7 @@ public class RedisMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
final ByteArrayDataOutput msg = ByteStreams.newDataOutput();
|
||||
|
||||
msg.writeLong(this.serverUUID.getMostSignificantBits());
|
||||
|
||||
+33
-27
@@ -30,24 +30,25 @@ import java.util.function.Supplier;
|
||||
|
||||
public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implements UserService<T> {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private @NonNull final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
private @NonNull final Type userType;
|
||||
private @NonNull final Supplier<@NonNull Iterable<@NonNull T>> supplier;
|
||||
private @NonNull final Function<UUID, T> userFactory;
|
||||
private @NonNull final Function<String, UUID> nameResolver;
|
||||
private @NonNull final Supplier<C> consoleFactory;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
private final @NonNull Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
private final @NonNull Type userType;
|
||||
private final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier;
|
||||
private final @NonNull Function<UUID, T> userFactory;
|
||||
private final @NonNull Function<String, UUID> nameResolver;
|
||||
private final @NonNull Supplier<C> consoleFactory;
|
||||
|
||||
private @NonNull final LoadingCache<@NonNull UUID, @NonNull T> userCache = CacheBuilder.newBuilder()
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
private final @NonNull LoadingCache<@NonNull UUID, @NonNull T> userCache = CacheBuilder.newBuilder()
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public JSONUserService(@NonNull final Class<? extends CarbonUser> userType,
|
||||
@NonNull final CarbonChat carbonChat,
|
||||
@NonNull final Supplier<@NonNull Iterable<@NonNull T>> supplier,
|
||||
@NonNull final Function<UUID, T> userFactory,
|
||||
@NonNull final Function<String, UUID> nameResolver,
|
||||
@NonNull final Supplier<C> consoleFactory) {
|
||||
public JSONUserService(final @NonNull Class<? extends CarbonUser> userType,
|
||||
final @NonNull CarbonChat carbonChat,
|
||||
final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier,
|
||||
final @NonNull Function<UUID, T> userFactory,
|
||||
final @NonNull Function<String, UUID> nameResolver,
|
||||
final @NonNull Supplier<C> consoleFactory) {
|
||||
this.userType = userType;
|
||||
this.carbonChat = carbonChat;
|
||||
this.supplier = supplier;
|
||||
@@ -66,7 +67,7 @@ public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID resolve(@NonNull final String name) {
|
||||
public UUID resolve(final @NonNull String name) {
|
||||
return this.nameResolver.apply(name);
|
||||
}
|
||||
|
||||
@@ -77,12 +78,11 @@ public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T wrap(@NonNull final UUID uuid) {
|
||||
public @NonNull T wrap(final @NonNull UUID uuid) {
|
||||
try {
|
||||
return this.userCache.get(uuid);
|
||||
} catch (final ExecutionException exception) {
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
throw new IllegalStateException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,24 +92,24 @@ public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T wrapIfLoaded(@NonNull final UUID uuid) {
|
||||
public @Nullable T wrapIfLoaded(final @NonNull UUID uuid) {
|
||||
return this.userCache.getIfPresent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T refreshUser(@NonNull final UUID uuid) {
|
||||
public @Nullable T refreshUser(final @NonNull UUID uuid) {
|
||||
this.userCache.invalidate(uuid);
|
||||
|
||||
return this.wrap(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(@NonNull final T user) {
|
||||
public void invalidate(final @NonNull T user) {
|
||||
this.userCache.invalidate(user.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@NonNull final T user) {
|
||||
public void validate(final @NonNull T user) {
|
||||
this.userCache.put(user.uuid(), user);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implem
|
||||
return this.supplier.get();
|
||||
}
|
||||
|
||||
private @NonNull T loadUser(@NonNull final UUID uuid) {
|
||||
private @NonNull T loadUser(final @NonNull UUID uuid) {
|
||||
final File userFile = new File(this.carbonChat.dataFolder().toFile(), "users/" + uuid.toString() + ".json");
|
||||
this.ensureFileExists(userFile);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implem
|
||||
return this.userFactory.apply(uuid);
|
||||
}
|
||||
|
||||
private void saveUser(@NonNull final RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
private void saveUser(final @NonNull RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
final File userFile = new File(this.carbonChat.dataFolder().toFile(), "users/" + notification.getKey().toString() + ".json");
|
||||
this.ensureFileExists(userFile);
|
||||
|
||||
@@ -146,9 +146,15 @@ public class JSONUserService<T extends PlayerUser, C extends ConsoleUser> implem
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureFileExists(@NonNull final File file) {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
private void ensureFileExists(final @NonNull File file) {
|
||||
final File parentFile = file.getParentFile();
|
||||
|
||||
if (parentFile == null) {
|
||||
throw new IllegalStateException("Parent file not present!");
|
||||
}
|
||||
|
||||
if (!parentFile.exists()) {
|
||||
parentFile.mkdirs();
|
||||
}
|
||||
|
||||
if (!file.exists()) {
|
||||
|
||||
+31
-29
@@ -34,22 +34,23 @@ import java.util.function.Supplier;
|
||||
|
||||
public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> implements UserService<T> {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private @NonNull final Database database;
|
||||
private @NonNull final Supplier<@NonNull Iterable<@NonNull T>> supplier;
|
||||
private @NonNull final Function<UUID, T> userFactory;
|
||||
private @NonNull final Function<String, UUID> nameResolver;
|
||||
private @NonNull final Supplier<C> consoleFactory;
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
private final @NonNull Database database;
|
||||
private final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier;
|
||||
private final @NonNull Function<UUID, T> userFactory;
|
||||
private final @NonNull Function<String, UUID> nameResolver;
|
||||
private final @NonNull Supplier<C> consoleFactory;
|
||||
|
||||
private @NonNull final LoadingCache<@NonNull UUID, @NonNull T> userCache = CacheBuilder.newBuilder()
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
private final @NonNull LoadingCache<@NonNull UUID, @NonNull T> userCache = CacheBuilder.newBuilder()
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public MySQLUserService(@NonNull final CarbonChat carbonChat, @NonNull final SQLCredentials credentials,
|
||||
@NonNull final Supplier<@NonNull Iterable<@NonNull T>> supplier,
|
||||
@NonNull final Function<UUID, T> userFactory,
|
||||
@NonNull final Function<String, UUID> nameResolver,
|
||||
@NonNull final Supplier<C> consoleFactory) {
|
||||
public MySQLUserService(final @NonNull CarbonChat carbonChat, final @NonNull SQLCredentials credentials,
|
||||
final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier,
|
||||
final @NonNull Function<UUID, T> userFactory,
|
||||
final @NonNull Function<String, UUID> nameResolver,
|
||||
final @NonNull Supplier<C> consoleFactory) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.supplier = supplier;
|
||||
this.userFactory = userFactory;
|
||||
@@ -99,7 +100,7 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID resolve(@NonNull final String name) {
|
||||
public UUID resolve(final @NonNull String name) {
|
||||
return this.nameResolver.apply(name);
|
||||
}
|
||||
|
||||
@@ -111,12 +112,11 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T wrap(@NonNull final UUID uuid) {
|
||||
public @NonNull T wrap(final @NonNull UUID uuid) {
|
||||
try {
|
||||
return this.userCache.get(uuid);
|
||||
} catch (final ExecutionException exception) {
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
throw new IllegalStateException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,24 +126,24 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T wrapIfLoaded(@NonNull final UUID uuid) {
|
||||
public @Nullable T wrapIfLoaded(final @NonNull UUID uuid) {
|
||||
return this.userCache.getIfPresent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T refreshUser(@NonNull final UUID uuid) {
|
||||
public @Nullable T refreshUser(final @NonNull UUID uuid) {
|
||||
this.userCache.invalidate(uuid);
|
||||
|
||||
return this.wrap(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(@NonNull final T user) {
|
||||
public void invalidate(final @NonNull T user) {
|
||||
this.userCache.invalidate(user.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@NonNull final T user) {
|
||||
public void validate(final @NonNull T user) {
|
||||
this.userCache.put(user.uuid(), user);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
return this.supplier.get();
|
||||
}
|
||||
|
||||
private @Nullable T loadUser(@NonNull final UUID uuid) {
|
||||
private @Nullable T loadUser(final @NonNull UUID uuid) {
|
||||
final T user = this.userFactory.apply(uuid);
|
||||
|
||||
try (final DbStatement statement = this.database.query("SELECT * from sc_users WHERE uuid = ?;")) {
|
||||
@@ -169,9 +169,7 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().getOrDefault(users.getString("channel"));
|
||||
|
||||
if (channel != null) {
|
||||
user.selectedChannel(channel, true);
|
||||
}
|
||||
user.selectedChannel(channel, true);
|
||||
|
||||
final String nickname = users.getString("nickname");
|
||||
|
||||
@@ -210,15 +208,18 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
return user;
|
||||
}
|
||||
|
||||
private void saveUser(@NonNull final RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
@SuppressWarnings("argument.type.incompatible")
|
||||
private void saveUser(final @NonNull RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
final T user = notification.getValue();
|
||||
|
||||
this.database.createTransaction(stm -> {
|
||||
// Save user general data
|
||||
String selectedName = null;
|
||||
|
||||
if (user.selectedChannel() != null) {
|
||||
selectedName = user.selectedChannel().key();
|
||||
final ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (channel != null) {
|
||||
selectedName = channel.key();
|
||||
}
|
||||
|
||||
this.carbonChat.logger().info("Saving user data!");
|
||||
@@ -233,9 +234,10 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
final UserChannelSettings value = entry.getValue();
|
||||
|
||||
String colorString = null;
|
||||
final TextColor color = value.color();
|
||||
|
||||
if (value.color() != null) {
|
||||
colorString = value.color().asHexString();
|
||||
if (color != null) {
|
||||
colorString = color.asHexString();
|
||||
}
|
||||
|
||||
stm.executeUpdateQuery("INSERT INTO sc_channel_settings (uuid, channel, spying, ignored, color) VALUES (?, ?, ?, ?, ?) " +
|
||||
|
||||
@@ -22,16 +22,16 @@ public final class ColorUtils {
|
||||
|
||||
}
|
||||
|
||||
public @Nullable static TextColor parseColor(@Nullable final String input) {
|
||||
public static @Nullable TextColor parseColor(final @NonNull String input) {
|
||||
return parseColor(null, input);
|
||||
}
|
||||
|
||||
public @Nullable static TextColor parseColor(@Nullable final CarbonUser user, @Nullable String input) {
|
||||
public static @Nullable TextColor parseColor(final @Nullable CarbonUser user, @NonNull String input) {
|
||||
if (user instanceof PlayerUser) {
|
||||
input = ((PlayerUser) user).parsePlaceholders(input);
|
||||
}
|
||||
|
||||
if (input == null || input.isEmpty()) {
|
||||
if (input.isEmpty()) {
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
@@ -50,14 +50,13 @@ public final class ColorUtils {
|
||||
return TextColor.fromCSSHexString(input);
|
||||
}
|
||||
|
||||
private static @NonNull final Pattern spigotLegacyRGB =
|
||||
private static final @NonNull Pattern spigotLegacyRGB =
|
||||
Pattern.compile("[§&]x[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])[§&]([0-9a-f])");
|
||||
|
||||
private static @NonNull final Pattern pluginRGB =
|
||||
private static final @NonNull Pattern pluginRGB =
|
||||
Pattern.compile("[§&]#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])");
|
||||
|
||||
@NonNull
|
||||
public static String translateAlternateColors(@NonNull final String input) {
|
||||
public static @NonNull String translateAlternateColors(final @NonNull String input) {
|
||||
// TODO: check if MiniMessage or MineDown
|
||||
String output = input;
|
||||
|
||||
@@ -83,17 +82,27 @@ public final class ColorUtils {
|
||||
// Legacy Colors
|
||||
for (final char c : "0123456789abcdef".toCharArray()) {
|
||||
final LegacyFormat format = LegacyComponentSerializer.parseChar(c);
|
||||
final TextColor color = format.color();
|
||||
|
||||
output = output.replaceAll("[§&]" + c, "<" + color.asHexString() + ">");
|
||||
if (format != null) {
|
||||
final TextColor color = format.color();
|
||||
|
||||
if (color != null) {
|
||||
output = output.replaceAll("[§&]" + c, "<" + color.asHexString() + ">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy Formatting
|
||||
for (final char c : "klmno".toCharArray()) {
|
||||
final LegacyFormat format = LegacyComponentSerializer.parseChar(c);
|
||||
final TextDecoration decoration = format.decoration();
|
||||
|
||||
output = output.replaceAll("[§&]" + c, "<" + decoration.name() + ">");
|
||||
if (format != null) {
|
||||
final TextDecoration decoration = format.decoration();
|
||||
|
||||
if (decoration != null) {
|
||||
output = output.replaceAll("[§&]" + c, "<" + decoration.name() + ">");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'com.palantir.git-version' version '0.12.3'
|
||||
id 'org.checkerframework' version '0.5.9'
|
||||
id 'org.checkerframework' version '0.5.11'
|
||||
}
|
||||
|
||||
// Gets the git commit hash of the latest commit, used for version string
|
||||
@@ -48,5 +48,12 @@ subprojects {
|
||||
configProperties = [basedir: configRoot.getAbsolutePath()]
|
||||
}
|
||||
|
||||
checkerFramework {
|
||||
checkers = [
|
||||
'org.checkerframework.checker.nullness.NullnessChecker'
|
||||
]
|
||||
}
|
||||
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
}
|
||||
Reference in new issue
Block a user