", TranslatableCaption.of("core.prefix").getComponent(this));
// Parse the message
- PlotSquared.platform().consoleAudience().sendMessage(MINI_MESSAGE.parse(message, replacements));
+ PlotSquared.platform().consoleAudience().sendMessage(MINI_MESSAGE.deserialize(message, replacements));
}
@Override
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 ea85afda1..2dd7bd7cb 100644
--- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
+++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java
@@ -66,7 +66,7 @@ import com.sk89q.worldedit.world.item.ItemType;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.kyori.adventure.title.Title;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -844,7 +844,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer,
*/
public void sendTitle(
final @NonNull Caption title, final @NonNull Caption subtitle,
- final @NonNull Template... replacements
+ final @NonNull TagResolver... replacements
) {
sendTitle(
title,
@@ -869,11 +869,11 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer,
public void sendTitle(
final @NonNull Caption title, final @NonNull Caption subtitle,
final int fadeIn, final int stay, final int fadeOut,
- final @NonNull Template... replacements
+ final @NonNull TagResolver... replacements
) {
- final Component titleComponent = MiniMessage.get().parse(title.getComponent(this), replacements);
+ final Component titleComponent = MiniMessage.miniMessage().deserialize(title.getComponent(this), replacements);
final Component subtitleComponent =
- MiniMessage.get().parse(subtitle.getComponent(this), replacements);
+ MiniMessage.miniMessage().deserialize(subtitle.getComponent(this), replacements);
final Title.Times times = Title.Times.of(
Duration.of(Settings.Titles.TITLES_FADE_IN * 50L, ChronoUnit.MILLIS),
Duration.of(Settings.Titles.TITLES_STAY * 50L, ChronoUnit.MILLIS),
@@ -891,7 +891,7 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer,
*/
public void sendActionBar(
final @NonNull Caption caption,
- final @NonNull Template... replacements
+ final @NonNull TagResolver... replacements
) {
String message;
try {
@@ -911,14 +911,14 @@ public abstract class PlotPlayer
implements CommandCaller, OfflinePlotPlayer,
.replace("", TranslatableCaption.of("core.prefix").getComponent(this));
- final Component component = MiniMessage.get().parse(message, replacements);
+ final Component component = MiniMessage.miniMessage().deserialize(message, replacements);
getAudience().sendActionBar(component);
}
@Override
public void sendMessage(
final @NonNull Caption caption,
- final @NonNull Template... replacements
+ final @NonNull TagResolver... replacements
) {
String message;
try {
@@ -937,7 +937,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer,
.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&')
.replace("", TranslatableCaption.of("core.prefix").getComponent(this));
// Parse the message
- final Component component = MiniMessage.get().parse(message, replacements);
+ final Component component = MiniMessage.miniMessage().deserialize(message, replacements);
if (!Objects.equal(component, this.getMeta("lastMessage"))
|| System.currentTimeMillis() - this.getMeta("lastMessageTime") > 5000) {
setMeta("lastMessage", component);
diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java
index b709de857..00d49fe01 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java
@@ -77,9 +77,11 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -464,7 +466,7 @@ public class Plot {
* that could alter the de facto owner of the plot.
*
* @return The plot owner of this particular (sub-)plot
- * as stored in the database, if one exists. Else, null.
+ * as stored in the database, if one exists. Else, null.
*/
public @Nullable UUID getOwnerAbs() {
return this.owner;
@@ -1738,7 +1740,10 @@ public class Plot {
area.addPlot(this);
updateWorldBorder();
}
- player.sendMessage(TranslatableCaption.of("working.claimed"), Template.of("plot", this.getId().toString()));
+ player.sendMessage(
+ TranslatableCaption.of("working.claimed"),
+ TagResolver.resolver("plot", Tag.inserting(Component.text(this.getId().toString())))
+ );
if (teleport) {
if (!auto && Settings.Teleport.ON_CLAIM) {
teleportPlayer(player, TeleportCause.COMMAND_CLAIM, result -> {
@@ -2607,11 +2612,13 @@ public class Plot {
return;
}
Caption caption = TranslatableCaption.of("debug.plot_debug");
- Template plotTemplate = Template.of("plot", this.toString());
- Template messageTemplate = Template.of("message", message);
+ TagResolver resolver = TagResolver.builder()
+ .tag("plot", Tag.inserting(Component.text(toString())))
+ .tag("message", Tag.inserting(Component.text(message)))
+ .build();
for (final PlotPlayer> player : players) {
if (isOwner(player.getUUID()) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_DEBUG_OTHER)) {
- player.sendMessage(caption, plotTemplate, messageTemplate);
+ player.sendMessage(caption, resolver);
}
}
} catch (final Exception ignored) {
@@ -2641,7 +2648,7 @@ public class Plot {
if (result == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
- Template.of("value", "Teleport")
+ TagResolver.resolver("value", Tag.inserting(Component.text("Teleport")))
);
resultConsumer.accept(false);
return;
@@ -2656,7 +2663,7 @@ public class Plot {
}
player.sendMessage(
TranslatableCaption.of("teleport.teleport_in_seconds"),
- Template.of("amount", String.valueOf(Settings.Teleport.DELAY))
+ TagResolver.resolver("amount", Tag.inserting(Component.text(Settings.Teleport.DELAY)))
);
final String name = player.getName();
TaskManager.addToTeleportQueue(name);
@@ -2832,41 +2839,44 @@ public class Plot {
public CompletableFuture format(final Caption iInfo, PlotPlayer> player, final boolean full) {
final CompletableFuture future = new CompletableFuture<>();
int num = this.getConnectedPlots().size();
- String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player);
+ ComponentLike alias = !this.getAlias().isEmpty() ?
+ Component.text(this.getAlias()) :
+ TranslatableCaption.of("info.none").toComponent(player);
Location bot = this.getCorners()[0];
PlotSquared.platform().worldUtil().getBiome(
Objects.requireNonNull(this.getWorldName()),
bot.getX(),
bot.getZ(),
biome -> {
- Component trusted = PlayerManager.getPlayerList(this.getTrusted(), player);
- Component members = PlayerManager.getPlayerList(this.getMembers(), player);
- Component denied = PlayerManager.getPlayerList(this.getDenied(), player);
- String seen;
+ ComponentLike trusted = PlayerManager.getPlayerList(this.getTrusted(), player);
+ ComponentLike members = PlayerManager.getPlayerList(this.getMembers(), player);
+ ComponentLike denied = PlayerManager.getPlayerList(this.getDenied(), player);
+ ComponentLike seen;
if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) {
if (this.isOnline()) {
- seen = TranslatableCaption.of("info.now").getComponent(player);
+ seen = TranslatableCaption.of("info.now").toComponent(player);
} else {
int time = (int) (ExpireManager.IMP.getAge(this, false) / 1000);
if (time != 0) {
- seen = TimeUtil.secToTime(time);
+ seen = Component.text(TimeUtil.secToTime(time));
} else {
- seen = TranslatableCaption.of("info.unknown").getComponent(player);
+ seen = TranslatableCaption.of("info.unknown").toComponent(player);
}
}
} else {
- seen = TranslatableCaption.of("info.never").getComponent(player);
+ seen = TranslatableCaption.of("info.never").toComponent(player);
}
- String description = this.getFlag(DescriptionFlag.class);
- if (description.isEmpty()) {
- description = TranslatableCaption.of("info.plot_no_description").getComponent(player);
+ ComponentLike description = TranslatableCaption.of("info.plot_no_description").toComponent(player);
+ String descriptionValue = this.getFlag(DescriptionFlag.class);
+ if (!descriptionValue.isEmpty()) {
+ description = Component.text(descriptionValue);
}
- Component flags;
+ ComponentLike flags;
Collection> flagCollection = this.getApplicableFlags(true);
if (flagCollection.isEmpty()) {
- flags = MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(player));
+ flags = TranslatableCaption.of("info.none").toComponent(player);
} else {
TextComponent.Builder flagBuilder = Component.text();
String prefix = "";
@@ -2877,13 +2887,18 @@ public class Plot {
} else {
value = flag.toString();
}
- Component snip = MINI_MESSAGE.parse(
+ Component snip = MINI_MESSAGE.deserialize(
prefix + CaptionUtility.format(
player,
TranslatableCaption.of("info.plot_flag_list").getComponent(player)
),
- Template.of("flag", flag.getName()),
- Template.of("value", CaptionUtility.formatRaw(player, value.toString()))
+ TagResolver.builder()
+ .tag("flag", Tag.inserting(Component.text(flag.getName())))
+ .tag("value", Tag.inserting(Component.text(CaptionUtility.formatRaw(
+ player,
+ value.toString()
+ ))))
+ .build()
);
flagBuilder.append(snip);
prefix = ", ";
@@ -2895,67 +2910,57 @@ public class Plot {
if (this.getOwner() == null) {
owner = Component.text("unowned");
} else if (this.getOwner().equals(DBFunc.SERVER)) {
- owner = Component.text(MINI_MESSAGE.stripTokens(TranslatableCaption
+ owner = Component.text(MINI_MESSAGE.stripTags(TranslatableCaption
.of("info.server")
.getComponent(player)));
} else {
owner = PlayerManager.getPlayerList(this.getOwners(), player);
}
- Template headerTemplate = Template.of(
- "header",
- TranslatableCaption.of("info.plot_info_header").getComponent(player)
- );
- Template footerTemplate = Template.of(
- "footer",
- TranslatableCaption.of("info.plot_info_footer").getComponent(player)
- );
- Template areaTemplate;
+ TagResolver.Builder tagBuilder = TagResolver.builder();
+ tagBuilder.tag("header", Tag.inserting(TranslatableCaption.of("info.plot_info_header").toComponent(player)));
+ tagBuilder.tag("footer", Tag.inserting(TranslatableCaption.of("info.plot_info_footer").toComponent(player)));
+ TextComponent.Builder areaComponent = Component.text();
if (this.getArea() != null) {
- areaTemplate =
- Template.of(
- "area",
- this.getArea().getWorldName() + (this.getArea().getId() == null
- ? ""
- : "(" + this.getArea().getId() + ")")
- );
+ areaComponent.append(Component.text(getArea().getWorldName()));
+ if (getArea().getId() != null) {
+ areaComponent.append(Component.text("("))
+ .append(Component.text(getArea().getId()))
+ .append(Component.text(")"));
+ }
} else {
- areaTemplate = Template.of("area", TranslatableCaption.of("info.none").getComponent(player));
+ areaComponent.append(TranslatableCaption.of("info.none").toComponent(player));
}
+ tagBuilder.tag("area", Tag.inserting(areaComponent));
long creationDate = Long.parseLong(String.valueOf(timestamp));
SimpleDateFormat sdf = new SimpleDateFormat(Settings.Timeformat.DATE_FORMAT);
sdf.setTimeZone(TimeZone.getTimeZone(Settings.Timeformat.TIME_ZONE));
String newDate = sdf.format(creationDate);
- Template idTemplate = Template.of("id", this.getId().toString());
- Template aliasTemplate = Template.of("alias", alias);
- Template numTemplate = Template.of("num", String.valueOf(num));
- Template descTemplate = Template.of("desc", description);
- Template biomeTemplate = Template.of("biome", biome.toString().toLowerCase());
- Template ownerTemplate = Template.of("owner", owner);
- Template membersTemplate = Template.of("members", members);
- Template playerTemplate = Template.of("player", player.getName());
- Template trustedTemplate = Template.of("trusted", trusted);
- Template helpersTemplate = Template.of("helpers", members);
- Template deniedTemplate = Template.of("denied", denied);
- Template seenTemplate = Template.of("seen", seen);
- Template flagsTemplate = Template.of("flags", flags);
- Template creationTemplate = Template.of("creationdate", newDate);
- Template buildTemplate = Template.of("build", String.valueOf(build));
- Template sizeTemplate = Template.of("size", String.valueOf(getConnectedPlots().size()));
+ tagBuilder.tag("id", Tag.inserting(Component.text(getId().toString())));
+ tagBuilder.tag("alias", Tag.inserting(alias));
+ tagBuilder.tag("num", Tag.inserting(Component.text(num)));
+ tagBuilder.tag("desc", Tag.inserting(description));
+ tagBuilder.tag("biome", Tag.inserting(Component.text(biome.toString().toLowerCase())));
+ tagBuilder.tag("owner", Tag.inserting(owner));
+ tagBuilder.tag("members", Tag.inserting(members));
+ tagBuilder.tag("player", Tag.inserting(Component.text(player.getName())));
+ tagBuilder.tag("trusted", Tag.inserting(trusted));
+ tagBuilder.tag("denied", Tag.inserting(denied));
+ tagBuilder.tag("seen", Tag.inserting(seen));
+ tagBuilder.tag("flags", Tag.inserting(flags));
+ tagBuilder.tag("creationdate", Tag.inserting(Component.text(newDate)));
+ tagBuilder.tag("build", Tag.inserting(Component.text(build)));
+ tagBuilder.tag("size", Tag.inserting(Component.text(getConnectedPlots().size())));
String component = iInfo.getComponent(player);
if (component.contains("") || component.contains("")) {
TaskManager.runTaskAsync(() -> {
- Template ratingTemplate;
- Template likesTemplate;
if (Settings.Ratings.USE_LIKES) {
- ratingTemplate = Template.of(
- "rating",
+ tagBuilder.tag("rating", Tag.inserting(Component.text(
String.format("%.0f%%", Like.getLikesPercentage(this) * 100D)
- );
- likesTemplate = Template.of(
- "likes",
+ )));
+ tagBuilder.tag("likes", Tag.inserting(Component.text(
String.format("%.0f%%", Like.getLikesPercentage(this) * 100D)
- );
+ )));
} else {
int max = 10;
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
@@ -2970,70 +2975,34 @@ public class Plot {
.append(String.format("%.1f", ratings[i]));
prefix = ",";
}
- ratingTemplate = Template.of("rating", rating.toString());
+ tagBuilder.tag("rating", Tag.inserting(Component.text(rating.toString())));
} else {
double rating = this.getAverageRating();
if (Double.isFinite(rating)) {
- ratingTemplate = Template.of("rating", String.format("%.1f", rating) + '/' + max);
- } else {
- ratingTemplate = Template.of(
+ tagBuilder.tag(
"rating",
- TranslatableCaption.of("info.none").getComponent(player)
+ Tag.inserting(Component.text(String.format("%.1f", rating) + '/' + max))
+ );
+ } else {
+ tagBuilder.tag(
+ "rating", Tag.inserting(TranslatableCaption.of("info.none").toComponent(player))
);
}
}
- likesTemplate = Template.of("likes", "N/A");
+ tagBuilder.tag("likes", Tag.inserting(Component.text("N/A")));
}
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
- .parse(
+ .deserialize(
iInfo.getComponent(player),
- headerTemplate,
- areaTemplate,
- idTemplate,
- aliasTemplate,
- numTemplate,
- descTemplate,
- biomeTemplate,
- ownerTemplate,
- membersTemplate,
- playerTemplate,
- trustedTemplate,
- helpersTemplate,
- deniedTemplate,
- seenTemplate,
- flagsTemplate,
- buildTemplate,
- ratingTemplate,
- creationTemplate,
- sizeTemplate,
- likesTemplate,
- footerTemplate
+ tagBuilder.build()
))));
});
return;
}
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
- .parse(
+ .deserialize(
iInfo.getComponent(player),
- headerTemplate,
- areaTemplate,
- idTemplate,
- aliasTemplate,
- numTemplate,
- descTemplate,
- biomeTemplate,
- ownerTemplate,
- membersTemplate,
- playerTemplate,
- trustedTemplate,
- helpersTemplate,
- deniedTemplate,
- seenTemplate,
- flagsTemplate,
- buildTemplate,
- creationTemplate,
- sizeTemplate,
- footerTemplate
+ tagBuilder.build()
))));
}
);
diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
index a45451aeb..afca97b00 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java
@@ -66,12 +66,15 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
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.NotNull;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -91,7 +94,7 @@ import java.util.function.Consumer;
/**
* @author Jesse Boyd, Alexander Söderberg
*/
-public abstract class PlotArea {
+public abstract class PlotArea implements ComponentLike {
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + PlotArea.class.getSimpleName());
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
@@ -412,7 +415,7 @@ public abstract class PlotArea {
this.getFlagContainer().addAll(parseFlags(flags));
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.area_flags"),
- Template.of("flags", flags.toString())
+ TagResolver.resolver("flags", Tag.inserting(Component.text(flags.toString())))
);
this.spawnEggs = config.getBoolean("event.spawn.egg");
@@ -434,7 +437,7 @@ public abstract class PlotArea {
this.getRoadFlagContainer().addAll(parseFlags(roadflags));
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.road_flags"),
- Template.of("flags", roadflags.toString())
+ TagResolver.resolver("flags", Tag.inserting(Component.text(roadflags.toString())))
);
loadConfiguration(config);
@@ -527,6 +530,11 @@ public abstract class PlotArea {
}
}
+ @Override
+ public @NotNull Component asComponent() {
+ return Component.text(toString());
+ }
+
@Override
public int hashCode() {
if (this.hash != 0) {
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 68052f02c..a2eabf04b 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/PlotModificationManager.java
@@ -52,7 +52,9 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -394,7 +396,10 @@ public final class PlotModificationManager {
Caption[] lines = new Caption[]{TranslatableCaption.of("signs.owner_sign_line_1"), TranslatableCaption.of(
"signs.owner_sign_line_2"),
TranslatableCaption.of("signs.owner_sign_line_3"), TranslatableCaption.of("signs.owner_sign_line_4")};
- PlotSquared.platform().worldUtil().setSign(location, lines, Template.of("id", id), Template.of("owner", name));
+ PlotSquared.platform().worldUtil().setSign(location, lines, TagResolver.builder()
+ .tag("id", Tag.inserting(Component.text(id)))
+ .tag("owner", Tag.inserting(Component.text(name)))
+ .build());
}
}
@@ -504,7 +509,7 @@ public final class PlotModificationManager {
if (player != null) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
- Template.of("value", "Auto merge on claim")
+ TagResolver.resolver("value", Tag.inserting(Component.text("Auto merge on claim")))
);
}
return;
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 c15656847..b8b37cfdb 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
@@ -36,7 +36,9 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import java.util.Collection;
import java.util.HashMap;
@@ -75,8 +77,10 @@ public class CommentManager {
player.sendTitle(
StaticCaption.of(""),
TranslatableCaption.of("comment.inbox_notification"),
- Template.of("amount", Integer.toString(total)),
- Template.of("command", "/plot inbox")
+ TagResolver.builder()
+ .tag("amount", Tag.inserting(Component.text(total)))
+ .tag("command", Tag.inserting(Component.text("/plot inbox")))
+ .build()
);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java
index 69c635e2b..5df0c16ff 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/expiration/ExpireManager.java
@@ -27,7 +27,6 @@ package com.plotsquared.core.plot.expiration;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.caption.Caption;
-import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagAddEvent;
@@ -51,7 +50,9 @@ import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayDeque;
@@ -152,25 +153,17 @@ public class ExpireManager {
current.getCenter(pp::teleport);
metaDataAccess.remove();
Caption msg = TranslatableCaption.of("expiry.expired_options_clicky");
- Template numTemplate = Template.of("num", String.valueOf(num));
- Template areIsTemplate = Template.of("are_or_is", (num > 1 ? "plots are" : "plot is"));
- Template list_cmd = Template.of("list_cmd", "/plot list expired");
- Template plot = Template.of("plot", current.toString());
- Template cmd_del = Template.of("cmd_del", "/plot delete");
- Template cmd_keep_1d = Template.of("cmd_keep_1d", "/plot flag set keep 1d");
- Template cmd_keep = Template.of("cmd_keep", "/plot flag set keep true");
- Template cmd_no_show_expir = Template.of("cmd_no_show_expir", "/plot toggle clear-confirmation");
- pp.sendMessage(
- msg,
- numTemplate,
- areIsTemplate,
- list_cmd,
- plot,
- cmd_del,
- cmd_keep_1d,
- cmd_keep,
- cmd_no_show_expir
- );
+ TagResolver resolver = TagResolver.builder()
+ .tag("num", Tag.inserting(Component.text(num)))
+ .tag("are_or_is", Tag.inserting(Component.text(num > 1 ? "plots are" : "plot is")))
+ .tag("list_cmd", Tag.preProcessParsed("/plot list expired"))
+ .tag("plot", Tag.inserting(Component.text(current.toString())))
+ .tag("cmd_del", Tag.preProcessParsed("/plot delete"))
+ .tag("cmd_keep_1d", Tag.preProcessParsed("/plot flag set keep 1d"))
+ .tag("cmd_keep", Tag.preProcessParsed("/plot flag set keep true"))
+ .tag("cmd_no_show_expir", Tag.preProcessParsed("/plot toggle clear-confirmation"))
+ .build();
+ pp.sendMessage(msg, resolver);
return;
} else {
iter.remove();
@@ -436,7 +429,7 @@ public class ExpireManager {
if (player != null) {
player.sendMessage(
TranslatableCaption.of("trusted.plot_removed_user"),
- Templates.of("plot", plot.toString())
+ TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString())))
);
}
}
@@ -445,7 +438,7 @@ public class ExpireManager {
if (player != null) {
player.sendMessage(
TranslatableCaption.of("trusted.plot_removed_user"),
- Templates.of("plot", plot.toString())
+ TagResolver.resolver("plot", Tag.inserting(Component.text(plot.toString())))
);
}
}
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 bb32f77d9..f94d50f09 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
@@ -26,14 +26,14 @@
package com.plotsquared.core.plot.flag;
import com.plotsquared.core.configuration.caption.Caption;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
public class FlagParseException extends Exception {
private final PlotFlag, ?> flag;
private final String value;
private final Caption errorMessage;
- private final Template[] templates;
+ private final TagResolver[] tagResolvers;
/**
* Construct a new flag parse exception to indicate that an attempt to parse a plot
@@ -46,7 +46,7 @@ public class FlagParseException extends Exception {
*/
public FlagParseException(
final PlotFlag, ?> flag, final String value,
- final Caption errorMessage, final Template... args
+ final Caption errorMessage, final TagResolver... args
) {
super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.",
flag.getName(), value
@@ -54,7 +54,7 @@ public class FlagParseException extends Exception {
this.flag = flag;
this.value = value;
this.errorMessage = errorMessage;
- this.templates = args;
+ this.tagResolvers = args;
}
/**
@@ -89,8 +89,8 @@ public class FlagParseException extends Exception {
*
* @return Message templates.
*/
- public Template[] getTemplates() {
- return templates;
+ public TagResolver[] getTagResolvers() {
+ return tagResolvers;
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java
index a7678e756..30bf43a3c 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/PlotFlag.java
@@ -27,11 +27,11 @@ package com.plotsquared.core.plot.flag;
import com.google.common.base.Preconditions;
import com.plotsquared.core.configuration.caption.Caption;
+import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.Collections;
-import java.util.Objects;
/**
* A plot flag is any property that can be assigned
@@ -91,6 +91,10 @@ public abstract class PlotFlag> {
return flagName.toString();
}
+ public static > Component getFlagNameComponent(Class flagClass) {
+ return Component.text(getFlagName(flagClass));
+ }
+
/**
* Get the flag value
*
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java
index 5ac7d1b56..9fb676ae8 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/DenyTeleportFlag.java
@@ -30,7 +30,9 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -89,7 +91,10 @@ public class DenyTeleportFlag extends PlotFlag {
@@ -49,7 +51,7 @@ public class FeedFlag extends TimedFlag {
this,
input,
TranslatableCaption.of("invalid.not_a_number"),
- Template.of("value", input)
+ TagResolver.resolver("value", Tag.inserting(Component.text(input)))
);
}
if (parsed < 1) {
@@ -57,7 +59,7 @@ public class FeedFlag extends TimedFlag {
this,
input,
TranslatableCaption.of("invalid.number_not_positive"),
- Template.of("value", String.valueOf(parsed))
+ TagResolver.resolver("value", Tag.inserting(Component.text(parsed)))
);
}
return parsed;
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java
index 809512776..d89deacee 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/HealFlag.java
@@ -28,7 +28,9 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.types.TimedFlag;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
public class HealFlag extends TimedFlag {
@@ -49,7 +51,7 @@ public class HealFlag extends TimedFlag {
this,
input,
TranslatableCaption.of("invalid.not_a_number"),
- Template.of("value", input)
+ TagResolver.resolver("value", Tag.inserting(Component.text(input)))
);
}
if (parsed < 1) {
@@ -57,7 +59,7 @@ public class HealFlag extends TimedFlag {
this,
input,
TranslatableCaption.of("invalid.number_not_positive"),
- Template.of("value", String.valueOf(parsed))
+ TagResolver.resolver("value", Tag.inserting(Component.text(parsed)))
);
}
return parsed;
diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/TitlesFlag.java b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/TitlesFlag.java
index 03e6834b1..573c32c06 100644
--- a/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/TitlesFlag.java
+++ b/Core/src/main/java/com/plotsquared/core/plot/flag/implementations/TitlesFlag.java
@@ -28,7 +28,9 @@ package com.plotsquared.core.plot.flag.implementations;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.plot.flag.FlagParseException;
import com.plotsquared.core.plot.flag.PlotFlag;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -54,7 +56,7 @@ public class TitlesFlag extends PlotFlag
this,
input,
TranslatableCaption.of("flags.flag_error_enum"),
- Template.of("list", "none, true, false")
+ TagResolver.resolver("list", Tag.inserting(Component.text("none, true, false")))
);
}
return flagOf(titlesFlagValue);
diff --git a/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java b/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java
index d72472723..a90e330c7 100644
--- a/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java
+++ b/Core/src/main/java/com/plotsquared/core/queue/subscriber/DefaultProgressSubscriber.java
@@ -37,7 +37,9 @@ import com.plotsquared.core.queue.ChunkCoordinator;
import com.plotsquared.core.util.task.PlotSquaredTask;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.annotation.Nullable;
@@ -120,7 +122,10 @@ public class DefaultProgressSubscriber implements ProgressSubscriber {
}
actor.sendMessage(
caption,
- Template.of("progress", String.format("%.2f", this.progress.doubleValue() * 100))
+ TagResolver.resolver(
+ "progress",
+ Tag.inserting(Component.text(String.format("%.2f", this.progress.doubleValue() * 100)))
+ )
);
}, interval), wait);
}
diff --git a/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java b/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java
index 40ec3f2b4..cf90e540c 100644
--- a/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java
+++ b/Core/src/main/java/com/plotsquared/core/setup/CommonSetupSteps.java
@@ -39,7 +39,9 @@ import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.StringMan;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -213,7 +215,10 @@ public enum CommonSetupSteps implements SetupStep {
}
if (PlotSquared.platform().worldUtil().isWorld(argument)) {
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(argument)) {
- plotPlayer.sendMessage(TranslatableCaption.of("setup.setup_world_taken"), Template.of("value", argument));
+ plotPlayer.sendMessage(
+ TranslatableCaption.of("setup.setup_world_taken"),
+ TagResolver.resolver("value", Tag.inserting(Component.text(argument)))
+ );
return this;
}
plotPlayer.sendMessage(TranslatableCaption.of("setup.setup_world_apply_plotsquared"));
diff --git a/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java b/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java
index f9f04d29e..d01f73ffb 100644
--- a/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java
+++ b/Core/src/main/java/com/plotsquared/core/setup/SettingsNodeStep.java
@@ -31,7 +31,9 @@ import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.TabCompletions;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -84,10 +86,15 @@ public class SettingsNodeStep implements SetupStep {
public void announce(PlotPlayer> plotPlayer) {
plotPlayer.sendMessage(
TranslatableCaption.of("setup.setup_step"),
- Template.of("step", String.valueOf(this.getId() + 1)),
- Template.of("description", this.configurationNode.getDescription().getComponent(plotPlayer)),
- Template.of("type", this.configurationNode.getType().getType()),
- Template.of("value", String.valueOf(this.configurationNode.getDefaultValue()))
+ TagResolver.builder()
+ .tag("step", Tag.inserting(Component.text(this.getId() + 1)))
+ .tag(
+ "description",
+ Tag.inserting(this.configurationNode.getDescription().toComponent(plotPlayer))
+ )
+ .tag("type", Tag.inserting(Component.text(this.configurationNode.getType().getType())))
+ .tag("value", Tag.inserting(Component.text(this.configurationNode.getDefaultValue().toString())))
+ .build()
);
}
diff --git a/Core/src/main/java/com/plotsquared/core/util/ComponentMan.java b/Core/src/main/java/com/plotsquared/core/util/ComponentMan.java
new file mode 100644
index 000000000..3f9f83e64
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/util/ComponentMan.java
@@ -0,0 +1,55 @@
+/*
+ * _____ _ _ _____ _
+ * | __ \| | | | / ____| | |
+ * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
+ * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
+ * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
+ * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
+ * | |
+ * |_|
+ * PlotSquared plot management system for Minecraft
+ * Copyright (C) 2014 - 2022 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 net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
+import net.kyori.adventure.text.TextComponent;
+
+import java.util.Collection;
+
+public class ComponentMan {
+
+ public static ComponentLike join(Collection extends ComponentLike> components, Component delimiter) {
+ return join(components.toArray(ComponentLike[]::new), delimiter);
+ }
+
+ public static Component join(Component[] components, Component delimiter) {
+ return join(components, delimiter);
+ }
+
+ public static Component join(ComponentLike[] components, Component delimiter) {
+ TextComponent.Builder builder = Component.text();
+ for (int i = 0, j = components.length; i < j; i++) {
+ if (i > 0) {
+ builder.append(delimiter);
+ }
+ builder.append(components[i]);
+ }
+ return builder.build();
+ }
+
+}
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 be653f45d..b7fe15e79 100644
--- a/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java
+++ b/Core/src/main/java/com/plotsquared/core/util/EventDispatcher.java
@@ -80,7 +80,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -380,7 +382,7 @@ public class EventDispatcher {
if (notifyPerms) {
player.sendMessage(
TranslatableCaption.of("commandconfig.flag_tutorial_usage"),
- Template.of("flag", PlaceFlag.getFlagName(UseFlag.class))
+ TagResolver.resolver("flag", Tag.inserting(PlaceFlag.getFlagNameComponent(UseFlag.class)))
);
}
return false;
@@ -447,8 +449,14 @@ public class EventDispatcher {
if (notifyPerms) {
player.sendMessage(
TranslatableCaption.of("commandconfig.flag_tutorial_usage"),
- Template.of("flag", PlotFlag.getFlagName(MobPlaceFlag.class)
- + '/' + PlotFlag.getFlagName(PlaceFlag.class))
+ TagResolver.resolver(
+ "flag",
+ Tag.inserting(
+ PlotFlag.getFlagNameComponent(MobPlaceFlag.class)
+ .append(Component.text("/"))
+ .append(PlotFlag.getFlagNameComponent(PlaceFlag.class))
+ )
+ )
);
}
return false;
@@ -483,8 +491,14 @@ public class EventDispatcher {
if (notifyPerms) {
player.sendMessage(
TranslatableCaption.of("commandconfig.flag_tutorial_usage"),
- Template.of("flag", PlotFlag.getFlagName(MiscPlaceFlag.class)
- + '/' + PlotFlag.getFlagName(PlaceFlag.class))
+ TagResolver.resolver(
+ "flag",
+ Tag.inserting(
+ PlotFlag.getFlagNameComponent(MiscPlaceFlag.class)
+ .append(Component.text("/"))
+ .append(PlotFlag.getFlagNameComponent(PlaceFlag.class))
+ )
+ )
);
}
return false;
diff --git a/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java b/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java
index d5818f735..90c5747ee 100644
--- a/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java
+++ b/Core/src/main/java/com/plotsquared/core/util/LegacyConverter.java
@@ -31,7 +31,9 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.plot.BlockBucket;
import com.sk89q.worldedit.world.block.BlockState;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -119,8 +121,10 @@ public final class LegacyConverter {
this.setString(section, key, bucket);
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("legacyconfig.legacy_config_replaced"),
- Template.of("value1", block),
- Template.of("value2", bucket.toString())
+ TagResolver.builder()
+ .tag("value1", Tag.inserting(Component.text(block)))
+ .tag("value2", Tag.inserting(Component.text(bucket.toString())))
+ .build()
);
}
@@ -135,8 +139,10 @@ public final class LegacyConverter {
ConsolePlayer.getConsole()
.sendMessage(
TranslatableCaption.of("legacyconfig.legacy_config_replaced"),
- Template.of("value1", plotBlockArrayString(blocks)),
- Template.of("value2", bucket.toString())
+ TagResolver.builder()
+ .tag("value1", Tag.inserting(Component.text(plotBlockArrayString(blocks))))
+ .tag("value2", Tag.inserting(Component.text(bucket.toString())))
+ .build()
);
}
diff --git a/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java b/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java
index e2db0dc7f..2be9de3c3 100644
--- a/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java
+++ b/Core/src/main/java/com/plotsquared/core/util/PatternUtil.java
@@ -41,7 +41,9 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@@ -91,7 +93,7 @@ public class PatternUtil {
} catch (InputParseException e) {
throw new Command.CommandException(
TranslatableCaption.of("invalid.not_valid_block"),
- Template.of("value", e.getMessage())
+ TagResolver.resolver("value", Tag.inserting(Component.text(e.getMessage())))
);
}
}
diff --git a/Core/src/main/java/com/plotsquared/core/util/Permissions.java b/Core/src/main/java/com/plotsquared/core/util/Permissions.java
index 41701b973..7304c21f4 100644
--- a/Core/src/main/java/com/plotsquared/core/util/Permissions.java
+++ b/Core/src/main/java/com/plotsquared/core/util/Permissions.java
@@ -30,7 +30,9 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.permissions.PermissionHolder;
import com.plotsquared.core.player.PlotPlayer;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@@ -96,7 +98,7 @@ public class Permissions {
if (notify) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
- Template.of("node", permission)
+ TagResolver.resolver("node", Tag.inserting(Component.text(permission)))
);
}
return false;
diff --git a/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java b/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java
index 11be11a43..9e8ed2cbd 100644
--- a/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java
+++ b/Core/src/main/java/com/plotsquared/core/util/PlayerManager.java
@@ -37,9 +37,11 @@ import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -121,18 +123,18 @@ public abstract class PlayerManager, T> {
*/
public static @NonNull Component getPlayerList(final @NonNull Collection uuids, LocaleHolder localeHolder) {
if (uuids.isEmpty()) {
- return MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(localeHolder));
+ return TranslatableCaption.of("info.none").toComponent(localeHolder).asComponent();
}
final List players = new LinkedList<>();
- final List users = new LinkedList<>();
+ final List users = new LinkedList<>();
for (final UUID uuid : uuids) {
if (uuid == null) {
- users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.none").getComponent(localeHolder)));
+ users.add(TranslatableCaption.of("info.none").toComponent(localeHolder));
} else if (DBFunc.EVERYONE.equals(uuid)) {
- users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.everyone").getComponent(localeHolder)));
+ users.add(TranslatableCaption.of("info.everyone").toComponent(localeHolder));
} else if (DBFunc.SERVER.equals(uuid)) {
- users.add(MINI_MESSAGE.stripTokens(TranslatableCaption.of("info.console").getComponent(localeHolder)));
+ users.add(TranslatableCaption.of("info.console").toComponent(localeHolder));
} else {
players.add(uuid);
}
@@ -141,7 +143,7 @@ public abstract class PlayerManager, T> {
try {
for (final UUIDMapping mapping : PlotSquared.get().getImpromptuUUIDPipeline()
.getNames(players).get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS)) {
- users.add(mapping.getUsername());
+ users.add(Component.text(mapping.getUsername()));
}
} catch (final Exception e) {
e.printStackTrace();
@@ -151,9 +153,15 @@ public abstract class PlayerManager
, T> {
TextComponent.Builder list = Component.text();
for (int x = 0; x < users.size(); x++) {
if (x + 1 == uuids.size()) {
- list.append(MINI_MESSAGE.parse(c, Template.of("user", users.get(x))));
+ list.append(MINI_MESSAGE.deserialize(c, TagResolver.resolver(
+ "user",
+ Tag.inserting(users.get(x))
+ )));
} else {
- list.append(MINI_MESSAGE.parse(c + ", ", Template.of("user", users.get(x))));
+ list.append(MINI_MESSAGE.deserialize(c + ", ", TagResolver.resolver(
+ "user",
+ Tag.inserting(users.get(x))
+ )));
}
}
return list.asComponent();
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 0674c7c82..3474e3bc1 100644
--- a/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java
+++ b/Core/src/main/java/com/plotsquared/core/util/WorldUtil.java
@@ -44,7 +44,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.entity.EntityType;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.checkerframework.checker.index.qual.NonNegative;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -162,7 +162,7 @@ public abstract class WorldUtil {
public abstract void setSign(
@NonNull Location location,
@NonNull Caption[] lines,
- @NonNull Template... replacements
+ @NonNull TagResolver... replacements
);
/**
diff --git a/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpObject.java b/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpObject.java
index 4b2f72bbd..b478efa9c 100644
--- a/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpObject.java
+++ b/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpObject.java
@@ -27,33 +27,35 @@ package com.plotsquared.core.util.helpmenu;
import com.plotsquared.core.command.Argument;
import com.plotsquared.core.command.Command;
-import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.StringMan;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
+import org.jetbrains.annotations.NotNull;
-public class HelpObject {
+public class HelpObject implements ComponentLike {
- static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
+ static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
- private final String rendered;
+ private final Component rendered;
public HelpObject(final Command command, final String label, final PlotPlayer> audience) {
- rendered = MINI_MESSAGE.serialize(MINI_MESSAGE.parse(
+ rendered = MINI_MESSAGE.deserialize(
TranslatableCaption.of("help.help_item").getComponent(audience),
- Template.of("usage", command.getUsage().replace("{label}", label)),
- Template.of("alias", command.getAliases().isEmpty() ? "" : StringMan.join(command.getAliases(), " | ")),
- Templates.of(audience, "desc", command.getDescription()),
- Template.of("arguments", buildArgumentList(command.getRequiredArguments())),
- Template.of("label", label)
- ));
- }
-
- @Override
- public String toString() {
- return rendered;
+ TagResolver.builder()
+ .tag("usage", Tag.inserting(Component.text(command.getUsage().replace("{label}", label))))
+ .tag("alias", Tag.inserting(Component.text(
+ command.getAliases().isEmpty() ? "" : StringMan.join(command.getAliases(), " | ")
+ )))
+ .tag("desc", Tag.inserting(command.getDescription().toComponent(audience)))
+ .tag("arguments", Tag.inserting(Component.text(buildArgumentList(command.getRequiredArguments()))))
+ .tag("label", Tag.inserting(Component.text(label)))
+ .build()
+ );
}
private String buildArgumentList(final Argument>[] arguments) {
@@ -68,4 +70,9 @@ public class HelpObject {
return arguments.length > 0 ? builder.substring(0, builder.length() - 1) : "";
}
+ @Override
+ public @NotNull Component asComponent() {
+ return this.rendered;
+ }
+
}
diff --git a/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpPage.java b/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpPage.java
index b01cbb1e1..67dd7025d 100644
--- a/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpPage.java
+++ b/Core/src/main/java/com/plotsquared/core/util/helpmenu/HelpPage.java
@@ -29,50 +29,46 @@ import com.plotsquared.core.command.CommandCategory;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
-import com.plotsquared.core.util.StringMan;
+import com.plotsquared.core.util.ComponentMan;
+import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
-import net.kyori.adventure.text.minimessage.Template;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import java.util.ArrayList;
import java.util.List;
public class HelpPage {
- private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
+ private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
private final List helpObjects;
- private final Template catTemplate;
- private final Template curTemplate;
- private final Template maxTemplate;
+ private final TagResolver pageHeaderResolver;
public HelpPage(CommandCategory category, int currentPage, int maxPages) {
this.helpObjects = new ArrayList<>();
- this.catTemplate = Template.of("category", category == null ? "ALL" : category.name());
- this.curTemplate = Template.of("current", String.valueOf(currentPage + 1));
- this.maxTemplate = Template.of("max", String.valueOf(maxPages + 1));
+ this.pageHeaderResolver = TagResolver.builder()
+ .tag("category", Tag.inserting(Component.text(category == null ? "ALL" : category.name())))
+ .tag("current", Tag.inserting(Component.text(currentPage + 1)))
+ .tag("max", Tag.inserting(Component.text(maxPages + 1)))
+ .build();
}
public void render(PlotPlayer> player) {
if (this.helpObjects.size() < 1) {
player.sendMessage(TranslatableCaption.of("help.no_permission"));
} else {
- Template header = Template.of("header", TranslatableCaption.of("help.help_header").getComponent(player));
- Template page_header = Template.of(
- "page_header",
- MINI_MESSAGE.parse(
+ TagResolver contentResolver = TagResolver.builder()
+ .tag("header", Tag.inserting(TranslatableCaption.of("help.help_header").toComponent(player)))
+ .tag("page_header", Tag.inserting(MINI_MESSAGE.deserialize(
TranslatableCaption.of("help.help_page_header").getComponent(player),
- catTemplate,
- curTemplate,
- maxTemplate
- )
- );
- Template help_objects = Template.of("help_objects", StringMan.join(this.helpObjects, "\n"));
- Template footer = Template.of("footer", TranslatableCaption.of("help.help_footer").getComponent(player));
+ pageHeaderResolver
+ )))
+ .tag("help_objects", Tag.inserting(ComponentMan.join(this.helpObjects, Component.text("\n"))))
+ .tag("footer", Tag.inserting(TranslatableCaption.of("help.help_footer").toComponent(player)))
+ .build();
player.sendMessage(
StaticCaption.of("\n\n\n"),
- header,
- page_header,
- help_objects,
- footer
+ contentResolver
);
}
}
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 f832061f5..45a43eaf1 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
@@ -80,8 +80,7 @@ public final class PlaceholderRegistry {
* @return a legacy-formatted string.
*/
private static String legacyComponent(TranslatableCaption caption, LocaleHolder localeHolder) {
- Component component = MiniMessage.get().parse(caption.getComponent(localeHolder));
- return PlotSquared.platform().toLegacyPlatformString(component);
+ return PlotSquared.platform().toLegacyPlatformString(caption.toComponent(localeHolder).asComponent());
}
private void registerDefault() {
diff --git a/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java b/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java
index 8f87ec11e..44b33eeac 100644
--- a/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java
+++ b/Core/src/main/java/com/plotsquared/core/util/task/AutoClaimFinishTask.java
@@ -25,7 +25,6 @@
*/
package com.plotsquared.core.util.task;
-import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotMergeEvent;
import com.plotsquared.core.events.Result;
@@ -36,6 +35,9 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.EventDispatcher;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.minimessage.tag.Tag;
+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import java.util.concurrent.Callable;
@@ -75,7 +77,7 @@ public final class AutoClaimFinishTask implements Callable {
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
- Templates.of("value", "Auto Merge")
+ TagResolver.resolver("value", Tag.inserting(Component.text("Auto Merge")))
);
} else {
if (plot.getPlotModificationManager().autoMerge(event.getDir(), event.getMax(), player.getUUID(), player, true)) {
diff --git a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java
index 9ab11138a..e3d833fd9 100644
--- a/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java
+++ b/Core/src/main/java/com/plotsquared/core/uuid/UUIDPipeline.java
@@ -352,7 +352,7 @@ public class UUIDPipeline {
for (final UUID uuid : remainingRequests) {
mappings.add(new UUIDMapping(
uuid,
- MINI_MESSAGE.stripTokens(TranslatableCaption
+ MINI_MESSAGE.escapeTags(TranslatableCaption
.of("info.unknown")
.getComponent(ConsolePlayer.getConsole()))
));
diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json
index bc189c8c9..44f0e385c 100644
--- a/Core/src/main/resources/lang/messages_en.json
+++ b/Core/src/main/resources/lang/messages_en.json
@@ -21,8 +21,8 @@
"web.generating_link": "Processing plot ",
"web.plot_merged": "This plot is merged and therefore cannot be downloaded ",
"web.generating_link_failed": "Failed to generate download link for plot ! ",
- "web.generation_link_success": "Download: > \n Deletion: > \nAttention: Opening the deletion link will delete the file immediately. ",
- "web.generation_link_success_legacy_world": "Download: > ",
+ "web.generation_link_success": "Download: '> \n Deletion: '> \nAttention: Opening the deletion link will delete the file immediately. ",
+ "web.generation_link_success_legacy_world": "Download: '> ",
"web.save_failed": "Failed to save. ",
"web.load_null": "Please use to get a list of schematics. ",
"web.load_failed": "Failed to load schematic. ",
@@ -281,7 +281,7 @@
"debugexec.expiry_already_started": "Plot expiry task already started. ",
"debugexec.script_list_item": "[ ] ",
"debugexec.analyze_done": "Done. Use for more information. ",
- "expiry.expired_options_clicky": " expired: >\"> \n - >\">Delete this () \n - >\">Remind later () \n - >\">Keep this () \n - >\">Don't show me this () ",
+ "expiry.expired_options_clicky": " expired: '>'> \n - '>'>Delete this () \n - '>'>Remind later () \n - '>'>Keep this () \n - '>'>Don't show me this () ",
"debugimportworlds.single_plot_area": "Must be a single plot area. ",
"debugimportworlds.world_container": "World container must be configured to be a separate directory to your base files. ",
"debugroadregen.regen_done": "Regenerating plot south/east roads: \n - Result: Success! ",
@@ -373,17 +373,17 @@
"info.plot_no_description": "No description set. ",
"info.plot_caps_header": "--------- CAPS ---------",
"info.plot_caps_format": "- Cap Type: | Status: / ( % ) ",
- "info.plot_list_item": ">\">[ ] > \"> - ",
+ "info.plot_list_item": "'>'>[ ] '> '> - ",
"info.plot_list_no_owner": " ",
"info.plot_list_owned_by": " ",
"info.plot_list_added_to": " ",
"info.plot_list_denied_on": " ",
"info.plot_list_default": " ",
- "info.plot_list_player_online": "Online\"> ",
- "info.plot_list_player_offline": "Offline \"> ",
+ "info.plot_list_player_online": "Online'> ",
+ "info.plot_list_player_offline": "Offline '> ",
"info.area_info_format": "\nName: \nType: \nTerrain: \nUsage: % \nClaimed: \nClusters: \nRegion: \nGenerator: \n",
"info.area_list_tooltip": "Claimed= \nUsage= \nClusters= \nRegion= \nGenerator= ",
- "info.area_list_item": ">\">[ ] >\"> - : ",
+ "info.area_list_item": "'>'>[ ] '>'> - : ",
"working.generating_component": "Started generating component from your settings. ",
"working.clearing_done": "Plot has been cleared! Took ms . ",
"working.deleting_done": "Plot has been deleted! Took ms . ",
@@ -400,7 +400,7 @@
"list.area_list_header_paged": "(Page / ) List of areas ",
"list.plot_list_header_paged": "(Page / ) List of plots ",
"list.plot_list_header": "List of plots. ",
- "list.page_turn": ">Back | >Next ",
+ "list.page_turn": "'>Back | '>Next ",
"chat.plot_chat_spy_format": "[Plot Spy ] [; ] : ",
"chat.plot_chat_format": "[Plot Chat ] [; ] : ",
"chat.plot_chat_forced": "This world forces everyone to use plot chat. ",
@@ -506,7 +506,7 @@
"flag.flag_info_header": "--------- PlotSquared Flags