diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java index 2f7921304..d46b73a48 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java @@ -51,7 +51,7 @@ public class MVdWPlaceholders { ) { this.plugin = plugin; this.registry = registry; - for (final Placeholder placeholder : registry.allPlaceholders()) { + for (final Placeholder placeholder : registry.getPlaceholders()) { this.addPlaceholder(placeholder); } PlotSquared.get().getEventDispatcher().registerListener(this); diff --git a/Core/src/main/java/com/plotsquared/core/PlotAPI.java b/Core/src/main/java/com/plotsquared/core/PlotAPI.java index 8ac9925ad..09a468e12 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotAPI.java +++ b/Core/src/main/java/com/plotsquared/core/PlotAPI.java @@ -149,7 +149,6 @@ public class PlotAPI { * * @param message the message * @param replacements Variable replacements - * @since 6.3.0 */ public void sendConsoleMessage( final @NonNull String message, @@ -163,7 +162,6 @@ public class PlotAPI { * * @param caption the message * @param replacements Variable replacements - * @since 6.3.0 */ public void sendConsoleMessage( final @NonNull Caption caption, diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java index 9be9be1b7..fcbac06b2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -614,7 +614,6 @@ public abstract class Command { * @param mustBeTrue The condition to check, that must be true * @param message The message to send * @param args The arguments to send with the message - * @since 6.3.0 */ public void checkTrue(boolean mustBeTrue, Caption message, Placeholder... args) { if (!mustBeTrue) { @@ -630,7 +629,6 @@ public abstract class Command { * @param args The arguments to send with the message * @param The type of the object * @return The object - * @since 6.3.0 */ public T check(T object, Caption message, Placeholder... args) { if (object == null) { @@ -656,7 +654,6 @@ public abstract class Command { * * @param message The message to send * @param placeholders The placeholders to send with the message - * @since 6.3.0 */ public CommandException(final @Nullable Caption message, final Placeholder... placeholders) { this.message = message; diff --git a/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java b/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java index ff0176add..10a6e64c5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java +++ b/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java @@ -40,7 +40,6 @@ public interface CommandCaller { * * @param caption Caption to send * @param replacements Variable replacements - * @since 6.3.0 */ void sendMessage(@NonNull Caption caption, @NonNull Placeholder... replacements); diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java index 2c3e69b4e..4cde5031d 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/CaptionHolder.java @@ -36,6 +36,16 @@ public class CaptionHolder { this.caption = caption; } + /** + * @return a {@link Caption} from a {@link StaticCaption} + * + * @deprecated use {@link #caption()} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public Caption get() { + return this.caption; + } + /** * @return a {@link Caption} from a {@link StaticCaption} * @since 6.3.0 @@ -44,6 +54,15 @@ public class CaptionHolder { return this.caption; } + /** + * @return an array of {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder}s + * @deprecated use {@link #placeholders()} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public Placeholder[] getTemplates() { + return this.placeholders; + } + /** * @return an array of {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder}s * @since 6.3.0 @@ -52,6 +71,16 @@ public class CaptionHolder { return this.placeholders; } + /** + * @param placeholders placeholders + * + * @deprecated use {@link #parsePlaceholders(Placeholder...)} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public void setTemplates(Placeholder... placeholders) { + this.placeholders = placeholders; + } + /** * @param placeholders placeholders * @since 6.3.0 diff --git a/Core/src/main/java/com/plotsquared/core/configuration/caption/Templates.java b/Core/src/main/java/com/plotsquared/core/configuration/caption/Templates.java new file mode 100644 index 000000000..d743a5d6f --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/configuration/caption/Templates.java @@ -0,0 +1,129 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * 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.configuration.caption; + +import com.plotsquared.core.plot.PlotArea; +import com.plotsquared.core.util.PlayerManager; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.placeholder.Placeholder; +import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver; +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.UUID; + +/** + * Utility class that generates {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder templates} + * @deprecated Use {@link Placeholders} instead + */ +@Deprecated(forRemoval = true, since = "6.3.0") +public final class Templates { + + private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build(); + + private Templates() { + throw new UnsupportedOperationException( + "This is a utility class and cannot be instantiated"); + } + + /** + * Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a PlotSquared {@link Caption} + * + * @param localeHolder Locale holder + * @param key Template key + * @param caption Caption object + * @param replacements Replacements + * @return Generated template + * + * @deprecated Use {@link Placeholders#miniMessage(LocaleHolder, String, Caption, Placeholder[])} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public static @NonNull Placeholder of( + final @NonNull LocaleHolder localeHolder, + final @NonNull String key, final @NonNull Caption caption, + final @NonNull Placeholder... replacements + ) { + return net.kyori.adventure.text.minimessage.placeholder.Placeholder.component(key, MINI_MESSAGE.deserialize(caption.getComponent(localeHolder), + PlaceholderResolver.placeholders(replacements))); + } + + /** + * Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a username (using UUID mappings) + * + * @param key Template key + * @param uuid Player UUID + * @return Generated template + * + * @deprecated Use {@link Placeholders#miniMessage(String, UUID)} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public static @NonNull Placeholder of(final @NonNull String key, final @NonNull UUID uuid) { + final String username = PlayerManager.getName(uuid); + return Placeholder.miniMessage(key, username); + } + + /** + * Create a {@link Placeholder} from a string + * + * @param key Template key + * @param value Template value + * @return Generated template + * + * @deprecated Use {@link Placeholders#miniMessage(String, String)} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public static @NonNull Placeholder of(final @NonNull String key, final @NonNull String value) { + return Placeholder.miniMessage(key, value); + } + + /** + * Create a {@link Placeholder} from a plot area + * + * @param key Template Key + * @param area Plot area + * @return Generated template + * + * @deprecated Use {@link Placeholders#miniMessage(String, PlotArea)} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public static @NonNull Placeholder of(final @NonNull String key, final @NonNull PlotArea area) { + return Placeholder.miniMessage(key, area.toString()); + } + + /** + * Create a {@link Placeholder} from a number + * + * @param key Template key + * @param number Number + * @return Generated template + * + * @deprecated Use {@link Placeholders#miniMessage(String, Number)} instead + */ + @Deprecated(forRemoval = true, since = "6.3.0") + public static @NonNull Placeholder of(final @NonNull String key, final @NonNull Number number) { + return Placeholder.miniMessage(key, number.toString()); + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 7959756dd..619c1f1bd 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -836,7 +836,6 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, * @param title Title text * @param subtitle Subtitle text * @param replacements Variable replacements - * @since 6.3.0 */ public void sendTitle( final @NonNull Caption title, final @NonNull Caption subtitle, @@ -861,7 +860,6 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, * @param stay The title stays for (in ticks) * @param fadeOut Fade out time (in ticks) * @param replacements Variable replacements - * @since 6.3.0 */ public void sendTitle( final @NonNull Caption title, final @NonNull Caption subtitle, @@ -887,7 +885,6 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, * * @param caption Caption * @param replacements Variable replacements - * @since 6.3.0 */ public void sendActionBar( final @NonNull Caption caption, diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java index 24ab16382..4077ea2e9 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java @@ -375,7 +375,6 @@ public final class PlotModificationManager { * Sets the sign for a plot to a specific name * * @param name name - * @since 6.3.0 */ public void setSign(final @NonNull String name) { if (!this.plot.isLoaded()) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagParseException.java b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagParseException.java index e1d365f7a..d6ac41189 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/FlagParseException.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/FlagParseException.java @@ -43,7 +43,6 @@ public class FlagParseException extends Exception { * @param value Value that failed ot parse * @param errorMessage An error message explaining the failure * @param args Arguments used to format the error message - * @since 6.3.0 */ public FlagParseException( final PlotFlag flag, final String value, diff --git a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java index 06e2b0d05..d3876e7d2 100644 --- a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java +++ b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java @@ -142,7 +142,6 @@ public abstract class WorldUtil { * @param location Block location * @param lines Sign text * @param replacements Text replacements - * @since 6.3.0 */ public abstract void setSign( @NonNull Location location, diff --git a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java index 71777ea6a..d3e84e9db 100644 --- a/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java +++ b/Core/src/main/java/com/plotsquared/core/util/placeholders/PlaceholderRegistry.java @@ -296,10 +296,9 @@ public final class PlaceholderRegistry { /** * Get all placeholders * - * @return Unmodifiable collection of miniMessage - * @since 6.3.0 + * @return Unmodifiable collection of placeholders */ - public @NonNull Collection allPlaceholders() { + public @NonNull Collection getPlaceholders() { return Collections.unmodifiableCollection(this.placeholders.values()); }