From f27009216c21a3bbe009f0c80c6b20c3e372277e Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Tue, 21 Jun 2022 19:09:17 +0200 Subject: [PATCH] chore: Replace AnnotationHelper class (#3706) --- Bukkit/build.gradle.kts | 2 + .../plotsquared/bukkit/queue/GenChunk.java | 4 +- Core/build.gradle.kts | 2 + .../com/plotsquared/core/PlotPlatform.java | 4 +- .../core/generator/HybridPlotWorld.java | 8 +-- .../core/location/UncheckedWorldLocation.java | 8 +-- .../core/plot/flag/FlagContainer.java | 5 +- ...BlockArrayCacheScopedQueueCoordinator.java | 4 +- .../core/util/AnnotationHelper.java | 55 ------------------- .../core/util/EventDispatcher.java | 4 +- build.gradle.kts | 2 +- 11 files changed, 23 insertions(+), 75 deletions(-) delete mode 100644 Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java diff --git a/Bukkit/build.gradle.kts b/Bukkit/build.gradle.kts index f29140b42..958f4627a 100644 --- a/Bukkit/build.gradle.kts +++ b/Bukkit/build.gradle.kts @@ -50,6 +50,7 @@ dependencies { implementation(libs.arkitektonika) implementation(libs.http4j) implementation("com.intellectualsites.paster:Paster") + implementation("com.intellectualsites.informative-annotations:informative-annotations") // Adventure implementation("net.kyori:adventure-platform-bukkit") @@ -87,6 +88,7 @@ tasks.named("shadowJar") { relocate("javax.inject", "com.plotsquared.core.annotation.inject") relocate("net.jcip", "com.plotsquared.core.annotations.jcip") relocate("edu.umd.cs.findbugs", "com.plotsquared.core.annotations.findbugs") + relocate("com.intellectualsites.informative-annotations", "com.plotsquared.core.annotation.informative") // Get rid of all the libs which are 100% unused. minimize() diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java index 0b580cf48..44ec39545 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java @@ -19,12 +19,12 @@ package com.plotsquared.bukkit.queue; import com.google.common.base.Preconditions; +import com.intellectualsites.annotations.DoNotUse; import com.plotsquared.bukkit.util.BukkitBlockUtil; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.core.location.ChunkWrapper; import com.plotsquared.core.location.Location; import com.plotsquared.core.queue.ScopedQueueCoordinator; -import com.plotsquared.core.util.AnnotationHelper; import com.plotsquared.core.util.ChunkUtil; import com.plotsquared.core.util.PatternUtil; import com.sk89q.worldedit.bukkit.BukkitAdapter; @@ -44,7 +44,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Arrays; -@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") +@DoNotUse public class GenChunk extends ScopedQueueCoordinator { public final Biome[] biomes; diff --git a/Core/build.gradle.kts b/Core/build.gradle.kts index a9a7f02b1..284b5399b 100644 --- a/Core/build.gradle.kts +++ b/Core/build.gradle.kts @@ -43,6 +43,7 @@ dependencies { api(libs.cloudServices) api(libs.arkitektonika) api("com.intellectualsites.paster:Paster") + api("com.intellectualsites.informative-annotations:informative-annotations") } tasks.processResources { @@ -62,5 +63,6 @@ tasks { opt.links("https://jd.adventure.kyori.net/api/4.9.3/") opt.links("https://google.github.io/guice/api-docs/" + libs.guice.get().versionConstraint.toString() + "/javadoc/") opt.links("https://checkerframework.org/api/") + opt.links("https://javadoc.io/doc/com.intellectualsites.informative-annotations/informative-annotations/latest/") } } diff --git a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java index b107724a5..75ceef94d 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotPlatform.java +++ b/Core/src/main/java/com/plotsquared/core/PlotPlatform.java @@ -22,6 +22,7 @@ import cloud.commandframework.services.ServicePipeline; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.TypeLiteral; +import com.intellectualsites.annotations.DoNotUse; import com.plotsquared.core.backup.BackupManager; import com.plotsquared.core.configuration.caption.LocaleHolder; import com.plotsquared.core.generator.GeneratorWrapper; @@ -33,7 +34,6 @@ import com.plotsquared.core.permissions.PermissionHandler; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.AnnotationHelper; import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.PlatformWorldManager; @@ -308,7 +308,7 @@ public interface PlotPlatform

extends LocaleHolder { * @return worldedit implementations * @since 6.3.0 */ - @AnnotationHelper.ApiDescription(info = "Internal use only") + @DoNotUse @NonNull String worldEditImplementations(); /** diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java index 3c5b8686c..054410817 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotWorld.java @@ -20,6 +20,7 @@ package com.plotsquared.core.generator; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; +import com.intellectualsites.annotations.DoNotUse; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.Settings; @@ -33,7 +34,6 @@ import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.queue.GlobalBlockQueue; -import com.plotsquared.core.util.AnnotationHelper; import com.plotsquared.core.util.FileUtils; import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.SchematicHandler; @@ -531,7 +531,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { * * @since 6.9.0 */ - @AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") + @DoNotUse public @Nullable List getPlotSchematicEntities() { return schem3Entities; } @@ -541,7 +541,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { * * @since 6.9.0 */ - @AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") + @DoNotUse public @Nullable BlockVector3 getPlotSchematicMinPoint() { return schem3MinPoint; } @@ -551,7 +551,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { * * @since 6.9.0 */ - @AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") + @DoNotUse public boolean populationNeeded() { return schem1PopulationNeeded || schem2PopulationNeeded || schem3PopulationNeeded; } diff --git a/Core/src/main/java/com/plotsquared/core/location/UncheckedWorldLocation.java b/Core/src/main/java/com/plotsquared/core/location/UncheckedWorldLocation.java index baa0c5086..bdf58ef5d 100644 --- a/Core/src/main/java/com/plotsquared/core/location/UncheckedWorldLocation.java +++ b/Core/src/main/java/com/plotsquared/core/location/UncheckedWorldLocation.java @@ -18,7 +18,7 @@ */ package com.plotsquared.core.location; -import com.plotsquared.core.util.AnnotationHelper; +import com.intellectualsites.annotations.DoNotUse; import com.sk89q.worldedit.math.BlockVector3; import org.checkerframework.checker.nullness.qual.NonNull; @@ -28,7 +28,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; * * @since 6.9.0 */ -@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") +@DoNotUse public final class UncheckedWorldLocation extends Location { private final String worldName; @@ -54,7 +54,7 @@ public final class UncheckedWorldLocation extends Location { * * @since 6.9.0 */ - @AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") + @DoNotUse public static @NonNull UncheckedWorldLocation at( final @NonNull String world, final int x, final int y, final int z ) { @@ -62,7 +62,7 @@ public final class UncheckedWorldLocation extends Location { } @Override - @AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.") + @DoNotUse public @NonNull String getWorldName() { return this.worldName; } diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java index 265f5f2c8..37fda5dd2 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagContainer.java @@ -20,8 +20,8 @@ package com.plotsquared.core.plot.flag; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; +import com.intellectualsites.annotations.NotPublic; import com.plotsquared.core.configuration.caption.CaptionUtility; -import com.plotsquared.core.util.AnnotationHelper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.checkerframework.checker.nullness.qual.NonNull; @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Map; -import java.util.Objects; /** * Container type for {@link PlotFlag plot flags}. @@ -353,7 +352,7 @@ public class FlagContainer { * @return a new Runnable that cleans up once the FlagContainer isn't needed anymore. * @since 6.0.10 */ - @AnnotationHelper.ApiDescription(info = "This method should not be considered as public or API.") + @NotPublic public Runnable createCleanupHook() { return () -> GlobalFlagContainer.getInstance().unsubscribe(unknownsRef); } diff --git a/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java index a57f2c389..243f5637f 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java @@ -18,8 +18,8 @@ */ package com.plotsquared.core.queue; +import com.intellectualsites.annotations.DoNotUse; import com.plotsquared.core.location.Location; -import com.plotsquared.core.util.AnnotationHelper; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector3; @@ -37,7 +37,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; * in {@link BlockArrayCacheScopedQueueCoordinator#setOffsetX(int)} and * {@link BlockArrayCacheScopedQueueCoordinator#setOffsetZ(int)} */ -@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to change at any time and created for specific use cases.") +@DoNotUse public class BlockArrayCacheScopedQueueCoordinator extends ScopedQueueCoordinator { private final BlockState[][][] blockStates; diff --git a/Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java b/Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java deleted file mode 100644 index bb8d69664..000000000 --- a/Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * PlotSquared, a land and world management plugin for Minecraft. - * Copyright (C) IntellectualSites - * Copyright (C) IntellectualSites team and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.plotsquared.core.util; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.MODULE; -import static java.lang.annotation.ElementType.PACKAGE; -import static java.lang.annotation.ElementType.RECORD_COMPONENT; -import static java.lang.annotation.ElementType.TYPE; - -/** - * @since 6.2.2 - */ -@AnnotationHelper.ApiDescription(info = "An internal class for custom annotations." + - "This is in no form part of the API and is subject to change at any time.") -public final class AnnotationHelper { - - private AnnotationHelper() { - } - - @Documented - @Retention(RetentionPolicy.CLASS) - @Target(value = {METHOD, PACKAGE, MODULE, RECORD_COMPONENT, TYPE}) - public @interface ApiDescription { - /** - * Returns additional information how to use a class for the API - * - * @return the version string - * @since 6.2.2 - */ - String info() default ""; - } - -} diff --git a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java index 7285e1981..d1ad9386c 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java +++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java @@ -19,6 +19,7 @@ package com.plotsquared.core.util; import com.google.common.eventbus.EventBus; +import com.intellectualsites.annotations.DoNotUse; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.events.PlayerAutoPlotEvent; @@ -81,8 +82,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -@AnnotationHelper.ApiDescription(info = "This is an internal class used by PlotSquared to dispatch events." + - "This is in no form part of the API and is subject to change at any time.") +@DoNotUse public class EventDispatcher { private final EventBus eventBus = new EventBus("PlotSquaredEvents"); diff --git a/build.gradle.kts b/build.gradle.kts index 9aa40c8bc..7f9d801ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -65,7 +65,7 @@ subprojects { } dependencies { - implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.5")) + implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.7")) } dependencies {