diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 7de0a01c..74ba59c4 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -13,7 +13,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Setup Java uses: actions/setup-java@v5 with: diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 1c151fc2..acf57a5f 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -18,7 +18,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout Repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Validate Gradle Wrapper uses: gradle/actions/wrapper-validation@v5 - name: Setup Java diff --git a/.github/workflows/publishing.yaml b/.github/workflows/publishing.yaml index 0f096c06..b99946dc 100644 --- a/.github/workflows/publishing.yaml +++ b/.github/workflows/publishing.yaml @@ -12,7 +12,7 @@ jobs: ONELITEFEATHER_MAVEN_PASSWORD: ${{ secrets.ONELITEFEATHER_MAVEN_PASSWORD }} steps: - name: Checkout repository - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Set up JDK 25 uses: actions/setup-java@v5 diff --git a/build.gradle.kts b/build.gradle.kts index 4b600334..1ebe9b1a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "net.theevilreaper" -version = "1.12.0" +version = "1.13.0" description = "Aves" java { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60c..f8e1ee31 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a35649f5..4eac4a84 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 151cd474..21b1ce7e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,7 +21,7 @@ dependencyResolutionManagement { } versionCatalogs { create("libs") { - version("bom", "1.5.0") + version("bom", "1.6.0") library("mycelium.bom", "net.onelitefeather", "mycelium-bom").versionRef("bom") library("minestom","net.minestom", "minestom").withoutVersion() library("adventure", "net.kyori", "adventure-text-minimessage").withoutVersion() diff --git a/src/main/java/net/theevilreaper/aves/file/FileHandler.java b/src/main/java/net/theevilreaper/aves/file/FileHandler.java index 10c28616..76ad88d5 100644 --- a/src/main/java/net/theevilreaper/aves/file/FileHandler.java +++ b/src/main/java/net/theevilreaper/aves/file/FileHandler.java @@ -1,6 +1,5 @@ package net.theevilreaper.aves.file; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,7 +36,7 @@ public interface FileHandler { * @param object The object to save * @param A generic type for the object value */ - void save(@NotNull Path path, @NotNull T object); + void save(Path path, T object); /** * Load a given file and parse to the give class. @@ -47,5 +46,5 @@ public interface FileHandler { * @param is generic type for the object value * @return a {@link Optional} with the object instance */ - Optional load(@NotNull Path path, @NotNull Class clazz); + Optional load(Path path, Class clazz); } \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/file/GsonFileHandler.java b/src/main/java/net/theevilreaper/aves/file/GsonFileHandler.java index 37e1f0a0..c65504c1 100644 --- a/src/main/java/net/theevilreaper/aves/file/GsonFileHandler.java +++ b/src/main/java/net/theevilreaper/aves/file/GsonFileHandler.java @@ -3,7 +3,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import net.minestom.server.utils.validate.Check; -import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.nio.file.Files; @@ -33,7 +32,7 @@ public GsonFileHandler() { * Creates a new instance from the file handler. * @param gson the gson instance to deserialize or serialize data */ - public GsonFileHandler(@NotNull Gson gson) { + public GsonFileHandler(Gson gson) { this.gson = gson; } @@ -44,7 +43,7 @@ public GsonFileHandler(@NotNull Gson gson) { * @param A generic type for the object value */ @Override - public void save(@NotNull Path path, @NotNull T object) { + public void save(Path path, T object) { Check.argCondition(Files.isDirectory(path), "Unable to save a directory. Please check the used path"); try (var outputStream = Files.newBufferedWriter(path, UTF_8)) { if (!Files.exists(path)) { @@ -65,7 +64,7 @@ public void save(@NotNull Path path, @NotNull T object) { * @return a {@link Optional} with the object instance */ @Override - public Optional load(@NotNull Path path, @NotNull Class clazz) { + public Optional load(Path path, Class clazz) { Check.argCondition(Files.isDirectory(path), "Unable to load a directory. Please check the used path"); if (!Files.exists(path)) { return Optional.empty(); diff --git a/src/main/java/net/theevilreaper/aves/file/ModernFileHandler.java b/src/main/java/net/theevilreaper/aves/file/ModernFileHandler.java index 7157ae1f..2b2628e5 100644 --- a/src/main/java/net/theevilreaper/aves/file/ModernFileHandler.java +++ b/src/main/java/net/theevilreaper/aves/file/ModernFileHandler.java @@ -1,7 +1,6 @@ package net.theevilreaper.aves.file; import com.google.gson.reflect.TypeToken; -import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +10,8 @@ import java.util.Optional; /** - * The class represents the base logic to load or save json files. + * The class represents the base logic to load or save JSON files. + * * @author theEvilReaper * @version 1.0.0 * @since 1.9.0 @@ -24,19 +24,21 @@ public interface ModernFileHandler { /** * Saves a given object into a file. - * @param path The path where the file is located - * @param object The object to save + * + * @param path The path where the file is located + * @param object The object to save * @param typeToken the type token to serialize the object - * @param A generic type for the object value + * @param A generic type for the object value */ - void save(@NotNull Path path, @NotNull T object, @NotNull TypeToken typeToken); + void save(Path path, T object, TypeToken typeToken); /** * Load a given file and parse to the give class. - * @param path is the where the file is located + * + * @param path is the where the file is located * @param typeToken the type token to deserialize the object - * @param is generic type for the object value + * @param is generic type for the object value * @return a {@link Optional} with the object instance */ - Optional load(@NotNull Path path, @NotNull TypeToken typeToken); + Optional load(Path path, TypeToken typeToken); } \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/file/ModernGsonFileHandler.java b/src/main/java/net/theevilreaper/aves/file/ModernGsonFileHandler.java index 1dc826f6..a08367fb 100644 --- a/src/main/java/net/theevilreaper/aves/file/ModernGsonFileHandler.java +++ b/src/main/java/net/theevilreaper/aves/file/ModernGsonFileHandler.java @@ -3,7 +3,6 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import net.minestom.server.utils.validate.Check; -import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.nio.file.Files; @@ -31,7 +30,7 @@ public ModernGsonFileHandler() { * Creates a new instance from the file handler. * @param gson the gson instance to deserialize or serialize data */ - public ModernGsonFileHandler(@NotNull Gson gson) { + public ModernGsonFileHandler(Gson gson) { this.gson = gson; } @@ -42,7 +41,7 @@ public ModernGsonFileHandler(@NotNull Gson gson) { * @param A generic type for the object value */ @Override - public void save(@NotNull Path path, @NotNull T object, @NotNull TypeToken typeToken) { + public void save(Path path, T object, TypeToken typeToken) { Check.argCondition(Files.isDirectory(path), "Unable to save a directory. Please check the used path"); try (var outputStream = Files.newBufferedWriter(path, UTF_8)) { if (!Files.exists(path)) { @@ -63,7 +62,7 @@ public void save(@NotNull Path path, @NotNull T object, @NotNull TypeToken Optional load(@NotNull Path path, @NotNull TypeToken typeToken) { + public Optional load(Path path, TypeToken typeToken) { Check.argCondition(Files.isDirectory(path), "Unable to load a directory. Please check the used path"); if (!Files.exists(path)) { return Optional.empty(); diff --git a/src/main/java/net/theevilreaper/aves/file/gson/ItemStackGsonTypeAdapter.java b/src/main/java/net/theevilreaper/aves/file/gson/ItemStackGsonTypeAdapter.java index d0c14105..74457d4a 100644 --- a/src/main/java/net/theevilreaper/aves/file/gson/ItemStackGsonTypeAdapter.java +++ b/src/main/java/net/theevilreaper/aves/file/gson/ItemStackGsonTypeAdapter.java @@ -14,7 +14,6 @@ import net.minestom.server.item.Material; import net.minestom.server.item.component.CustomModelData; import net.minestom.server.item.component.TooltipDisplay; -import org.jetbrains.annotations.NotNull; import java.lang.reflect.Type; @@ -30,7 +29,7 @@ public non-sealed class ItemStackGsonTypeAdapter implements JsonSerializer loreLines = stack.get(DataComponents.LORE); @@ -75,7 +74,7 @@ default void serializeLore(@NotNull ItemStack stack, @NotNull JsonObject jsonObj * @param object the object to deserialize the data * @return the builder with the lore set */ - default @NotNull ItemStack.Builder deserializeLore(@NotNull ItemStack.Builder builder, @NotNull JsonObject object) { + default ItemStack.Builder deserializeLore(ItemStack.Builder builder, JsonObject object) { if (!object.has(LORE_KEY)) return builder; JsonArray loreArray = object.getAsJsonArray(LORE_KEY); @@ -92,7 +91,7 @@ default void serializeLore(@NotNull ItemStack stack, @NotNull JsonObject jsonObj * @param stack the stack to serialize * @param object the object to serialize the data */ - default void serializeEnchantments(@NotNull ItemStack stack, @NotNull JsonObject object) { + default void serializeEnchantments(ItemStack stack, JsonObject object) { if (!stack.has(DataComponents.ENCHANTMENTS)) return; JsonArray enchantsArray = new JsonArray(); final EnchantmentList enchantmentList = stack.get(DataComponents.ENCHANTMENTS); @@ -115,7 +114,7 @@ default void serializeEnchantments(@NotNull ItemStack stack, @NotNull JsonObject * @param object the object to deserialize the data * @return the builder with the enchantments set */ - default @NotNull ItemStack.Builder deserializeEnchantments(@NotNull ItemStack.Builder builder, @NotNull JsonObject object) { + default ItemStack.Builder deserializeEnchantments(ItemStack.Builder builder, JsonObject object) { if (!object.has(ENCHANTMENTS)) return builder; JsonArray enchantsArray = object.getAsJsonArray(ENCHANTMENTS); Map, Integer> enchantments = new HashMap<>(); diff --git a/src/main/java/net/theevilreaper/aves/file/gson/KeyGsonAdapter.java b/src/main/java/net/theevilreaper/aves/file/gson/KeyGsonAdapter.java index fe1131ae..95cc7e7b 100644 --- a/src/main/java/net/theevilreaper/aves/file/gson/KeyGsonAdapter.java +++ b/src/main/java/net/theevilreaper/aves/file/gson/KeyGsonAdapter.java @@ -5,7 +5,6 @@ import com.google.gson.stream.JsonWriter; import net.kyori.adventure.key.Key; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.function.BiFunction; @@ -36,7 +35,7 @@ public class KeyGsonAdapter extends TypeAdapter { private final BiFunction createKeyObject; - private KeyGsonAdapter(@NotNull BiFunction createKeyObject) { + private KeyGsonAdapter(BiFunction createKeyObject) { this.createKeyObject = createKeyObject; } @@ -49,7 +48,7 @@ private KeyGsonAdapter() { * @return the new instance of the {@link KeyGsonAdapter} */ @Contract(value = " -> new", pure = true) - public static @NotNull KeyGsonAdapter create() { + public static KeyGsonAdapter create() { return new KeyGsonAdapter(); } @@ -59,7 +58,7 @@ private KeyGsonAdapter() { * @return the new instance of the {@link KeyGsonAdapter} */ @Contract(value = "_ -> new", pure = true) - public static @NotNull KeyGsonAdapter create(@NotNull BiFunction createKeyObject) { + public static KeyGsonAdapter create(BiFunction createKeyObject) { return new KeyGsonAdapter(createKeyObject); } @@ -67,15 +66,12 @@ private KeyGsonAdapter() { * Creates a new instance of the {@link KeyGsonAdapter} with a custom key) creation function for Minestom. * @return the new instance of the {@link KeyGsonAdapter} */ - public static @NotNull KeyGsonAdapter createMinestom() { + public static KeyGsonAdapter createMinestom() { return new KeyGsonAdapter(Key::key); } @Override public void write(JsonWriter out, Key value) throws IOException { - if (value == null) { - return; - } out.beginObject(); out.name("namespace").value(value.namespace()); out.name("value").value(value.value()); diff --git a/src/main/java/net/theevilreaper/aves/file/gson/MiniMessageComponentGsonAdapter.java b/src/main/java/net/theevilreaper/aves/file/gson/MiniMessageComponentGsonAdapter.java index 2635180f..eaaf14da 100644 --- a/src/main/java/net/theevilreaper/aves/file/gson/MiniMessageComponentGsonAdapter.java +++ b/src/main/java/net/theevilreaper/aves/file/gson/MiniMessageComponentGsonAdapter.java @@ -6,7 +6,6 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -36,15 +35,12 @@ public class MiniMessageComponentGsonAdapter extends TypeAdapter { * @return the new instance of the {@link MiniMessageComponentGsonAdapter} */ @Contract(value = " -> new", pure = true) - public static @NotNull MiniMessageComponentGsonAdapter create() { + public static MiniMessageComponentGsonAdapter create() { return new MiniMessageComponentGsonAdapter(); } @Override public void write(JsonWriter out, Component value) throws IOException { - if (value == null) { - return; - } out.beginObject(); out.name("minimessage").value(MiniMessage.miniMessage().serialize(value)); out.endObject(); diff --git a/src/main/java/net/theevilreaper/aves/file/gson/PositionGsonAdapter.java b/src/main/java/net/theevilreaper/aves/file/gson/PositionGsonAdapter.java index 156ecad6..ea9e60a9 100644 --- a/src/main/java/net/theevilreaper/aves/file/gson/PositionGsonAdapter.java +++ b/src/main/java/net/theevilreaper/aves/file/gson/PositionGsonAdapter.java @@ -10,7 +10,6 @@ import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Pos; import net.minestom.server.coordinate.Vec; -import org.jetbrains.annotations.NotNull; import java.lang.reflect.Type; @@ -27,7 +26,7 @@ public class PositionGsonAdapter implements JsonSerializer, JsonDeseriali private static final String PITCH = "pitch"; @Override - public Point deserialize(@NotNull JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + public Point deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject object = json.getAsJsonObject(); double x = object.get("x").getAsDouble(); double y = object.get("y").getAsDouble(); @@ -43,7 +42,7 @@ public Point deserialize(@NotNull JsonElement json, Type typeOfT, JsonDeserializ } @Override - public JsonElement serialize(@NotNull Point src, Type typeOfSrc, JsonSerializationContext context) { + public JsonElement serialize(Point src, Type typeOfSrc, JsonSerializationContext context) { JsonObject object = new JsonObject(); object.addProperty("x", src.x()); object.addProperty("y", src.y()); diff --git a/src/main/java/net/theevilreaper/aves/file/gson/UUIDGsonAdapter.java b/src/main/java/net/theevilreaper/aves/file/gson/UUIDGsonAdapter.java index 5e8cdf6d..f28542be 100644 --- a/src/main/java/net/theevilreaper/aves/file/gson/UUIDGsonAdapter.java +++ b/src/main/java/net/theevilreaper/aves/file/gson/UUIDGsonAdapter.java @@ -3,7 +3,6 @@ import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -28,7 +27,7 @@ public final class UUIDGsonAdapter extends TypeAdapter { * @throws IOException if an error occurs during the writing process */ @Override - public void write(@NotNull JsonWriter jsonWriter, @Nullable UUID uuid) throws IOException { + public void write(JsonWriter jsonWriter, @Nullable UUID uuid) throws IOException { if (uuid == null) return; jsonWriter.beginObject(); jsonWriter.name("mostSigBits").value(uuid.getMostSignificantBits()); @@ -44,7 +43,7 @@ public void write(@NotNull JsonWriter jsonWriter, @Nullable UUID uuid) throws IO * @throws IOException if an error occurs during the reading process */ @Override - public @NotNull UUID read(@NotNull JsonReader jsonReader) throws IOException { + public UUID read(JsonReader jsonReader) throws IOException { jsonReader.beginObject(); if (!jsonReader.nextName().equals("mostSigBits")) { throw new IOException("Expected mostSigBits"); diff --git a/src/main/java/net/theevilreaper/aves/file/gson/package-info.java b/src/main/java/net/theevilreaper/aves/file/gson/package-info.java new file mode 100644 index 00000000..f10f4726 --- /dev/null +++ b/src/main/java/net/theevilreaper/aves/file/gson/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package net.theevilreaper.aves.file.gson; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/file/package-info.java b/src/main/java/net/theevilreaper/aves/file/package-info.java new file mode 100644 index 00000000..98d319a8 --- /dev/null +++ b/src/main/java/net/theevilreaper/aves/file/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package net.theevilreaper.aves.file; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/util/Broadcaster.java b/src/main/java/net/theevilreaper/aves/util/Broadcaster.java index 6da72977..3b0906e2 100644 --- a/src/main/java/net/theevilreaper/aves/util/Broadcaster.java +++ b/src/main/java/net/theevilreaper/aves/util/Broadcaster.java @@ -5,7 +5,6 @@ import net.minestom.server.entity.Player; import net.minestom.server.instance.Instance; import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -24,7 +23,7 @@ private Broadcaster() {} * @param component The message to send */ @ApiStatus.Experimental - public static void broadcast(@NotNull Component component) { + public static void broadcast(Component component) { broadcast(MinecraftServer.getConnectionManager().getOnlinePlayers(), component); } @@ -34,7 +33,7 @@ public static void broadcast(@NotNull Component component) { * @param message The message to send */ @ApiStatus.Experimental - public static void broadcast(@NotNull Instance instance, @NotNull Component message) { + public static void broadcast(Instance instance, Component message) { broadcast(instance.getPlayers(), message); } @@ -44,7 +43,7 @@ public static void broadcast(@NotNull Instance instance, @NotNull Component mess * @param message The message to send */ @ApiStatus.Experimental - public static void broadcast(@NotNull Collection players, @NotNull Component message) { + public static void broadcast(Collection players, Component message) { if (players.isEmpty()) return; for (Player player : players) { diff --git a/src/main/java/net/theevilreaper/aves/util/Components.java b/src/main/java/net/theevilreaper/aves/util/Components.java index 2db216f5..cdd50779 100644 --- a/src/main/java/net/theevilreaper/aves/util/Components.java +++ b/src/main/java/net/theevilreaper/aves/util/Components.java @@ -9,7 +9,6 @@ import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.UnmodifiableView; import java.text.DecimalFormat; @@ -52,12 +51,12 @@ private Components() { * @return the progressbar as a {@link Component} */ @Contract(pure = true) - public static @NotNull Component getProgressBar(int current, + public static Component getProgressBar(int current, int max, int totalBars, - @NotNull String symbol, - @NotNull TextColor completedColor, - @NotNull TextColor notCompletedColor) { + String symbol, + TextColor completedColor, + TextColor notCompletedColor) { float percent = (float) current / max; int progressBars = (int) (totalBars * percent); String completedCharAsString = symbol.repeat(progressBars); @@ -74,9 +73,9 @@ private Components() { * @return the converted health as string */ @Contract(value = "_, _, _ -> new ", pure = true) - public static @NotNull Component getHealthString(double paramHealth, - @NotNull TextColor remainingHearth, - @NotNull TextColor goneHearth) { + public static Component getHealthString(double paramHealth, + TextColor remainingHearth, + TextColor goneHearth) { int health = (int) Math.round(paramHealth); health /= 2; int healthAway = 10 - health; @@ -97,7 +96,7 @@ private Components() { * @return the converted health as string */ @Contract(value = "_ -> new", pure = true) - public static @NotNull Component getHealthString(double paramHealth) { + public static Component getHealthString(double paramHealth) { return getHealthString(paramHealth, FILLED_HEART, EMPTY_HEARTS); } @@ -110,7 +109,7 @@ private Components() { * @return the textual representation mapped as {@link Component} */ @Contract(value = "_ -> new", pure = true) - public static @NotNull Component convertPoint(@NotNull T pos) { + public static Component convertPoint(T pos) { return convert(pos, JoinConfiguration.arrayLike()); } @@ -123,7 +122,7 @@ private Components() { * @return the textual representation mapped as {@link Component} */ @Contract(value = "_, _ -> new", pure = true) - public static @NotNull Component convertPoint(@NotNull T pos, @NotNull JoinConfiguration joinConfiguration) { + public static Component convertPoint(T pos, JoinConfiguration joinConfiguration) { return convert(pos, joinConfiguration); } @@ -136,7 +135,7 @@ private Components() { * @return the textual representation mapped as {@link Component} */ @Contract(value = "_, _ -> new", pure = true) - public static @NotNull Component convertPoint(@NotNull T pos, @NotNull JoinConfiguration.Builder configurationBuilder) { + public static Component convertPoint(T pos, JoinConfiguration.Builder configurationBuilder) { return convert(pos, configurationBuilder.build()); } @@ -149,7 +148,7 @@ private Components() { * @return the textual representation mapped as {@link Component} */ @Contract(value = "_, _ -> new", pure = true) - private static @NotNull Component convert(@NotNull T point, @NotNull JoinConfiguration joinConfiguration) { + private static Component convert(T point, JoinConfiguration joinConfiguration) { final boolean isPos = point instanceof Pos; Component[] data = new Component[isPos ? 5 : 3]; data[0] = Component.text("x:").append(Component.space()).append(Component.text(point.blockX())); @@ -175,10 +174,10 @@ private Components() { * @return the list of components */ @Contract(value = "_, _, _-> new", pure = true) - public static @NotNull @UnmodifiableView List<@NotNull Component> pointToLore( - @NotNull MiniMessage miniMessage, - @NotNull T point, - @NotNull DecimalFormat format + public static @UnmodifiableView List pointToLore( + MiniMessage miniMessage, + T point, + DecimalFormat format ) { final List loreComponents = new ArrayList<>(); loreComponents.add(miniMessage.deserialize("X: " + format.format(point.x()))); @@ -201,10 +200,10 @@ private Components() { * @return the list of components */ @Contract(value = "_, _, _ -> new", pure = true) - public static @NotNull List<@NotNull Component> pointToLore( - @NotNull T point, - @NotNull DecimalFormat format, - @NotNull List partArguments + public static List pointToLore( + T point, + DecimalFormat format, + List partArguments ) { final int maxSize = point instanceof Pos ? 5 : 3; if (partArguments.size() != maxSize) { diff --git a/src/main/java/net/theevilreaper/aves/util/Futures.java b/src/main/java/net/theevilreaper/aves/util/Futures.java index ecdfe41f..fc26734b 100644 --- a/src/main/java/net/theevilreaper/aves/util/Futures.java +++ b/src/main/java/net/theevilreaper/aves/util/Futures.java @@ -1,7 +1,5 @@ package net.theevilreaper.aves.util; -import org.jetbrains.annotations.NotNull; - import java.time.Duration; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CountDownLatch; @@ -33,7 +31,7 @@ private Futures() { * * @return the new CompletionStage */ - public static CompletableFuture thenRunOrTimeout(@NotNull CompletableFuture future, @NotNull Duration timeout, Consumer action) { + public static CompletableFuture thenRunOrTimeout(CompletableFuture future, Duration timeout, Consumer action) { final CompletableFuture f = new CompletableFuture<>(); CompletableFuture.delayedExecutor(timeout.toNanos(), TimeUnit.NANOSECONDS).execute(() -> f.complete(true)); future.thenRun(() -> f.complete(false)); @@ -46,7 +44,7 @@ public static CompletableFuture thenRunOrTimeout(@NotNull CompletableFutur * @param countDownLatch the countdown latch to wait for * @return a future that completes when the countdown reaches zero */ - public static @NotNull CompletableFuture futureFromCountdown(@NotNull CountDownLatch countDownLatch) { + public static CompletableFuture futureFromCountdown(CountDownLatch countDownLatch) { final CompletableFuture future = new CompletableFuture<>(); CompletableFuture.runAsync(() -> { try { diff --git a/src/main/java/net/theevilreaper/aves/util/Items.java b/src/main/java/net/theevilreaper/aves/util/Items.java index e6547e01..3302b19b 100644 --- a/src/main/java/net/theevilreaper/aves/util/Items.java +++ b/src/main/java/net/theevilreaper/aves/util/Items.java @@ -2,7 +2,6 @@ import net.minestom.server.entity.Player; import net.minestom.server.item.ItemStack; -import org.jetbrains.annotations.NotNull; /** * The class contains some methods to work with {@link ItemStack}. @@ -22,7 +21,7 @@ private Items() {} * @param item The item to check * @return The amount of the given item but returns with zero when the item does not occur in the inventory */ - public static int getAmountFromItem(@NotNull Player player, @NotNull ItemStack item) { + public static int getAmountFromItem(Player player, ItemStack item) { int amount = 0; if (player.getInventory().getItemStacks().length != 0) { for (int i = 0; i < player.getInventory().getItemStacks().length; i++) { @@ -39,7 +38,7 @@ public static int getAmountFromItem(@NotNull Player player, @NotNull ItemStack i * @param player The player from which the remaining place should be determined * @return The amount of free space */ - public static int getFreeSpace(@NotNull Player player) { + public static int getFreeSpace(Player player) { int spaceCount = 0; for (int i = 0; i < player.getInventory().getSize(); i++) { var currentStack = player.getInventory().getItemStacks()[i]; diff --git a/src/main/java/net/theevilreaper/aves/util/Players.java b/src/main/java/net/theevilreaper/aves/util/Players.java index 1c71fe1a..35717225 100644 --- a/src/main/java/net/theevilreaper/aves/util/Players.java +++ b/src/main/java/net/theevilreaper/aves/util/Players.java @@ -40,7 +40,7 @@ public final class Players { private static final Logger PLAYER_LOGGER = LoggerFactory.getLogger(Players.class); private static Duration itemDuration = Duration.ofMillis(3); - private static ItemPlacer placer; + private static @Nullable ItemPlacer placer; private Players() { } @@ -50,7 +50,7 @@ private Players() { * * @param duration the duration to set */ - public static void setItemDuration(@NotNull Duration duration) { + public static void setItemDuration(Duration duration) { itemDuration = duration; } @@ -59,7 +59,7 @@ public static void setItemDuration(@NotNull Duration duration) { * * @param itemPlacer the new instance to set */ - public static void setItemPlacer(@NotNull ItemPlacer itemPlacer) { + public static void setItemPlacer(ItemPlacer itemPlacer) { placer = itemPlacer; } @@ -73,7 +73,7 @@ public static void setItemPlacer(@NotNull ItemPlacer itemPlacer) { * @param stay the time how long the title stays * @param fadeOut the time to fade out */ - public static void showTitle(@NotNull Player player, @NotNull Component title, @NotNull Component subTitle, int fadeIn, int stay, int fadeOut) { + public static void showTitle(Player player, Component title, Component subTitle, int fadeIn, int stay, int fadeOut) { player.showTitle(Title.title(title, subTitle, Title.Times.times(Ticks.duration(fadeIn), Ticks.duration(stay), Ticks.duration(fadeOut)))); } @@ -82,7 +82,7 @@ public static void showTitle(@NotNull Player player, @NotNull Component title, @ * * @param player The player from which the inventory should be dropped */ - public static void dropPlayerInventory(@NotNull Player player) { + public static void dropPlayerInventory(Player player) { Check.argCondition(player.getInstance() == null, "The instance from the player can't be null"); dropItemStacks(player.getInstance(), player.getPosition(), player.getInventory().getItemStacks()); } @@ -94,7 +94,7 @@ public static void dropPlayerInventory(@NotNull Player player) { * @param pos the position where the items should be dropped * @param content the items stored in an array */ - public static void dropItemStacks(@NotNull Instance instance, @NotNull Pos pos, @NotNull ItemStack @NotNull ... content) { + public static void dropItemStacks(Instance instance, Pos pos, ItemStack ... content) { Check.argCondition(content.length == 0, "The array can not be null or empty"); for (int i = 0; i < content.length; i++) { if (content[i] == null) continue; @@ -138,7 +138,7 @@ public static Optional getRandomPlayer() { * @param locale The {@link Locale} for {@link TranslatedItem} * @param shiftedSlots An array with contains shifted layout only for the hotbar */ - public static void updateHotBar(@NotNull Player player, @NotNull IItem[] hotBarItems, @Nullable Locale locale, int... shiftedSlots) { + public static void updateHotBar(Player player, IItem[] hotBarItems, @Nullable Locale locale, int... shiftedSlots) { Check.argCondition(hotBarItems.length > InventoryConstants.INVENTORY_WIDTH, "The array length for the items is greater than " + InventoryConstants.INVENTORY_WIDTH); Check.argCondition(shiftedSlots.length > hotBarItems.length, "The length from shiftedSlots has not the same length with the underlying array"); if (placer == null) { @@ -156,7 +156,7 @@ public static void updateHotBar(@NotNull Player player, @NotNull IItem[] hotBarI * @param armorItems The array with the items for the armor area * @param locale The {@link Locale} for {@link TranslatedItem} */ - public static void updateArmorItems(@NotNull Player player, @NotNull IItem[] armorItems, @Nullable Locale locale) { + public static void updateArmorItems(Player player, IItem[] armorItems, @Nullable Locale locale) { if (placer == null) { placer = ItemPlacer.FALLBACK; PLAYER_LOGGER.info("Set `ItemPlacer Interface` to fallback implementation"); @@ -172,7 +172,7 @@ public static void updateArmorItems(@NotNull Player player, @NotNull IItem[] arm * @param locale the locale if the case need some * @param shiftedSlots an array which contains shifted slots */ - private static void setItems(@NotNull Player player, @NotNull IItem[] items, Locale locale, int... shiftedSlots) { + private static void setItems(Player player, IItem[] items, Locale locale, int... shiftedSlots) { for (int i = 0; i < items.length; i++) { var wrappedItem = items[i]; if (wrappedItem == null) continue; @@ -187,7 +187,7 @@ private static void setItems(@NotNull Player player, @NotNull IItem[] items, Loc * @param players A list which contains some player objects * @return a random player */ - public static Optional getRandomPlayer(@NotNull List players) { + public static Optional getRandomPlayer(List players) { if (players.isEmpty()) return Optional.empty(); return Optional.of(players.get(ThreadLocalRandom.current().nextInt(players.size()))); } @@ -199,7 +199,7 @@ public static Optional getRandomPlayer(@NotNull List players) { * @param itemStack the involved {@link ItemStack} * @param ticks how long the cooldown is */ - public static void sendCooldown(@NotNull Player player, @NotNull ItemStack itemStack, int ticks) { + public static void sendCooldown(Player player, ItemStack itemStack, int ticks) { sendCooldown(player, itemStack.material(), ticks); } @@ -210,7 +210,7 @@ public static void sendCooldown(@NotNull Player player, @NotNull ItemStack itemS * @param material the {@link Material} to get the id from it2 * @param ticks how long the cooldown is */ - public static void sendCooldown(@NotNull Player player, @NotNull Material material, int ticks) { + public static void sendCooldown(Player player, Material material, int ticks) { player.sendPacket(new SetCooldownPacket(material.name(), ticks)); } } \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/util/Positions.java b/src/main/java/net/theevilreaper/aves/util/Positions.java index 3544229b..f02fb1e1 100644 --- a/src/main/java/net/theevilreaper/aves/util/Positions.java +++ b/src/main/java/net/theevilreaper/aves/util/Positions.java @@ -3,7 +3,6 @@ import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; /** * Includes some helpful methods for the {@link Pos} and {@link net.minestom.server.coordinate.Vec} from minestom. @@ -35,7 +34,7 @@ public static float getYaw(double dX, double dZ) { * @return the centered pos */ @Contract(pure = true) - public static @NotNull Pos centerPos3D(@NotNull Pos pos) { + public static Pos centerPos3D(Pos pos) { return pos.add(0.5, 0.5, 0.5); } @@ -46,7 +45,7 @@ public static float getYaw(double dX, double dZ) { * @return the centered pos */ @Contract(pure = true) - public static @NotNull Pos centerPos2D(@NotNull Pos pos) { + public static Pos centerPos2D(Pos pos) { return pos.add(0.5, 0, 0.5); } @@ -56,7 +55,7 @@ public static float getYaw(double dX, double dZ) { * @param pos The position to calculate the length from * @return the squared length of the position */ - public static double lengthSquaredPos(@NotNull Point pos) { + public static double lengthSquaredPos(Point pos) { return Math.pow(pos.x(), 2) + Math.pow(pos.y(), 2) + Math.pow(pos.z(), 2); } } diff --git a/src/main/java/net/theevilreaper/aves/util/Strings.java b/src/main/java/net/theevilreaper/aves/util/Strings.java index 1a635e42..c325fcdd 100644 --- a/src/main/java/net/theevilreaper/aves/util/Strings.java +++ b/src/main/java/net/theevilreaper/aves/util/Strings.java @@ -1,7 +1,6 @@ package net.theevilreaper.aves.util; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import java.util.StringJoiner; @@ -33,7 +32,7 @@ private Strings() { * @return The centered text */ @Contract(value = "_, _ -> new", pure = true) - public static @NotNull String centerText(@NotNull String text, int lineLength) { + public static String centerText(String text, int lineLength) { text = text.trim(); if (text.isEmpty()) { throw new IllegalArgumentException("The text can not be empty"); @@ -57,7 +56,7 @@ private Strings() { * @return the converted time */ @Contract(pure = true) - public static @NotNull String getTimeString(@NotNull TimeFormat timeFormat, int time) { + public static String getTimeString(TimeFormat timeFormat, int time) { if (time <= 0) { return timeFormat.getDefaultFormat(); } diff --git a/src/main/java/net/theevilreaper/aves/util/TimeFormat.java b/src/main/java/net/theevilreaper/aves/util/TimeFormat.java index 8242c92c..135731d0 100644 --- a/src/main/java/net/theevilreaper/aves/util/TimeFormat.java +++ b/src/main/java/net/theevilreaper/aves/util/TimeFormat.java @@ -1,10 +1,8 @@ package net.theevilreaper.aves.util; -import org.jetbrains.annotations.NotNull; - /** - * The enum contains all formats which are supported by the {@link Strings#getTimeString(TimeFormat, int)} method. - * Each enum entry contains a default format which contains the format for the timestamp zero. + * The enum contains all formats that are supported by the {@link Strings#getTimeString(TimeFormat, int)} method. + * Each enum entry contains a default format which contains the format for timestamp zero. * * @author theEvilReaper * @version 1.0.0 @@ -28,7 +26,7 @@ public enum TimeFormat { * * @param defaultFormat the format to set */ - TimeFormat(@NotNull String defaultFormat) { + TimeFormat(String defaultFormat) { this.defaultFormat = defaultFormat; } @@ -37,7 +35,7 @@ public enum TimeFormat { * * @return the given format */ - public @NotNull String getDefaultFormat() { + public String getDefaultFormat() { return defaultFormat; } } diff --git a/src/main/java/net/theevilreaper/aves/util/Vectors.java b/src/main/java/net/theevilreaper/aves/util/Vectors.java index 21830121..7faf6c4a 100644 --- a/src/main/java/net/theevilreaper/aves/util/Vectors.java +++ b/src/main/java/net/theevilreaper/aves/util/Vectors.java @@ -3,7 +3,6 @@ import net.minestom.server.coordinate.Pos; import net.minestom.server.coordinate.Vec; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; import java.security.SecureRandom; @@ -27,7 +26,7 @@ private Vectors() { * @return a new vector with random values */ @Contract(pure = true) - public static @NotNull Vec getRandomVector() { + public static Vec getRandomVector() { double x = random.nextDouble() * 2.0D - 1.0D; double y = random.nextDouble() * 2.0D - 1.0D; double z = random.nextDouble() * 2.0D - 1.0D; @@ -41,7 +40,7 @@ private Vectors() { * @return The forward vector */ @Contract("_ -> new") - public static @NotNull Vec getBackVector(@NotNull Pos location) { + public static Vec getBackVector(Pos location) { float newZ = (float) (location.z() + Math.sin(Math.toRadians(location.yaw() + 90.0F))); float newX = (float) (location.x() + Math.cos(Math.toRadians(location.yaw() + 90.0F))); return new Vec(newX - location.x(), 0.0D, newZ - location.z()); @@ -53,7 +52,7 @@ private Vectors() { * @return a new vector with random values */ @Contract(pure = true) - public static @NotNull Vec getRandomCircleVector() { + public static Vec getRandomCircleVector() { double rnd = random.nextDouble() * 2.0D * Math.PI; double x = Math.cos(rnd); double z = Math.sin(rnd); @@ -67,7 +66,7 @@ private Vectors() { * @param vector the vector for which to calculate the angle * @return the angle between the vector and the positive x-axis in radians */ - public static double angleToXAxis(@NotNull Vec vector) { + public static double angleToXAxis(Vec vector) { return Math.atan2(vector.x(), vector.y()); } } diff --git a/src/main/java/net/theevilreaper/aves/util/exception/ThrowingException.java b/src/main/java/net/theevilreaper/aves/util/exception/ThrowingException.java index 7fca30b8..8afc79b5 100644 --- a/src/main/java/net/theevilreaper/aves/util/exception/ThrowingException.java +++ b/src/main/java/net/theevilreaper/aves/util/exception/ThrowingException.java @@ -1,7 +1,6 @@ package net.theevilreaper.aves.util.exception; import net.theevilreaper.aves.util.functional.ThrowingFunction; -import org.jetbrains.annotations.NotNull; /** * The exception will be thrown by the {@link ThrowingFunction}. @@ -15,7 +14,7 @@ public class ThrowingException extends RuntimeException { * Creates a new instance from the exception with a given message. * @param message the message for the exception */ - public ThrowingException(@NotNull String message) { + public ThrowingException(String message) { super(message); } diff --git a/src/main/java/net/theevilreaper/aves/util/exception/package-info.java b/src/main/java/net/theevilreaper/aves/util/exception/package-info.java new file mode 100644 index 00000000..04f458c4 --- /dev/null +++ b/src/main/java/net/theevilreaper/aves/util/exception/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package net.theevilreaper.aves.util.exception; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/util/functional/BaseMapBiFunction.java b/src/main/java/net/theevilreaper/aves/util/functional/BaseMapBiFunction.java index 0aa32579..9e307c48 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/BaseMapBiFunction.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/BaseMapBiFunction.java @@ -45,7 +45,7 @@ public interface BaseMapBiFunction { * applies the {@code after} function * @throws NullPointerException if {@code after} is null */ - default BaseMapBiFunction andThen(Function after) { + default BaseMapBiFunction andThen(@Nullable Function after) { if (after == null) { throw new NullPointerException("After function must not be null"); } diff --git a/src/main/java/net/theevilreaper/aves/util/functional/ItemBiFunction.java b/src/main/java/net/theevilreaper/aves/util/functional/ItemBiFunction.java index b22fbfec..d7e5ade4 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/ItemBiFunction.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/ItemBiFunction.java @@ -3,7 +3,6 @@ import net.theevilreaper.aves.item.IItem; import org.jetbrains.annotations.Nullable; -import java.util.Objects; import java.util.function.Function; /** @@ -35,16 +34,15 @@ public interface ItemBiFunction { @Nullable R apply(@Nullable T item, @Nullable U u); /** - * Returns a composed function that first applies this function to its input, + * Returns a composed function that first applies this function to its input * and then applies the after function to the result. * - * @param the type of output of the after function, and of the composed function + * @param the type of output of the after function and of the composed function * @param after the function to apply after this function is applied * @return a composed function that first applies this function and then applies the after function * @throws NullPointerException if after is null */ default ItemBiFunction andThen(Function after) { - Objects.requireNonNull(after); return (T t, U v) -> after.apply(this.apply(t, v)); } } diff --git a/src/main/java/net/theevilreaper/aves/util/functional/ItemPlacer.java b/src/main/java/net/theevilreaper/aves/util/functional/ItemPlacer.java index 40f22546..5b152725 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/ItemPlacer.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/ItemPlacer.java @@ -5,7 +5,7 @@ import net.minestom.server.entity.EquipmentSlot; import net.minestom.server.entity.Player; import net.minestom.server.item.ItemStack; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Locale; @@ -49,7 +49,7 @@ public interface ItemPlacer { * @param item the itemStack itself * @param locale the locale for the itemStack, if the itemStack is a {@link TranslatedItem} it will be translated to the given locale */ - default void setItem(@NotNull Player player, int slotID, @NotNull IItem item, Locale locale) { + default void setItem(Player player, int slotID, IItem item, Locale locale) { this.setItem(player, slotID, item, locale, false); } @@ -62,5 +62,5 @@ default void setItem(@NotNull Player player, int slotID, @NotNull IItem item, Lo * @param locale the locale for the itemStack, if the itemStack is a {@link TranslatedItem} it will be translated to the given locale * @param armor if the item is an armor item or not */ - void setItem(@NotNull Player player, int slotID, @NotNull IItem item, Locale locale, boolean armor); + void setItem(Player player, int slotID, IItem item, @Nullable Locale locale, boolean armor); } diff --git a/src/main/java/net/theevilreaper/aves/util/functional/ItemStackBiFunction.java b/src/main/java/net/theevilreaper/aves/util/functional/ItemStackBiFunction.java index 45101a1c..7d23d4c7 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/ItemStackBiFunction.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/ItemStackBiFunction.java @@ -47,7 +47,7 @@ public interface ItemStackBiFunction { * applies the {@code after} function * @throws NullPointerException if {@code after} is null */ - default ItemStackBiFunction andThen(@NotNull Function after) { + default ItemStackBiFunction andThen(Function after) { return (ItemStack itemStack, U u) -> after.apply(apply(itemStack, u)); } } diff --git a/src/main/java/net/theevilreaper/aves/util/functional/ItemStackFunction.java b/src/main/java/net/theevilreaper/aves/util/functional/ItemStackFunction.java index bbf0ddfb..301a11f5 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/ItemStackFunction.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/ItemStackFunction.java @@ -1,7 +1,6 @@ package net.theevilreaper.aves.util.functional; import net.minestom.server.item.ItemStack; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.function.Function; @@ -43,7 +42,7 @@ public interface ItemStackFunction { * operation followed by the {@code after} operation * @throws NullPointerException if {@code after} is null */ - default ItemStackFunction andThen(@NotNull ItemStackFunction after) { + default ItemStackFunction andThen(ItemStackFunction after) { return itemStack -> { this.apply(itemStack); return after.apply(itemStack); diff --git a/src/main/java/net/theevilreaper/aves/util/functional/PathFilter.java b/src/main/java/net/theevilreaper/aves/util/functional/PathFilter.java index 59b5f7fe..fb2c8446 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/PathFilter.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/PathFilter.java @@ -1,7 +1,5 @@ package net.theevilreaper.aves.util.functional; -import org.jetbrains.annotations.NotNull; - import java.nio.file.Path; import java.util.List; import java.util.stream.Stream; @@ -24,5 +22,5 @@ public interface PathFilter { * @param stream the stream of map paths to filter * @return a list of filtered {@link T} objects */ - @NotNull List filter(@NotNull Stream stream); + List filter(Stream stream); } diff --git a/src/main/java/net/theevilreaper/aves/util/functional/PlayerConsumer.java b/src/main/java/net/theevilreaper/aves/util/functional/PlayerConsumer.java index 08d5f9a5..20958b91 100644 --- a/src/main/java/net/theevilreaper/aves/util/functional/PlayerConsumer.java +++ b/src/main/java/net/theevilreaper/aves/util/functional/PlayerConsumer.java @@ -1,7 +1,6 @@ package net.theevilreaper.aves.util.functional; import net.minestom.server.entity.Player; -import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; @@ -23,7 +22,7 @@ public interface PlayerConsumer { * * @param player the input argument */ - void accept(@NotNull Player player); + void accept(Player player); /** * Returns a composed {@code PlayerConsumer} that performs, in sequence, this @@ -36,7 +35,7 @@ public interface PlayerConsumer { * operation followed by the {@code after} operation * @throws NullPointerException if {@code after} is null */ - default PlayerConsumer andThen(@NotNull PlayerConsumer after) { + default PlayerConsumer andThen(PlayerConsumer after) { return (Player player) -> { accept(player); after.accept(player); diff --git a/src/main/java/net/theevilreaper/aves/util/functional/package-info.java b/src/main/java/net/theevilreaper/aves/util/functional/package-info.java new file mode 100644 index 00000000..48214ae3 --- /dev/null +++ b/src/main/java/net/theevilreaper/aves/util/functional/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package net.theevilreaper.aves.util.functional; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/util/package-info.java b/src/main/java/net/theevilreaper/aves/util/package-info.java new file mode 100644 index 00000000..951e87c0 --- /dev/null +++ b/src/main/java/net/theevilreaper/aves/util/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package net.theevilreaper.aves.util; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file diff --git a/src/main/java/net/theevilreaper/aves/util/vector/Vec2D.java b/src/main/java/net/theevilreaper/aves/util/vector/Vec2D.java index 22c2d275..e2998e4f 100644 --- a/src/main/java/net/theevilreaper/aves/util/vector/Vec2D.java +++ b/src/main/java/net/theevilreaper/aves/util/vector/Vec2D.java @@ -4,7 +4,6 @@ import net.minestom.server.coordinate.Vec; import net.minestom.server.utils.MathUtils; import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; /** * The {@link Vec2D} class represents a vector in a two-dimensional space with x and y coordinates. @@ -26,7 +25,7 @@ public record Vec2D(double x, double y) { * * @param pos The input pos */ - public Vec2D(@NotNull Pos pos) { + public Vec2D(Pos pos) { this(pos.blockX(), pos.blockZ()); } @@ -35,7 +34,7 @@ public Vec2D(@NotNull Pos pos) { * * @param vec The input vec */ - public Vec2D(@NotNull Vec vec) { + public Vec2D(Vec vec) { this(vec.blockX(), vec.blockZ()); } @@ -47,7 +46,7 @@ public Vec2D(@NotNull Vec vec) { * @return result vector */ @Contract("_, _ -> new") - public @NotNull Vec2D add(double x, double y) { + public Vec2D add(double x, double y) { return new Vec2D(this.x + x, this.y + y); } @@ -58,7 +57,7 @@ public Vec2D(@NotNull Vec vec) { * @return result vector */ @Contract("_ -> new") - public @NotNull Vec2D add(@NotNull Vec2D vector) { + public Vec2D add(Vec2D vector) { return new Vec2D(this.x + vector.x, this.y + vector.y); } @@ -70,7 +69,7 @@ public Vec2D(@NotNull Vec vec) { * @return result vector */ @Contract("_, _ -> new") - public @NotNull Vec2D sub(double x, double y) { + public Vec2D sub(double x, double y) { return new Vec2D(this.x - x, this.y - y); } @@ -81,7 +80,7 @@ public Vec2D(@NotNull Vec vec) { * @return result vector */ @Contract("_ -> new") - public @NotNull Vec2D sub(@NotNull Vec2D vector) { + public Vec2D sub(Vec2D vector) { return new Vec2D(this.x - vector.x, this.y - vector.y); } @@ -91,7 +90,7 @@ public Vec2D(@NotNull Vec vec) { * @return result vector */ @Contract(" -> new") - public @NotNull Vec2D neg() { + public Vec2D neg() { return new Vec2D(-x, -y); } @@ -102,7 +101,7 @@ public Vec2D(@NotNull Vec vec) { * @return result vector */ @Contract("_ -> new") - public @NotNull Vec2D scalarMul(int multiplier) { + public Vec2D scalarMul(int multiplier) { return new Vec2D(this.x * multiplier, this.y * multiplier); } diff --git a/src/main/java/net/theevilreaper/aves/util/vector/package-info.java b/src/main/java/net/theevilreaper/aves/util/vector/package-info.java new file mode 100644 index 00000000..7aa23be8 --- /dev/null +++ b/src/main/java/net/theevilreaper/aves/util/vector/package-info.java @@ -0,0 +1,4 @@ +@NotNullByDefault +package net.theevilreaper.aves.util.vector; + +import org.jetbrains.annotations.NotNullByDefault; \ No newline at end of file