style: Javadoc fixup

This commit is contained in:
NotMyFault 2021-12-15 11:33:14 +01:00
parent 51abe5565c
commit 0886f9ccd3
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
32 changed files with 131 additions and 70 deletions

View File

@ -100,5 +100,6 @@ tasks {
opt.links("https://jd.adventure.kyori.net/api/4.9.3/") opt.links("https://jd.adventure.kyori.net/api/4.9.3/")
opt.links("https://google.github.io/guice/api-docs/5.0.1/javadoc/") opt.links("https://google.github.io/guice/api-docs/5.0.1/javadoc/")
opt.links("https://checkerframework.org/api/") opt.links("https://checkerframework.org/api/")
opt.links("https://notmyfault.github.io/MiniMessage-Javadocs/") // Temporary hosting until Kyori adds hosted Javadocs
} }
} }

View File

@ -733,7 +733,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot_id", id.toString()); Placeholder<?> plotTemplate = Placeholder.miniMessage("plot_id", id.toString());
Placeholder<?> senderTemplate = Placeholder.miniMessage("sender", sender); Placeholder<?> senderTemplate = Placeholder.miniMessage("sender", sender);
// If we do/don't want colour, we need to be careful about how to go about it, as players could attempt either <gold></gold> or &6 etc. // If we do/don't want colour, we need to be careful about how to go about it, as players could attempt either <gold></gold> or &6 etc.
// In both cases, we want to use a Component Template to ensure that the player cannot use any of in their message on purpose // In both cases, we want to use a Component Template to ensure that the player cannot use any placeholders in their message on purpose
// or accidentally, as component templates are done at the end. We also need to deserialize from legacy color codes to a Component if // or accidentally, as component templates are done at the end. We also need to deserialize from legacy color codes to a Component if
// allowing colour. // allowing colour.
if (plotPlayer.hasPermission("plots.chat.color")) { if (plotPlayer.hasPermission("plots.chat.color")) {

View File

@ -155,7 +155,7 @@ public class PlotAPI {
final @NonNull String message, final @NonNull String message,
final @NonNull Placeholder<?> @NonNull ... replacements final @NonNull Placeholder<?> @NonNull ... replacements
) { ) {
ConsolePlayer.getConsole().sendMessage(StaticCaption.of(message), replacements); ConsolePlayer.getConsole().sendMessage(StaticCaption.miniMessage(message), replacements);
} }
/** /**

View File

@ -728,7 +728,7 @@ public class Area extends SubCommand {
Placeholder<?> typeTemplate = Placeholder.miniMessage("area_type", area.getType().name()); Placeholder<?> typeTemplate = Placeholder.miniMessage("area_type", area.getType().name());
Placeholder<?> terrainTemplate = Placeholder.miniMessage("area_terrain", area.getTerrain().name()); Placeholder<?> terrainTemplate = Placeholder.miniMessage("area_terrain", area.getTerrain().name());
caption.set(TranslatableCaption.miniMessage("info.area_list_item")); caption.set(TranslatableCaption.miniMessage("info.area_list_item"));
caption.setPlaceholders( caption.parsePlaceholders(
tooltipTemplate, tooltipTemplate,
visitcmdTemplate, visitcmdTemplate,
numberTemplate, numberTemplate,

View File

@ -215,7 +215,7 @@ public abstract class Command {
String descriptionKey = String.join(".", path); String descriptionKey = String.join(".", path);
this.description = TranslatableCaption.miniMessage(String.format("commands.description.%s", descriptionKey)); this.description = TranslatableCaption.miniMessage(String.format("commands.description.%s", descriptionKey));
} else { } else {
this.description = StaticCaption.of(declaration.description()); this.description = StaticCaption.miniMessage(declaration.description());
} }
this.usage = declaration.usage(); this.usage = declaration.usage();
this.confirmation = declaration.confirmation(); this.confirmation = declaration.confirmation();
@ -274,7 +274,7 @@ public abstract class Command {
i++; i++;
final CaptionHolder msg = new CaptionHolder(); final CaptionHolder msg = new CaptionHolder();
add.run(i, obj, msg); add.run(i, obj, msg);
player.sendMessage(msg.get(), msg.getPlaceholders()); player.sendMessage(msg.caption(), msg.placeholders());
} }
// Send the footer // Send the footer
Placeholder<?> command1 = Placeholder.miniMessage("command1", baseCommand + " " + page); Placeholder<?> command1 = Placeholder.miniMessage("command1", baseCommand + " " + page);
@ -307,7 +307,7 @@ public abstract class Command {
} }
if (this.allCommands.isEmpty()) { if (this.allCommands.isEmpty()) {
player.sendMessage( player.sendMessage(
StaticCaption.of("Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues")); StaticCaption.miniMessage("Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues"));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
Command cmd = getCommand(args[0]); Command cmd = getCommand(args[0]);
@ -608,12 +608,30 @@ public abstract class Command {
return this.getFullId().hashCode(); return this.getFullId().hashCode();
} }
/**
* Check whether a given condition is true
*
* @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) { public void checkTrue(boolean mustBeTrue, Caption message, Placeholder<?>... args) {
if (!mustBeTrue) { if (!mustBeTrue) {
throw new CommandException(message, args); throw new CommandException(message, args);
} }
} }
/**
* Check whether a given condition is true
*
* @param object The condition to check, that must be true
* @param message The message to send
* @param args The arguments to send with the message
* @param <T> The type of the object
* @return The object
* @since 6.3.0
*/
public <T> T check(T object, Caption message, Placeholder<?>... args) { public <T> T check(T object, Caption message, Placeholder<?>... args) {
if (object == null) { if (object == null) {
throw new CommandException(message, args); throw new CommandException(message, args);
@ -633,6 +651,13 @@ public abstract class Command {
private final Placeholder<?>[] placeholders; private final Placeholder<?>[] placeholders;
private final Caption message; private final Caption message;
/**
* Create a new CommandException
*
* @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) { public CommandException(final @Nullable Caption message, final Placeholder<?>... placeholders) {
this.message = message; this.message = message;
this.placeholders = placeholders; this.placeholders = placeholders;

View File

@ -40,6 +40,7 @@ public interface CommandCaller {
* *
* @param caption Caption to send * @param caption Caption to send
* @param replacements Variable replacements * @param replacements Variable replacements
* @since 6.3.0
*/ */
void sendMessage(@NonNull Caption caption, @NonNull Placeholder<?>... replacements); void sendMessage(@NonNull Caption caption, @NonNull Placeholder<?>... replacements);

View File

@ -112,7 +112,7 @@ public class Comment extends SubCommand {
for (final PlotPlayer<?> pp : PlotSquared.platform().playerManager().getPlayers()) { for (final PlotPlayer<?> pp : PlotSquared.platform().playerManager().getPlayers()) {
if (pp.getAttribute("chatspy")) { if (pp.getAttribute("chatspy")) {
pp.sendMessage(StaticCaption.of("/plot comment " + StringMan.join(args, " "))); pp.sendMessage(StaticCaption.miniMessage("/plot comment " + StringMan.join(args, " ")));
} }
} }

View File

@ -213,7 +213,7 @@ public class DatabaseCommand extends SubCommand {
} }
case "mysql" -> { case "mysql" -> {
if (args.length < 6) { if (args.length < 6) {
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"/plot database mysql [host] [port] [username] [password] [database] {prefix}")); "/plot database mysql [host] [port] [username] [password] [database] {prefix}"));
return false; return false;
} }
@ -229,7 +229,7 @@ public class DatabaseCommand extends SubCommand {
} }
case "sqlite" -> { case "sqlite" -> {
if (args.length < 2) { if (args.length < 2) {
player.sendMessage(StaticCaption.of("/plot database sqlite [file]")); player.sendMessage(StaticCaption.miniMessage("/plot database sqlite [file]"));
return false; return false;
} }
File sqliteFile = File sqliteFile =
@ -237,7 +237,7 @@ public class DatabaseCommand extends SubCommand {
implementation = new SQLite(sqliteFile); implementation = new SQLite(sqliteFile);
} }
default -> { default -> {
player.sendMessage(StaticCaption.of("/plot database [sqlite/mysql]")); player.sendMessage(StaticCaption.miniMessage("/plot database [sqlite/mysql]"));
return false; return false;
} }
} }

View File

@ -82,7 +82,7 @@ public class Debug extends SubCommand {
if (args.length > 0) { if (args.length > 0) {
if ("player".equalsIgnoreCase(args[0])) { if ("player".equalsIgnoreCase(args[0])) {
for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) { for (Map.Entry<String, Object> meta : player.getMeta().entrySet()) {
player.sendMessage(StaticCaption.of("Key: " + meta.getKey() + " Value: " + meta player.sendMessage(StaticCaption.miniMessage("Key: " + meta.getKey() + " Value: " + meta
.getValue() .getValue()
.toString() + " , ")); .toString() + " , "));
} }
@ -93,7 +93,7 @@ public class Debug extends SubCommand {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
player.sendMessage(TranslatableCaption.miniMessage("debug.fetching_loaded_chunks")); player.sendMessage(TranslatableCaption.miniMessage("debug.fetching_loaded_chunks"));
TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption
.of("Loaded chunks: " + this.worldUtil .miniMessage("Loaded chunks: " + this.worldUtil
.getChunkChunks(player.getLocation().getWorldName()) .getChunkChunks(player.getLocation().getWorldName())
.size() + " (" + (System.currentTimeMillis() .size() + " (" + (System.currentTimeMillis()
- start) + "ms) using thread: " + Thread.currentThread().getName()))); - start) + "ms) using thread: " + Thread.currentThread().getName())));
@ -126,7 +126,7 @@ public class Debug extends SubCommand {
for (final EntityType entityType : category.getAll()) { for (final EntityType entityType : category.getAll()) {
builder.append(entityType.getId()).append(" "); builder.append(entityType.getId()).append(" ");
} }
player.sendMessage(StaticCaption.of("<prefix>" + builder)); player.sendMessage(StaticCaption.miniMessage("<prefix>" + builder));
}); });
EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId)) EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId))
.forEach(entityType -> { .forEach(entityType -> {
@ -135,7 +135,7 @@ public class Debug extends SubCommand {
if (categoryCount > 0) { if (categoryCount > 0) {
return; return;
} }
player.sendMessage(StaticCaption.of("<prefix>" + entityType.getName() + " is in " player.sendMessage(StaticCaption.miniMessage("<prefix>" + entityType.getName() + " is in "
+ categoryCount + " categories")); + categoryCount + " categories"));
}); });
return true; return true;
@ -170,7 +170,7 @@ public class Debug extends SubCommand {
PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Total Messages"), PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Total Messages"),
Placeholder.miniMessage("val", String.valueOf(captions.size()))) Placeholder.miniMessage("val", String.valueOf(captions.size())))
)); ));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(information.build()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(information.build())));
return true; return true;
} }

View File

@ -228,7 +228,7 @@ public class DebugExec extends SubCommand {
} }
} }
} }
player.sendMessage(StaticCaption.of("<prefix><gold>Possible sub commands: </gold><gray>/plot debugexec <" player.sendMessage(StaticCaption.miniMessage("<prefix><gold>Possible sub commands: </gold><gray>/plot debugexec <"
+ StringMan.join(allowedParams, " | ") + "></gray>")); + StringMan.join(allowedParams, " | ") + "></gray>"));
return false; return false;
} }

View File

@ -193,7 +193,7 @@ public class Download extends SubCommand {
Placeholder.miniMessage("download", value.toString()), Placeholder.miniMessage("download", value.toString()),
Placeholder.miniMessage("delete", "Not available") Placeholder.miniMessage("delete", "Not available")
); );
player.sendMessage(StaticCaption.of(value.toString())); player.sendMessage(StaticCaption.miniMessage(value.toString()));
} }
}); });
}); });

View File

@ -595,7 +595,7 @@ public final class FlagCommand extends Command {
) )
)); ));
} }
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(builder.build())));
} }
} }

View File

@ -142,7 +142,7 @@ public class Help extends Command {
builder.append(Component.newline()).append(MINI_MESSAGE.parse(TranslatableCaption builder.append(Component.newline()).append(MINI_MESSAGE.parse(TranslatableCaption
.miniMessage("help.help_footer") .miniMessage("help.help_footer")
.getComponent(player))); .getComponent(player)));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.asComponent()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(builder.asComponent())));
return true; return true;
} }
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage( new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(

View File

@ -122,7 +122,7 @@ public class Inbox extends SubCommand {
commentTemplate commentTemplate
))); )));
} }
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build()))); player.sendMessage(StaticCaption.miniMessage(MINI_MESSAGE.serialize(builder.build())));
} }
@Override @Override

View File

@ -129,11 +129,11 @@ public class Info extends SubCommand {
info = getCaption(arg); info = getCaption(arg);
if (info == null) { if (info == null) {
if (Settings.Ratings.USE_LIKES) { if (Settings.Ratings.USE_LIKES) {
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + " &alikes")); + "&aowner&7, " + " &alikes"));
} else { } else {
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
+ "&aowner&7, " + " &arating")); + "&aowner&7, " + " &arating"));
} }

View File

@ -493,7 +493,7 @@ public class ListCmd extends SubCommand {
} }
Placeholder<?> players = Placeholder.miniMessage("players", builder.asComponent().toString()); Placeholder<?> players = Placeholder.miniMessage("players", builder.asComponent().toString());
caption.set(TranslatableCaption.miniMessage("info.plot_list_item")); caption.set(TranslatableCaption.miniMessage("info.plot_list_item"));
caption.setPlaceholders(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players); caption.parsePlaceholders(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players);
} }
}, "/plot list " + args[0], TranslatableCaption.miniMessage("list.plot_list_header_paged")); }, "/plot list " + args[0], TranslatableCaption.miniMessage("list.plot_list_header_paged"));
} }

View File

@ -210,7 +210,7 @@ public class Load extends SubCommand {
PlotId id = PlotId.fromString(split[2] + ';' + split[3]); PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
String size = split[4]; String size = split[4];
String color = "<dark_aqua>"; String color = "<dark_aqua>";
player.sendMessage(StaticCaption.of("<dark_gray>[</dark_gray><gray>" + (i + 1) + "</gray><dark_aqua>] </dark_aqua>" + color + time + "<dark_gray> | </dark_gray>" + color + world + ';' + id player.sendMessage(StaticCaption.miniMessage("<dark_gray>[</dark_gray><gray>" + (i + 1) + "</gray><dark_aqua>] </dark_aqua>" + color + time + "<dark_gray> | </dark_gray>" + color + world + ';' + id
+ "<dark_gray> | </dark_gray>" + color + size + 'x' + size)); + "<dark_gray> | </dark_gray>" + color + size + 'x' + size));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -43,19 +43,23 @@ public class PluginCmd extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) { public boolean onCommand(final PlotPlayer<?> player, String[] args) {
TaskManager.getPlatformImplementation().taskAsync(() -> { TaskManager.getPlatformImplementation().taskAsync(() -> {
player.sendMessage( player.sendMessage(
StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared StaticCaption.miniMessage("<gray>>> </gray><gold><bold>" + PlotSquared
.platform() .platform()
.pluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"), .pluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"),
Placeholder.miniMessage("version", String.valueOf(PlotSquared.get().getVersion())) Placeholder.miniMessage("version", String.valueOf(PlotSquared.get().getVersion()))
); );
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"<gray>>> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray><gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray><gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>")); "<gray>>> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray>" +
player.sendMessage(StaticCaption.of( "<gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray>" +
"<gray>>> </gray><gold><bold>Wiki<reset><gray>: </gray><gold><click:open_url:https://github.com/IntellectualSites/PlotSquared-Documentation/wiki>https://github.com/IntellectualSites/PlotSquared-Documentation/wiki</gold>")); "<gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>"));
player.sendMessage(StaticCaption.of( player.sendMessage(StaticCaption.miniMessage(
"<gray>>> </gray><gold><bold>Discord<reset><gray>: </gray><gold><click:open_url:https://discord.gg/intellectualsites>https://discord.gg/intellectualsites</gold>")); "<gray>>> </gray><gold><bold>Wiki<reset><gray>:" +
"</gray><gold><click:open_url:https://github.com/IntellectualSites/PlotSquared-Documentation/wiki>https://github.com/IntellectualSites/PlotSquared-Documentation/wiki</gold>"));
player.sendMessage(StaticCaption.miniMessage(
"<gray>>> </gray><gold><bold>Discord<reset><gray>:" +
"</gray><gold><click:open_url:https://discord.gg/intellectualsites>https://discord.gg/intellectualsites</gold>"));
player.sendMessage( player.sendMessage(
StaticCaption.of("<gray>>> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"), StaticCaption.miniMessage("<gray>>> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"),
Placeholder.miniMessage("value", String.valueOf(PremiumVerification.isPremium())) Placeholder.miniMessage("value", String.valueOf(PremiumVerification.isPremium()))
); );
}); });

View File

@ -33,7 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
public enum RequiredType { public enum RequiredType {
CONSOLE(TranslatableCaption.miniMessage("console.not_console")), CONSOLE(TranslatableCaption.miniMessage("console.not_console")),
PLAYER(TranslatableCaption.miniMessage("console.is_console")), PLAYER(TranslatableCaption.miniMessage("console.is_console")),
NONE(StaticCaption.of("Something went wrong: RequiredType=NONE")); // this caption should never be sent NONE(StaticCaption.miniMessage("Something went wrong: RequiredType=NONE")); // this caption should never be sent
private final Caption caption; private final Caption caption;

View File

@ -204,7 +204,7 @@ public class Set extends SubCommand {
if (plot != null) { if (plot != null) {
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId()))); newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
} }
player.sendMessage(StaticCaption.of(TranslatableCaption player.sendMessage(StaticCaption.miniMessage(TranslatableCaption
.miniMessage("commandconfig.subcommand_set_options_header_only") .miniMessage("commandconfig.subcommand_set_options_header_only")
.getComponent(player) + StringMan .getComponent(player) + StringMan
.join(newValues, TranslatableCaption.miniMessage("blocklist.block_list_separator").getComponent(player)))); .join(newValues, TranslatableCaption.miniMessage("blocklist.block_list_separator").getComponent(player))));

View File

@ -72,7 +72,7 @@ public class Setup extends SubCommand {
message.append("\n<dark_gray> - </dark_gray><gray>").append(entry.getKey()).append(" (Unknown structure)</gray>"); message.append("\n<dark_gray> - </dark_gray><gray>").append(entry.getKey()).append(" (Unknown structure)</gray>");
} }
} }
player.sendMessage(StaticCaption.of(message.toString())); player.sendMessage(StaticCaption.miniMessage(message.toString()));
} }
@Override @Override

View File

@ -104,9 +104,9 @@ public class Trim extends SubCommand {
} }
result.value1 = new HashSet<>(PlotSquared.platform().worldUtil().getChunkChunks(world)); result.value1 = new HashSet<>(PlotSquared.platform().worldUtil().getChunkChunks(world));
result.value2 = new HashSet<>(); result.value2 = new HashSet<>();
StaticCaption.of(" - MCA #: " + result.value1.size()); StaticCaption.miniMessage(" - MCA #: " + result.value1.size());
StaticCaption.of(" - CHUNKS: " + (result.value1.size() * 1024) + " (max)"); StaticCaption.miniMessage(" - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
StaticCaption.of(" - TIME ESTIMATE: 12 Parsecs"); StaticCaption.miniMessage(" - TIME ESTIMATE: 12 Parsecs");
TaskManager.getPlatformImplementation().objectTask(plots, new RunnableVal<>() { TaskManager.getPlatformImplementation().objectTask(plots, new RunnableVal<>() {
@Override @Override
public void run(Plot plot) { public void run(Plot plot) {

View File

@ -24,28 +24,40 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package com.plotsquared.core.configuration.caption; package com.plotsquared.core.configuration.caption;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder; import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
public class CaptionHolder { public class CaptionHolder {
private Caption caption = StaticCaption.of(""); private Caption caption = StaticCaption.miniMessage("");
private Placeholder<?>[] placeholders = new Placeholder[0]; private Placeholder<?>[] placeholders = new Placeholder[0];
public void set(Caption caption) { public void set(Caption caption) {
this.caption = caption; this.caption = caption;
} }
public Caption get() { /**
return this.caption; * @return a {@link Caption} from a {@link StaticCaption}
} * @since 6.3.0
*/
public Placeholder<?>[] getPlaceholders() { public Caption caption() {
return this.placeholders; return this.caption;
} }
public void setPlaceholders(Placeholder<?>... placeholders) { /**
this.placeholders = placeholders; * @return an array of {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder}s
} * @since 6.3.0
*/
} public Placeholder<?>[] placeholders() {
return this.placeholders;
}
/**
* @param placeholders placeholders
* @since 6.3.0
*/
public void parsePlaceholders(Placeholder<?>... placeholders) {
this.placeholders = placeholders;
}
}

View File

@ -41,11 +41,24 @@ public final class StaticCaption implements Caption {
* *
* @param text Text * @param text Text
* @return Created caption * @return Created caption
* @deprecated Use {@link #miniMessage(String)} instead
*/ */
@Deprecated(forRemoval = true, since = "6.3.0")
public static @NonNull StaticCaption of(final @NonNull String text) { public static @NonNull StaticCaption of(final @NonNull String text) {
return new StaticCaption(Preconditions.checkNotNull(text, "Text may not be null")); return new StaticCaption(Preconditions.checkNotNull(text, "Text may not be null"));
} }
/**
* Create a new static caption from the given text
*
* @param text Text
* @return Created caption
* @since 6.3.0
*/
public static @NonNull StaticCaption miniMessage(final @NonNull String text) {
return new StaticCaption(Preconditions.checkNotNull(text, "Text may not be null"));
}
@Override @Override
public @NonNull String getComponent(@NonNull LocaleHolder localeHolder) { public @NonNull String getComponent(@NonNull LocaleHolder localeHolder) {
return this.value; // can't be translated return this.value; // can't be translated

View File

@ -328,9 +328,9 @@ public class PlotListener {
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) { if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) {
final UUID plotOwner = plot.getOwnerAbs(); final UUID plotOwner = plot.getOwnerAbs();
String owner = PlayerManager.getName(plotOwner, false); String owner = PlayerManager.getName(plotOwner, false);
Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.miniMessage("titles" + Caption header = fromFlag ? StaticCaption.miniMessage(title) : TranslatableCaption.miniMessage("titles" +
".title_entered_plot"); ".title_entered_plot");
Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.miniMessage("titles" + Caption subHeader = fromFlag ? StaticCaption.miniMessage(subtitle) : TranslatableCaption.miniMessage("titles" +
".title_entered_plot_sub"); ".title_entered_plot_sub");
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot", lastPlot.getId().toString()); Placeholder<?> plotTemplate = Placeholder.miniMessage("plot", lastPlot.getId().toString());
Placeholder<?> worldTemplate = Placeholder.miniMessage("world", player.getLocation().getWorldName()); Placeholder<?> worldTemplate = Placeholder.miniMessage("world", player.getLocation().getWorldName());

View File

@ -836,6 +836,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
* @param title Title text * @param title Title text
* @param subtitle Subtitle text * @param subtitle Subtitle text
* @param replacements Variable replacements * @param replacements Variable replacements
* @since 6.3.0
*/ */
public void sendTitle( public void sendTitle(
final @NonNull Caption title, final @NonNull Caption subtitle, final @NonNull Caption title, final @NonNull Caption subtitle,
@ -860,6 +861,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
* @param stay The title stays for (in ticks) * @param stay The title stays for (in ticks)
* @param fadeOut Fade out time (in ticks) * @param fadeOut Fade out time (in ticks)
* @param replacements Variable replacements * @param replacements Variable replacements
* @since 6.3.0
*/ */
public void sendTitle( public void sendTitle(
final @NonNull Caption title, final @NonNull Caption subtitle, final @NonNull Caption title, final @NonNull Caption subtitle,
@ -885,6 +887,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
* *
* @param caption Caption * @param caption Caption
* @param replacements Variable replacements * @param replacements Variable replacements
* @since 6.3.0
*/ */
public void sendActionBar( public void sendActionBar(
final @NonNull Caption caption, final @NonNull Caption caption,

View File

@ -2946,7 +2946,7 @@ public class Plot {
} }
} }
} }
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE future.complete(StaticCaption.miniMessage(MINI_MESSAGE.serialize(MINI_MESSAGE
.deserialize( .deserialize(
iInfo.getComponent(player), iInfo.getComponent(player),
PlaceholderResolver.placeholders( PlaceholderResolver.placeholders(
@ -2973,7 +2973,7 @@ public class Plot {
}); });
return; return;
} }
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE future.complete(StaticCaption.miniMessage(MINI_MESSAGE.serialize(MINI_MESSAGE
.deserialize( .deserialize(
iInfo.getComponent(player), iInfo.getComponent(player),
PlaceholderResolver.placeholders( PlaceholderResolver.placeholders(

View File

@ -375,6 +375,7 @@ public final class PlotModificationManager {
* Sets the sign for a plot to a specific name * Sets the sign for a plot to a specific name
* *
* @param name name * @param name name
* @since 6.3.0
*/ */
public void setSign(final @NonNull String name) { public void setSign(final @NonNull String name) {
if (!this.plot.isLoaded()) { if (!this.plot.isLoaded()) {

View File

@ -75,7 +75,7 @@ public class CommentManager {
} }
if ((size.decrementAndGet() == 0) && (total > 0)) { if ((size.decrementAndGet() == 0) && (total > 0)) {
player.sendTitle( player.sendTitle(
StaticCaption.of(""), StaticCaption.miniMessage(""),
TranslatableCaption.miniMessage("comment.inbox_notification"), TranslatableCaption.miniMessage("comment.inbox_notification"),
Placeholder.miniMessage("amount", Integer.toString(total)), Placeholder.miniMessage("amount", Integer.toString(total)),
Placeholder.miniMessage("command", "/plot inbox") Placeholder.miniMessage("command", "/plot inbox")

View File

@ -142,6 +142,7 @@ public abstract class WorldUtil {
* @param location Block location * @param location Block location
* @param lines Sign text * @param lines Sign text
* @param replacements Text replacements * @param replacements Text replacements
* @since 6.3.0
*/ */
public abstract void setSign( public abstract void setSign(
@NonNull Location location, @NonNull Location location,

View File

@ -71,7 +71,7 @@ public class HelpPage {
Placeholder<?> help_objects = Placeholder.miniMessage("help_objects", StringMan.join(this.helpObjects, "\n")); Placeholder<?> help_objects = Placeholder.miniMessage("help_objects", StringMan.join(this.helpObjects, "\n"));
Placeholder<?> footer = Placeholder.miniMessage("footer", TranslatableCaption.miniMessage("help.help_footer").getComponent(player)); Placeholder<?> footer = Placeholder.miniMessage("footer", TranslatableCaption.miniMessage("help.help_footer").getComponent(player));
player.sendMessage( player.sendMessage(
StaticCaption.of("<header>\n<page_header>\n<help_objects>\n<footer>"), StaticCaption.miniMessage("<header>\n<page_header>\n<help_objects>\n<footer>"),
header, header,
page_header, page_header,
help_objects, help_objects,

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.plot.Plot;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
/** /**
* A {@link Placeholder placeholder} that requires a {@link com.plotsquared.core.plot.Plot plot} * A {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} that requires a {@link com.plotsquared.core.plot.Plot plot}
*/ */
public abstract class PlotSpecificPlaceholder extends Placeholder { public abstract class PlotSpecificPlaceholder extends Placeholder {