mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Move to Checkerframework
This commit is contained in:
22 files changed
+82
-76
No files matched your search
@@ -5,32 +5,32 @@ import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.channels.ChatChannel;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public CarbonPlaceholders(@NotNull CarbonChat carbonChat) {
|
||||
public CarbonPlaceholders(@NonNull CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNull
|
||||
public String getIdentifier() {
|
||||
return "carbonchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNull
|
||||
public String getAuthor() {
|
||||
return "Draycia (Vicarious#0001)";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
@NonNull
|
||||
public String getVersion() {
|
||||
return "1.0.0";
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String onPlaceholderRequest(@NotNull final Player player, @NotNull final String identifier) {
|
||||
public String onPlaceholderRequest(@NonNull final Player player, @NonNull final String identifier) {
|
||||
String key = identifier.toLowerCase();
|
||||
|
||||
if (key.startsWith("can_use_")) {
|
||||
|
||||
@@ -41,15 +41,15 @@ import org.apache.commons.lang.NotImplementedException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class CarbonUtils {
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
private static final String[] colors;
|
||||
|
||||
static {
|
||||
@@ -62,8 +62,8 @@ public final class CarbonUtils {
|
||||
colors = colorList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Component createComponent(@NotNull final Player player) {
|
||||
@NonNull
|
||||
public static Component createComponent(@NonNull final Player player) {
|
||||
if (!FunctionalityConstants.HAS_HOVER_EVENT_METHOD) {
|
||||
return net.kyori.adventure.text.TextComponent.empty();
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public final class CarbonUtils {
|
||||
return TextColor.fromCSSHexString(input);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public static Argument onlineChatUserArgument() {
|
||||
return new CustomArgument<>((input) -> {
|
||||
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
@@ -148,7 +148,7 @@ public final class CarbonUtils {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public static Argument chatUserArgument() {
|
||||
return new CustomArgument<>((input) -> {
|
||||
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
@@ -165,7 +165,7 @@ public final class CarbonUtils {
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public static Argument textColorArgument() {
|
||||
return new CustomArgument<>((input) -> {
|
||||
TextColor color = parseColor(input);
|
||||
@@ -178,7 +178,7 @@ public final class CarbonUtils {
|
||||
}).overrideSuggestions(colors);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NonNull
|
||||
public static Argument channelArgument() {
|
||||
return new CustomArgument<>((input) -> {
|
||||
CarbonChat carbonChat = (CarbonChat) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
|
||||
@@ -2,14 +2,14 @@ package net.draycia.carbon.util;
|
||||
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored") // This is a common pattern in this class.
|
||||
public final class FunctionalityConstants {
|
||||
|
||||
public static final boolean HAS_HOVER_EVENT_METHOD = noThrow(() -> ItemFactory.class.getMethod("hoverContentOf", ItemStack.class));
|
||||
|
||||
private static boolean noThrow(@NotNull ThrowingRunnable runnable) {
|
||||
private static boolean noThrow(@NonNull ThrowingRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
return true;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
package net.draycia.carbon.util;
|
||||
|
||||
import io.lettuce.core.pubsub.RedisPubSubListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RedisListener extends RedisPubSubListener<String, String> {
|
||||
|
||||
@Override
|
||||
void message(@NotNull String channel, @NotNull String message);
|
||||
void message(@NonNull String channel, @NonNull String message);
|
||||
|
||||
@Override
|
||||
default void message(@NotNull String pattern, @NotNull String channel, @NotNull String message) { }
|
||||
default void message(@NonNull String pattern, @NonNull String channel, @NonNull String message) { }
|
||||
|
||||
@Override
|
||||
default void subscribed(@NotNull String channel, long count) { }
|
||||
default void subscribed(@NonNull String channel, long count) { }
|
||||
|
||||
@Override
|
||||
default void psubscribed(@NotNull String pattern, long count) { }
|
||||
default void psubscribed(@NonNull String pattern, long count) { }
|
||||
|
||||
@Override
|
||||
default void unsubscribed(@NotNull String channel, long count) { }
|
||||
default void unsubscribed(@NonNull String channel, long count) { }
|
||||
|
||||
@Override
|
||||
default void punsubscribed(@NotNull String pattern, long count) { }
|
||||
default void punsubscribed(@NonNull String pattern, long count) { }
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -14,14 +14,14 @@ public interface Registry<T> {
|
||||
* @param value The value to insert
|
||||
* @return If successfully registered
|
||||
*/
|
||||
boolean register(@NotNull String key, @NotNull T value);
|
||||
boolean register(@NonNull String key, @NonNull T value);
|
||||
|
||||
/**
|
||||
* Gets the list of registered values
|
||||
*
|
||||
* @return The list of registered values
|
||||
*/
|
||||
@NotNull
|
||||
@NonNull
|
||||
Collection<T> values();
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ public interface Registry<T> {
|
||||
* @return The entry associated with the key
|
||||
*/
|
||||
@Nullable
|
||||
T get(@NotNull String key);
|
||||
T get(@NonNull String key);
|
||||
|
||||
/**
|
||||
* Clears all registered entries from the registry
|
||||
|
||||
Reference in new issue
Block a user