From 3eb485e90043ee64df78fbecaa83686e3b27b598 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Dec 2021 16:18:19 +0100 Subject: [PATCH] refactor: Drop guava annotations and create annotation helper (#3389) --- .../core/plot/comment/CommentManager.java | 2 - .../core/plot/flag/FlagContainer.java | 4 +- .../core/util/AnnotationHelper.java | 62 +++++++++++++++++++ .../core/util/EventDispatcher.java | 4 +- 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java diff --git a/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java b/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java index adfc4df75..26a2a8ce4 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/comment/CommentManager.java @@ -25,7 +25,6 @@ */ package com.plotsquared.core.plot.comment; -import com.google.common.annotations.Beta; import com.google.inject.TypeLiteral; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.caption.StaticCaption; @@ -44,7 +43,6 @@ import java.util.HashMap; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -@Beta public class CommentManager { public static final HashMap inboxes = new HashMap<>(); 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 94eadff69..27790ed1d 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 @@ -28,11 +28,11 @@ package com.plotsquared.core.plot.flag; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; 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; import org.checkerframework.checker.nullness.qual.Nullable; -import org.jetbrains.annotations.ApiStatus; import java.util.Collection; import java.util.HashMap; @@ -349,7 +349,7 @@ public class FlagContainer { * * @return a new Runnable that cleans up once the FlagContainer isn't needed anymore. */ - @ApiStatus.Internal + @AnnotationHelper.ApiDescription(info = "This method should not be considered as public or API.") public Runnable createCleanupHook() { return () -> GlobalFlagContainer.getInstance().unsubscribe(unknownsRef); } diff --git a/Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java b/Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java new file mode 100644 index 000000000..3ab9abd36 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/util/AnnotationHelper.java @@ -0,0 +1,62 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2021 IntellectualSites + * + * 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.3.0 + */ +@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.3.0 + */ + 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 7173ecdcb..3db67c9c2 100644 --- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java +++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java @@ -83,13 +83,13 @@ import com.sk89q.worldedit.world.block.BlockTypes; import net.kyori.adventure.text.minimessage.Template; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import org.jetbrains.annotations.ApiStatus; import java.util.ArrayList; import java.util.List; import java.util.UUID; -@ApiStatus.Internal +@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.") public class EventDispatcher { private final EventBus eventBus = new EventBus("PlotSquaredEvents");