refactor!: Update minimessage implementation

This commit is contained in:
NotMyFault 2021-12-15 01:20:26 +01:00
parent 8859871e89
commit fda01502b2
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
215 changed files with 2401 additions and 2306 deletions

View File

@ -68,7 +68,7 @@ import com.plotsquared.core.util.task.TaskTime;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@ -282,16 +282,16 @@ public class BlockEventListener implements Listener {
.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
pp.sendMessage(
TranslatableCaption.of("height.height_limit"),
Template.of("minHeight", String.valueOf(area.getMinBuildHeight())),
Template.of("maxHeight", String.valueOf(area.getMaxBuildHeight()))
TranslatableCaption.miniMessage("height.height_limit"),
Placeholder.miniMessage("minHeight", String.valueOf(area.getMinBuildHeight())),
Placeholder.miniMessage("maxHeight", String.valueOf(area.getMaxBuildHeight()))
);
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
);
event.setCancelled(true);
return;
@ -307,8 +307,8 @@ public class BlockEventListener implements Listener {
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
);
event.setCancelled(true);
plot.debug(player.getName() + " could not place " + event.getBlock().getType()
@ -318,7 +318,7 @@ public class BlockEventListener implements Listener {
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("done.building_restricted")
TranslatableCaption.miniMessage("done.building_restricted")
);
event.setCancelled(true);
return;
@ -334,8 +334,8 @@ public class BlockEventListener implements Listener {
}
} else if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
);
event.setCancelled(true);
}
@ -356,8 +356,8 @@ public class BlockEventListener implements Listener {
if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL))
);
event.setCancelled(true);
return;
@ -367,9 +367,9 @@ public class BlockEventListener implements Listener {
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
plotPlayer.sendMessage(
TranslatableCaption.of("height.height_limit"),
Template.of("minHeight", String.valueOf(area.getMinBuildHeight())),
Template.of("maxHeight", String.valueOf(area.getMaxBuildHeight()))
TranslatableCaption.miniMessage("height.height_limit"),
Placeholder.miniMessage("minHeight", String.valueOf(area.getMinBuildHeight())),
Placeholder.miniMessage("maxHeight", String.valueOf(area.getMaxBuildHeight()))
);
}
if (!plot.hasOwner()) {
@ -393,14 +393,14 @@ public class BlockEventListener implements Listener {
return;
}
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("done.building_restricted")
TranslatableCaption.miniMessage("done.building_restricted")
);
event.setCancelled(true);
return;
@ -419,8 +419,8 @@ public class BlockEventListener implements Listener {
}
}
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
);
event.setCancelled(true);
}
@ -1094,24 +1094,24 @@ public class BlockEventListener implements Listener {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
);
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
);
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
);
event.setCancelled(true);
}

View File

@ -44,7 +44,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Chunk;
import org.bukkit.block.Block;
import org.bukkit.block.TileState;
@ -301,8 +301,8 @@ public class PaperListener implements Listener {
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
plotPlayer.sendMessage(
TranslatableCaption.of("errors.tile_entity_cap_reached"),
Template.of("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))
TranslatableCaption.miniMessage("errors.tile_entity_cap_reached"),
Placeholder.miniMessage("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))
);
event.setCancelled(true);
event.setBuild(false);

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.block.Banner;
import org.bukkit.block.Beacon;
import org.bukkit.block.Bed;
@ -83,8 +83,8 @@ public class PaperListener113 extends PaperListener {
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
plotPlayer.sendMessage(
TranslatableCaption.of("errors.tile_entity_cap_reached"),
Template.of("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))
TranslatableCaption.miniMessage("errors.tile_entity_cap_reached"),
Placeholder.miniMessage("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))
);
event.setCancelled(true);
event.setBuild(false);

View File

@ -87,7 +87,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.FluidCollisionMode;
@ -309,7 +309,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
perm = "plots.admin.command.blocked-cmds.road";
}
if (!Permissions.hasPermission(plotPlayer, perm)) {
plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked"));
plotPlayer.sendMessage(TranslatableCaption.miniMessage("blockedcmds.command_blocked"));
event.setCancelled(true);
}
return;
@ -362,11 +362,11 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (pp.hasPermission(Permission.PERMISSION_ADMIN_UPDATE_NOTIFICATION.toString()) && Settings.Enabled_Components.UPDATE_NOTIFICATIONS
&& PremiumVerification.isPremium() && UpdateUtility.hasUpdate) {
Caption boundary = TranslatableCaption.of("update.update_boundary");
Caption updateNotification = TranslatableCaption.of("update.update_notification");
Template internalVersion = Template.of("p2version", UpdateUtility.internalVersion.versionString());
Template spigotVersion = Template.of("spigotversion", UpdateUtility.spigotVersion);
Template downloadUrl = Template.of("downloadurl", "https://www.spigotmc.org/resources/77506/updates");
Caption boundary = TranslatableCaption.miniMessage("update.update_boundary");
Caption updateNotification = TranslatableCaption.miniMessage("update.update_notification");
Placeholder<?> internalVersion = Placeholder.miniMessage("p2version", UpdateUtility.internalVersion.versionString());
Placeholder<?> spigotVersion = Placeholder.miniMessage("spigotversion", UpdateUtility.spigotVersion);
Placeholder<?> downloadUrl = Placeholder.miniMessage("downloadurl", "https://www.spigotmc.org/resources/77506/updates");
pp.sendMessage(boundary);
pp.sendMessage(updateNotification, internalVersion, spigotVersion, downloadUrl);
pp.sendMessage(boundary);
@ -418,8 +418,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
.getHomeSynchronous()
.equals(BukkitUtil.adaptComplete(to)))) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
);
event.setCancelled(true);
}
@ -507,7 +507,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(player);
// Cancel teleport
if (TaskManager.removeFromTeleportQueue(pp.getName())) {
pp.sendMessage(TranslatableCaption.of("teleport.teleport_failed"));
pp.sendMessage(TranslatableCaption.miniMessage("teleport.teleport_failed"));
}
// Set last location
Location location = BukkitUtil.adapt(to);
@ -534,8 +534,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !kickAccess.get().orElse(false)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED))
);
this.tmpTeleport = false;
if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) {
@ -552,8 +552,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
ForceFieldListener.handleForcefield(player, pp, now);
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
);
this.tmpTeleport = false;
to.setX(from.getBlockX());
@ -571,9 +571,9 @@ public class PlayerEventListener extends PlotListener implements Listener {
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.denied"));
pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (x2 < -border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
@ -581,13 +581,13 @@ public class PlayerEventListener extends PlotListener implements Listener {
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.denied"));
pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (((x1 = MathMan.roundInt(from.getX())) >= border && x2 <= border) || (x1 <= -border && x2 >= -border)) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
pp.sendMessage(TranslatableCaption.of("border.bypass.entered"));
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.entered"));
}
}
}
@ -597,7 +597,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
BukkitPlayer pp = BukkitUtil.adapt(player);
// Cancel teleport
if (TaskManager.removeFromTeleportQueue(pp.getName())) {
pp.sendMessage(TranslatableCaption.of("teleport.teleport_failed"));
pp.sendMessage(TranslatableCaption.miniMessage("teleport.teleport_failed"));
}
// Set last location
Location location = BukkitUtil.adapt(to);
@ -624,8 +624,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
pp.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_KICK)) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !kickAccess.get().orElse(false)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_EXIT_DENIED))
);
this.tmpTeleport = false;
if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) {
@ -642,8 +642,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
ForceFieldListener.handleForcefield(player, pp, now);
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_ENTRY_DENIED))
);
this.tmpTeleport = false;
player.teleport(from);
@ -662,9 +662,9 @@ public class PlayerEventListener extends PlotListener implements Listener {
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.denied"));
pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (z2 < -border && this.tmpTeleport) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
@ -672,13 +672,13 @@ public class PlayerEventListener extends PlotListener implements Listener {
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmpTeleport = true;
pp.sendMessage(TranslatableCaption.of("border.denied"));
pp.sendMessage(TranslatableCaption.miniMessage("border.denied"));
} else {
pp.sendMessage(TranslatableCaption.of("border.bypass.exited"));
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.exited"));
}
} else if (((z1 = MathMan.roundInt(from.getZ())) >= border && z2 <= border) || (z1 <= -border && z2 >= -border)) {
if (Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
pp.sendMessage(TranslatableCaption.of("border.bypass.entered"));
pp.sendMessage(TranslatableCaption.miniMessage("border.bypass.entered"));
}
}
}
@ -727,45 +727,45 @@ public class PlayerEventListener extends PlotListener implements Listener {
String sender = event.getPlayer().getDisplayName();
PlotId id = plot.getId();
String worldName = plot.getWorldName();
Caption msg = TranslatableCaption.of("chat.plot_chat_format");
Template msgTemplate;
Template worldNameTemplate = Template.of("world", worldName);
Template plotTemplate = Template.of("plot_id", id.toString());
Template senderTemplate = Template.of("sender", sender);
Caption msg = TranslatableCaption.miniMessage("chat.plot_chat_format");
Placeholder<?> msgTemplate;
Placeholder<?> worldNameTemplate = Placeholder.miniMessage("world", worldName);
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot_id", id.toString());
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.
// In both cases, we want to use a Component Template to ensure that the player cannot use any placeholders in their message on purpose
// In both cases, we want to use a Component Template to ensure that the player cannot use any of 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
// allowing colour.
if (plotPlayer.hasPermission("plots.chat.color")) {
msgTemplate = Template
.of(
msgTemplate = Placeholder
.miniMessage(
"msg",
BukkitUtil.LEGACY_COMPONENT_SERIALIZER.deserialize(ChatColor.translateAlternateColorCodes(
'&',
message
))
)).toString()
);
} else {
msgTemplate = Template.of("msg", BukkitUtil.MINI_MESSAGE.deserialize(
ChatColor.stripColor(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(Component.text(message)))));
msgTemplate = Placeholder.miniMessage("msg", BukkitUtil.MINI_MESSAGE.deserialize(
ChatColor.stripColor(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(Component.text(message)))).toString());
}
for (PlotPlayer<?> receiver : plotRecipients) {
receiver.sendMessage(msg, worldNameTemplate, msgTemplate, plotTemplate, senderTemplate);
}
if (!spies.isEmpty()) {
Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format");
Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY());
Template spysenderTemplate = Template.of("sender", sender);
Template spymessageTemplate = Template.of("msg", Component.text(message));
Caption spymsg = TranslatableCaption.miniMessage("chat.plot_chat_spy_format");
Placeholder<?> plotidTemplate = Placeholder.miniMessage("plot_id", id.getX() + ";" + id.getY());
Placeholder<?> spysenderTemplate = Placeholder.miniMessage("sender", sender);
Placeholder<?> spymessageTemplate = Placeholder.miniMessage("msg", Component.text(message).toString());
for (PlotPlayer<?> player : spies) {
player.sendMessage(spymsg, worldNameTemplate, plotidTemplate, spysenderTemplate, spymessageTemplate);
}
}
if (Settings.Chat.LOG_PLOTCHAT_TO_CONSOLE) {
Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format");
Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY());
Template spysenderTemplate = Template.of("sender", sender);
Template spymessageTemplate = Template.of("msg", Component.text(message));
Caption spymsg = TranslatableCaption.miniMessage("chat.plot_chat_spy_format");
Placeholder<?> plotidTemplate = Placeholder.miniMessage("plot_id", id.getX() + ";" + id.getY());
Placeholder<?> spysenderTemplate = Placeholder.miniMessage("sender", sender);
Placeholder<?> spymessageTemplate = Placeholder.miniMessage("msg", Component.text(message).toString());
ConsolePlayer.getConsole().sendMessage(spymsg, worldNameTemplate, plotidTemplate, spysenderTemplate,
spymessageTemplate
);
@ -920,16 +920,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
);
cancelled = true;
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
);
cancelled = true;
}
@ -938,8 +938,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
);
cancelled = true;
}
@ -976,8 +976,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions
.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
);
e.setCancelled(true);
}
@ -985,7 +985,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("done.building_restricted")
TranslatableCaption.miniMessage("done.building_restricted")
);
e.setCancelled(true);
return;
@ -994,8 +994,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
);
e.setCancelled(true);
}
@ -1009,8 +1009,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
);
e.setCancelled(true);
plot.debug(pp.getName() + " could not interact with " + entity.getType()
@ -1225,8 +1225,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
return;
}
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
);
event.setCancelled(true);
} else if (!plot.hasOwner()) {
@ -1234,8 +1234,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
return;
}
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
);
event.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) {
@ -1250,14 +1250,14 @@ public class PlayerEventListener extends PlotListener implements Listener {
return;
}
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("done.building_restricted")
TranslatableCaption.miniMessage("done.building_restricted")
);
event.setCancelled(true);
}
@ -1297,8 +1297,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
return;
}
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
);
event.setCancelled(true);
} else if (!plot.hasOwner()) {
@ -1306,8 +1306,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
return;
}
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
);
event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) {
@ -1323,14 +1323,14 @@ public class PlayerEventListener extends PlotListener implements Listener {
return;
}
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("done.building_restricted")
TranslatableCaption.miniMessage("done.building_restricted")
);
event.setCancelled(true);
}
@ -1355,8 +1355,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_ROAD))
);
event.setCancelled(true);
}
@ -1364,8 +1364,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_UNOWNED))
);
event.setCancelled(true);
}
@ -1375,8 +1375,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.getFlag(HangingPlaceFlag.class)) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER))
);
event.setCancelled(true);
}
@ -1404,16 +1404,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_ROAD))
);
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
);
event.setCancelled(true);
}
@ -1423,8 +1423,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
);
event.setCancelled(true);
plot.debug(p.getName()
@ -1445,8 +1445,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_UNOWNED))
);
event.setCancelled(true);
}
@ -1455,8 +1455,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_DESTROY_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER))
);
event.setCancelled(true);
plot.debug(player.getName()
@ -1487,16 +1487,16 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null && !area.isRoadFlags()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_ROAD))
);
event.setCancelled(true);
}
} else if (plot != null && !plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_UNOWNED))
);
event.setCancelled(true);
}
@ -1553,8 +1553,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_INTERACT_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_INTERACT_OTHER))
);
event.setCancelled(true);
}
@ -1575,8 +1575,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_ROAD))
);
event.setCancelled(true);
}
@ -1584,8 +1584,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_UNOWNED))
);
event.setCancelled(true);
return;
@ -1598,8 +1598,8 @@ public class PlayerEventListener extends PlotListener implements Listener {
}
if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER)) {
pp.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_VEHICLE_OTHER))
);
event.setCancelled(true);
plot.debug(pp.getName()
@ -1623,24 +1623,24 @@ public class PlayerEventListener extends PlotListener implements Listener {
if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_ROAD)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_ROAD))
);
event.setHatching(false);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_UNOWNED))
);
event.setHatching(false);
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PROJECTILE_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_PROJECTILE_OTHER))
);
event.setHatching(false);
}

View File

@ -50,7 +50,7 @@ public class ServerListener implements Listener {
public void onServerLoad(ServerLoadEvent event) {
if (Bukkit.getPluginManager().getPlugin("MVdWPlaceholderAPI") != null && Settings.Enabled_Components.USE_MVDWAPI) {
new MVdWPlaceholders(this.plugin, this.plugin.placeholderRegistry());
ConsolePlayer.getConsole().sendMessage(TranslatableCaption.of("placeholder.hooked"));
ConsolePlayer.getConsole().sendMessage(TranslatableCaption.miniMessage("placeholder.hooked"));
}
}

View File

@ -51,7 +51,7 @@ public class MVdWPlaceholders {
) {
this.plugin = plugin;
this.registry = registry;
for (final Placeholder placeholder : registry.getPlaceholders()) {
for (final Placeholder placeholder : registry.allPlaceholders()) {
this.addPlaceholder(placeholder);
}
PlotSquared.get().getEventDispatcher().registerListener(this);

View File

@ -50,7 +50,7 @@ import com.plotsquared.core.util.EntityUtil;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.entity.EntityCategories;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
@ -178,7 +178,7 @@ public class BukkitEntityUtil {
if (!Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) {
plotPlayer.sendMessage(
TranslatableCaption.of("done.building_restricted")
TranslatableCaption.miniMessage("done.building_restricted")
);
return false;
}
@ -187,8 +187,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
);
return false;
}
@ -199,8 +199,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_DESTROY + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_DESTROY + "." + stub)
);
if (plot != null) {
plot.debug(player.getName()
@ -220,8 +220,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
);
if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType
@ -241,8 +241,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
);
if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType
@ -255,8 +255,8 @@ public class BukkitEntityUtil {
if (!plot.getFlag(PvpFlag.class) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
);
plot.debug(player.getName() + " could not attack " + entityType
+ " because pve = false");
@ -269,8 +269,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVP + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVP + "." + stub)
);
return false;
}
@ -286,8 +286,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
);
if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType
@ -308,8 +308,8 @@ public class BukkitEntityUtil {
}
if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_PVE + "." + stub)) {
plotPlayer.sendMessage(
TranslatableCaption.of("permission.no_permission_event"),
Template.of("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
TranslatableCaption.miniMessage("permission.no_permission_event"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_PVE + "." + stub)
);
if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType

View File

@ -53,7 +53,8 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -337,7 +338,7 @@ public class BukkitUtil extends WorldUtil {
@SuppressWarnings("deprecation")
public void setSign(
final @NonNull Location location, final @NonNull Caption[] lines,
final @NonNull Template... replacements
final @NonNull Placeholder<?>... replacements
) {
ensureLoaded(location.getWorldName(), location.getX(), location.getZ(), chunk -> {
PlotArea area = location.getPlotArea();
@ -369,7 +370,8 @@ public class BukkitUtil extends WorldUtil {
if (blockstate instanceof final Sign sign) {
for (int i = 0; i < lines.length; i++) {
sign.setLine(i, LEGACY_COMPONENT_SERIALIZER
.serialize(MINI_MESSAGE.parse(lines[i].getComponent(LocaleHolder.console()), replacements)));
.serialize(MINI_MESSAGE.deserialize(lines[i].getComponent(LocaleHolder.console()),
PlaceholderResolver.placeholders(replacements))));
}
sign.update(true);
}

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -149,10 +149,11 @@ public class PlotAPI {
*
* @param message the message
* @param replacements Variable replacements
* @since 6.3.0
*/
public void sendConsoleMessage(
final @NonNull String message,
final @NonNull Template @NonNull ... replacements
final @NonNull Placeholder<?> @NonNull ... replacements
) {
ConsolePlayer.getConsole().sendMessage(StaticCaption.of(message), replacements);
}
@ -162,10 +163,11 @@ public class PlotAPI {
*
* @param caption the message
* @param replacements Variable replacements
* @since 6.3.0
*/
public void sendConsoleMessage(
final @NonNull Caption caption,
final @NonNull Template @NonNull ... replacements
final @NonNull Placeholder<?> @NonNull ... replacements
) {
ConsolePlayer.getConsole().sendMessage(caption, replacements);
}

View File

@ -209,7 +209,7 @@ public class PlayerBackupProfile implements BackupProfile {
} else {
future.completeExceptionally(new RuntimeException(MINI_MESSAGE.stripTokens(
TranslatableCaption
.of("schematics.schematic_paste_failed")
.miniMessage("schematics.schematic_paste_failed")
.getComponent(ConsolePlayer.getConsole()))));
}
}

View File

@ -31,13 +31,12 @@ import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.inject.factory.PlayerBackupProfileFactory;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -106,22 +105,22 @@ public class SimpleBackupManager implements BackupManager {
} else {
if (player != null) {
player.sendMessage(
TranslatableCaption.of("backups.backup_automatic_started"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("backups.backup_automatic_started"),
Placeholders.miniMessage("plot", plot.getId().toString())
);
}
profile.createBackup().whenComplete((backup, throwable) -> {
if (throwable != null) {
if (player != null) {
player.sendMessage(
TranslatableCaption.of("backups.backup_automatic_failure"),
Templates.of("reason", throwable.getMessage())
TranslatableCaption.miniMessage("backups.backup_automatic_failure"),
Placeholders.miniMessage("reason", throwable.getMessage())
);
}
throwable.printStackTrace();
} else {
if (player != null) {
player.sendMessage(TranslatableCaption.of("backups.backup_automatic_finished"));
player.sendMessage(TranslatableCaption.miniMessage("backups.backup_automatic_finished"));
TaskManager.runTaskAsync(whenDone);
}
}

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -69,33 +69,33 @@ public class Add extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone
) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned"));
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
checkTrue(
plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST),
TranslatableCaption.of("permission.no_plot_perms")
TranslatableCaption.miniMessage("permission.no_plot_perms")
);
checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot add <player | *>")
checkTrue(args.length == 1, TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot add <player | *>")
);
final CompletableFuture<Boolean> future = new CompletableFuture<>();
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable != null) {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
}
future.completeExceptionally(throwable);
return;
} else {
try {
checkTrue(!uuids.isEmpty(), TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
checkTrue(!uuids.isEmpty(), TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
Iterator<UUID> iterator = uuids.iterator();
int size = plot.getTrusted().size() + plot.getMembers().size();
@ -105,24 +105,24 @@ public class Add extends Command {
Permissions.hasPermission(player, Permission.PERMISSION_TRUST_EVERYONE) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", PlayerManager.getName(uuid))
);
iterator.remove();
continue;
}
if (plot.isOwner(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_added"),
Template.of("player", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("member.already_added"),
Placeholder.miniMessage("player", PlayerManager.getName(uuid))
);
iterator.remove();
continue;
}
if (plot.getMembers().contains(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_added"),
Template.of("player", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("member.already_added"),
Placeholder.miniMessage("player", PlayerManager.getName(uuid))
);
iterator.remove();
continue;
@ -134,8 +134,8 @@ public class Add extends Command {
int maxAddSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_ADD, Settings.Limit.MAX_PLOTS);
if (localAddSize >= maxAddSize) {
player.sendMessage(
TranslatableCaption.of("members.plot_max_members_added"),
Template.of("amount", String.valueOf(localAddSize))
TranslatableCaption.miniMessage("members.plot_max_members_added"),
Placeholder.miniMessage("amount", String.valueOf(localAddSize))
);
return;
}
@ -151,7 +151,7 @@ public class Add extends Command {
}
plot.addMember(uuid);
this.eventDispatcher.callMember(player, plot, uuid, true);
player.sendMessage(TranslatableCaption.of("member.member_added"));
player.sendMessage(TranslatableCaption.miniMessage("member.member_added"));
}
}, null);
} catch (final Throwable exception) {

View File

@ -35,7 +35,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.ArrayList;
import java.util.Collection;
@ -67,12 +67,12 @@ public class Alias extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
return false;
}
@ -90,7 +90,7 @@ public class Alias extends SubCommand {
permission = isPermitted(player, Permission.PERMISSION_ALIAS_SET);
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_SET);
if (!admin && !owner) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (permission) { // is either admin or owner
@ -98,8 +98,8 @@ public class Alias extends SubCommand {
return true;
} else {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_SET))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ALIAS_SET))
);
}
}
@ -107,15 +107,15 @@ public class Alias extends SubCommand {
permission = isPermitted(player, Permission.PERMISSION_ALIAS_REMOVE);
admin = isPermitted(player, Permission.PERMISSION_ADMIN_ALIAS_REMOVE);
if (!admin && !owner) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (permission) {
result = removeAlias(player, plot);
} else {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ALIAS_REMOVE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ALIAS_REMOVE))
);
}
}
@ -147,37 +147,37 @@ public class Alias extends SubCommand {
if (alias.isEmpty()) {
sendUsage(player);
} else if (alias.length() >= 50) {
player.sendMessage(TranslatableCaption.of("alias.alias_too_long"));
player.sendMessage(TranslatableCaption.miniMessage("alias.alias_too_long"));
} else if (MathMan.isInteger(alias)) {
player.sendMessage(TranslatableCaption.of("flag.not_valid_value")); // TODO this is obviously wrong
player.sendMessage(TranslatableCaption.miniMessage("flag.not_valid_value")); // TODO this is obviously wrong
} else {
if (PlotQuery.newQuery().inArea(plot.getArea())
.withAlias(alias)
.anyMatch()) {
player.sendMessage(
TranslatableCaption.of("alias.alias_is_taken"),
Template.of("alias", alias)
TranslatableCaption.miniMessage("alias.alias_is_taken"),
Placeholder.miniMessage("alias", alias)
);
return;
}
if (Settings.UUID.OFFLINE) {
plot.setAlias(alias);
player.sendMessage(TranslatableCaption.of("alias.alias_set_to"), Template.of("alias", alias));
player.sendMessage(TranslatableCaption.miniMessage("alias.alias_set_to"), Placeholder.miniMessage("alias", alias));
return;
}
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(alias, ((uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (uuid != null) {
player.sendMessage(
TranslatableCaption.of("alias.alias_is_taken"),
Template.of("alias", alias)
TranslatableCaption.miniMessage("alias.alias_is_taken"),
Placeholder.miniMessage("alias", alias)
);
} else {
plot.setAlias(alias);
player.sendMessage(
TranslatableCaption.of("alias.alias_set_to"),
Template.of("alias", alias)
TranslatableCaption.miniMessage("alias.alias_set_to"),
Placeholder.miniMessage("alias", alias)
);
}
}));
@ -188,12 +188,12 @@ public class Alias extends SubCommand {
String alias = plot.getAlias();
if (!plot.getAlias().isEmpty()) {
player.sendMessage(
TranslatableCaption.of("alias.alias_removed"),
Template.of("alias", alias)
TranslatableCaption.miniMessage("alias.alias_removed"),
Placeholder.miniMessage("alias", alias)
);
} else {
player.sendMessage(
TranslatableCaption.of("alias.no_alias_set")
TranslatableCaption.miniMessage("alias.no_alias_set")
);
}
plot.setAlias(null);

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.events.TeleportCause;
@ -75,7 +75,8 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File;
@ -146,26 +147,26 @@ public class Area extends SubCommand {
}
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_CREATE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_CREATE))
);
return false;
}
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("single.single_area_needs_name"),
Template.of("command", "/plot area single <name>")
TranslatableCaption.miniMessage("single.single_area_needs_name"),
Placeholder.miniMessage("command", "/plot area single <name>")
);
return false;
}
final PlotArea existingArea = this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]);
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
player.sendMessage(TranslatableCaption.of("single.single_area_name_taken"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_name_taken"));
return false;
}
final LocalSession localSession = WorldEdit.getInstance().getSessionManager().getIfPresent(player.toActor());
if (localSession == null) {
player.sendMessage(TranslatableCaption.of("single.single_area_missing_selection"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_missing_selection"));
return false;
}
Region playerSelectedRegion = null;
@ -174,18 +175,18 @@ public class Area extends SubCommand {
} catch (final Exception ignored) {
}
if (playerSelectedRegion == null) {
player.sendMessage(TranslatableCaption.of("single.single_area_missing_selection"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_missing_selection"));
return false;
}
if (playerSelectedRegion.getWidth() != playerSelectedRegion.getLength()) {
player.sendMessage(TranslatableCaption.of("single.single_area_not_square"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_not_square"));
return false;
}
if (this.plotAreaManager.getPlotAreas(
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(),
CuboidRegion.makeCuboid(playerSelectedRegion)
).length != 0) {
player.sendMessage(TranslatableCaption.of("single.single_area_overlapping"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_overlapping"));
}
// Alter the region
final BlockVector3 playerSelectionMin = playerSelectedRegion.getMinimumPoint();
@ -227,7 +228,7 @@ public class Area extends SubCommand {
+ hybridPlotWorld.getId()
);
if (!parentFile.exists() && !parentFile.mkdirs()) {
player.sendMessage(TranslatableCaption.of("single.single_area_could_not_make_directories"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_could_not_make_directories"));
return false;
}
final File file = new File(parentFile, "plot.schem");
@ -245,7 +246,7 @@ public class Area extends SubCommand {
Operations.complete(forwardExtentCopy);
clipboardWriter.write(clipboard);
} catch (final Exception e) {
player.sendMessage(TranslatableCaption.of("single.single_area_failed_to_save"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_failed_to_save"));
e.printStackTrace();
return false;
}
@ -281,11 +282,11 @@ public class Area extends SubCommand {
final String world = this.setupUtils.setupWorld(singleBuilder);
if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null);
player.sendMessage(TranslatableCaption.of("single.single_area_created"));
player.sendMessage(TranslatableCaption.miniMessage("single.single_area_created"));
} else {
player.sendMessage(
TranslatableCaption.of("errors.error_create"),
Template.of("world", hybridPlotWorld.getWorldName())
TranslatableCaption.miniMessage("errors.error_create"),
Placeholder.miniMessage("world", hybridPlotWorld.getWorldName())
);
}
};
@ -295,16 +296,16 @@ public class Area extends SubCommand {
case "c", "setup", "create" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_CREATE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_CREATE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_CREATE))
);
return false;
}
switch (args.length) {
case 1:
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
);
return false;
case 2:
@ -317,8 +318,8 @@ public class Area extends SubCommand {
.get("area_create_area");
if (area == null) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
@ -328,13 +329,13 @@ public class Area extends SubCommand {
location
);
player.sendMessage(
TranslatableCaption.of("set.set_attribute"),
Template.of("attribute", "area_pos1"),
Template.of("value", location.getX() + "," + location.getZ())
TranslatableCaption.miniMessage("set.set_attribute"),
Placeholder.miniMessage("attribute", "area_pos1"),
Placeholder.miniMessage("value", location.getX() + "," + location.getZ())
);
player.sendMessage(
TranslatableCaption.of("area.set_pos2"),
Template.of("command", "/plot area create pos2")
TranslatableCaption.miniMessage("area.set_pos2"),
Placeholder.miniMessage("command", "/plot area create pos2")
);
return true;
}
@ -347,8 +348,8 @@ public class Area extends SubCommand {
.get("area_create_area");
if (area == null) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", "/plot area create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
@ -373,8 +374,8 @@ public class Area extends SubCommand {
final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(area.getWorldName(), region);
if (!areas.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"),
Template.of("cluster", areas.iterator().next().toString())
TranslatableCaption.miniMessage("cluster.cluster_intersection"),
Placeholder.miniMessage("cluster", areas.iterator().next().toString())
);
return false;
}
@ -397,7 +398,7 @@ public class Area extends SubCommand {
if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null);
player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE);
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
player.sendMessage(TranslatableCaption.miniMessage("setup.setup_finished"));
if (area.getTerrain() != PlotAreaTerrainType.ALL) {
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
queue.setChunkConsumer(chunk -> AugmentedUtils.generate(
@ -412,8 +413,8 @@ public class Area extends SubCommand {
}
} else {
player.sendMessage(
TranslatableCaption.of("errors.error_create"),
Template.of("world", area.getWorldName())
TranslatableCaption.miniMessage("errors.error_create"),
Placeholder.miniMessage("world", area.getWorldName())
);
}
};
@ -446,8 +447,8 @@ public class Area extends SubCommand {
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
if (other != null && Objects.equals(pa.getId(), other.getId())) {
player.sendMessage(
TranslatableCaption.of("setup.setup_world_taken"),
Template.of("value", pa.toString())
TranslatableCaption.miniMessage("setup.setup_world_taken"),
Placeholder.miniMessage("value", pa.toString())
);
return false;
}
@ -461,9 +462,9 @@ public class Area extends SubCommand {
String[] pair = args[i].split("=");
if (pair.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1,", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Placeholder.miniMessage("value1,", getCommandString()),
Placeholder.miniMessage("value2", " create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
@ -498,9 +499,9 @@ public class Area extends SubCommand {
}
default -> {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Placeholder.miniMessage("value1", getCommandString()),
Placeholder.miniMessage("value2", " create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
@ -509,8 +510,8 @@ public class Area extends SubCommand {
if (pa.getType() != PlotAreaType.PARTIAL) {
if (this.worldUtil.isWorld(pa.getWorldName())) {
player.sendMessage(
TranslatableCaption.of("setup.setup_world_taken"),
Template.of("value", pa.getWorldName())
TranslatableCaption.miniMessage("setup.setup_world_taken"),
Placeholder.miniMessage("value", pa.getWorldName())
);
return false;
}
@ -527,11 +528,11 @@ public class Area extends SubCommand {
String world = this.setupUtils.setupWorld(builder);
if (this.worldUtil.isWorld(world)) {
player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_AREA_CREATE);
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
player.sendMessage(TranslatableCaption.miniMessage("setup.setup_finished"));
} else {
player.sendMessage(
TranslatableCaption.of("errors.error_create"),
Template.of("world", pa.getWorldName())
TranslatableCaption.miniMessage("errors.error_create"),
Placeholder.miniMessage("world", pa.getWorldName())
);
}
try {
@ -549,13 +550,13 @@ public class Area extends SubCommand {
}
if (pa.getId() == null) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", getUsage())
);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Placeholder.miniMessage("value1", getCommandString()),
Placeholder.miniMessage("value2", " create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
@ -571,8 +572,8 @@ public class Area extends SubCommand {
}
metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa);
player.sendMessage(
TranslatableCaption.of("single.get_position"),
Template.of("command", getCommandString())
TranslatableCaption.miniMessage("single.get_position"),
Placeholder.miniMessage("command", getCommandString())
);
break;
}
@ -581,8 +582,8 @@ public class Area extends SubCommand {
case "i", "info" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_INFO)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_INFO))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_INFO))
);
return false;
}
@ -592,18 +593,18 @@ public class Area extends SubCommand {
case 2 -> area = this.plotAreaManager.getPlotAreaByString(args[1]);
default -> {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " info [area]")
TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Placeholder.miniMessage("value1", getCommandString()),
Placeholder.miniMessage("value2", " info [area]")
);
return false;
}
}
if (area == null) {
if (args.length == 2) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), Template.of("value", args[1]));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_valid_plot_world"), Placeholder.miniMessage("value", args[1]));
} else {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
return false;
}
@ -625,24 +626,24 @@ public class Area extends SubCommand {
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
region = "N/A";
}
Template headerTemplate = Template.of(
Placeholder<?> headerTemplate = Placeholder.miniMessage(
"header",
TranslatableCaption.of("info.plot_info_header").getComponent(player)
TranslatableCaption.miniMessage("info.plot_info_header").getComponent(player)
);
Template nameTemplate = Template.of("name", name);
Template typeTemplate = Template.of("type", area.getType().name());
Template terrainTemplate = Template.of("terrain", area.getTerrain().name());
Template usageTemplate = Template.of("usage", String.format("%.2f", percent));
Template claimedTemplate = Template.of("claimed", String.valueOf(claimed));
Template clustersTemplate = Template.of("clusters", String.valueOf(clusters));
Template regionTemplate = Template.of("region", region);
Template generatorTemplate = Template.of("generator", generator);
Template footerTemplate = Template.of(
Placeholder<?> nameTemplate = Placeholder.miniMessage("name", name);
Placeholder<?> typeTemplate = Placeholder.miniMessage("type", area.getType().name());
Placeholder<?> terrainTemplate = Placeholder.miniMessage("terrain", area.getTerrain().name());
Placeholder<?> usageTemplate = Placeholder.miniMessage("usage", String.format("%.2f", percent));
Placeholder<?> claimedTemplate = Placeholder.miniMessage("claimed", String.valueOf(claimed));
Placeholder<?> clustersTemplate = Placeholder.miniMessage("clusters", String.valueOf(clusters));
Placeholder<?> regionTemplate = Placeholder.miniMessage("region", region);
Placeholder<?> generatorTemplate = Placeholder.miniMessage("generator", generator);
Placeholder<?> footerTemplate = Placeholder.miniMessage(
"footer",
TranslatableCaption.of("info.plot_info_footer").getComponent(player)
TranslatableCaption.miniMessage("info.plot_info_footer").getComponent(player)
);
player.sendMessage(
TranslatableCaption.of("info.area_info_format"),
TranslatableCaption.miniMessage("info.area_info_format"),
headerTemplate,
nameTemplate,
typeTemplate,
@ -659,8 +660,8 @@ public class Area extends SubCommand {
case "l", "list" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_LIST)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_LIST))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_LIST))
);
return false;
}
@ -676,9 +677,9 @@ public class Area extends SubCommand {
}
default:
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " list [#]")
TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"),
Placeholder.miniMessage("value1", getCommandString()),
Placeholder.miniMessage("value2", " list [#]")
);
return false;
}
@ -704,29 +705,30 @@ public class Area extends SubCommand {
percent = claimed == 0 ? 0 : (double) claimed / Short.MAX_VALUE * Short.MAX_VALUE;
region = "N/A";
}
Template claimedTemplate = Template.of("claimed", String.valueOf(claimed));
Template usageTemplate = Template.of("usage", String.format("%.2f", percent) + "%");
Template clustersTemplate = Template.of("clusters", String.valueOf(clusters));
Template regionTemplate = Template.of("region", region);
Template generatorTemplate = Template.of("generator", generator);
Placeholder<?> claimedTemplate = Placeholder.miniMessage("claimed", String.valueOf(claimed));
Placeholder<?> usageTemplate = Placeholder.miniMessage("usage", String.format("%.2f", percent) + "%");
Placeholder<?> clustersTemplate = Placeholder.miniMessage("clusters", String.valueOf(clusters));
Placeholder<?> regionTemplate = Placeholder.miniMessage("region", region);
Placeholder<?> generatorTemplate = Placeholder.miniMessage("generator", generator);
String tooltip = MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(
TranslatableCaption.of("info.area_list_tooltip").getComponent(player),
.deserialize(
TranslatableCaption.miniMessage("info.area_list_tooltip").getComponent(player),
PlaceholderResolver.placeholders(
claimedTemplate,
usageTemplate,
clustersTemplate,
regionTemplate,
generatorTemplate
));
Template tooltipTemplate = Template.of("hover_info", tooltip);
Template visitcmdTemplate = Template.of("command_tp", "/plot area tp " + area);
Template infocmdTemplate = Template.of("command_info", "/plot area info " + area);
Template numberTemplate = Template.of("number", String.valueOf(i));
Template nameTemplate = Template.of("area_name", name);
Template typeTemplate = Template.of("area_type", area.getType().name());
Template terrainTemplate = Template.of("area_terrain", area.getTerrain().name());
caption.set(TranslatableCaption.of("info.area_list_item"));
caption.setTemplates(
)));
Placeholder<?> tooltipTemplate = Placeholder.miniMessage("hover_info", tooltip);
Placeholder<?> visitcmdTemplate = Placeholder.miniMessage("command_tp", "/plot area tp " + area);
Placeholder<?> infocmdTemplate = Placeholder.miniMessage("command_info", "/plot area info " + area);
Placeholder<?> numberTemplate = Placeholder.miniMessage("number", String.valueOf(i));
Placeholder<?> nameTemplate = Placeholder.miniMessage("area_name", name);
Placeholder<?> typeTemplate = Placeholder.miniMessage("area_type", area.getType().name());
Placeholder<?> terrainTemplate = Placeholder.miniMessage("area_terrain", area.getTerrain().name());
caption.set(TranslatableCaption.miniMessage("info.area_list_item"));
caption.setPlaceholders(
tooltipTemplate,
visitcmdTemplate,
numberTemplate,
@ -736,26 +738,26 @@ public class Area extends SubCommand {
infocmdTemplate
);
}
}, "/plot area list", TranslatableCaption.of("list.area_list_header_paged"));
}, "/plot area list", TranslatableCaption.miniMessage("list.area_list_header_paged"));
return true;
}
case "regen", "clear", "reset", "regenerate" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_REGEN)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_REGEN))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_REGEN))
);
return false;
}
final PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
if (area.getType() != PlotAreaType.PARTIAL) {
player.sendMessage(
TranslatableCaption.of("single.delete_world_region"),
Template.of("world", area.getWorldName())
TranslatableCaption.miniMessage("single.delete_world_region"),
Placeholder.miniMessage("world", area.getWorldName())
);
return false;
}
@ -768,28 +770,28 @@ public class Area extends SubCommand {
null
));
queue.addReadChunks(area.getRegion().getChunks());
queue.setCompleteTask(() -> player.sendMessage(TranslatableCaption.of("single.regeneration_complete")));
queue.setCompleteTask(() -> player.sendMessage(TranslatableCaption.miniMessage("single.regeneration_complete")));
queue.enqueue();
return true;
}
case "goto", "v", "teleport", "visit", "tp" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_AREA_TP)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AREA_TP))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AREA_TP))
);
return false;
}
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot area tp [area]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot area tp [area]")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), Template.of("value", args[1]));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_valid_plot_world"), Placeholder.miniMessage("value", args[1]));
return false;
}
Location center;
@ -817,7 +819,7 @@ public class Area extends SubCommand {
return true;
}
case "delete", "remove" -> {
player.sendMessage(TranslatableCaption.of("single.worldcreation_location"));
player.sendMessage(TranslatableCaption.miniMessage("single.worldcreation_location"));
return true;
}
}

View File

@ -51,7 +51,7 @@ import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.AutoClaimFinishTask;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -116,14 +116,14 @@ public class Auto extends SubCommand {
int grantedPlots = metaDataAccess.get().orElse(0);
if (diff < 0 && grantedPlots < sizeX * sizeZ) {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(diff + grantedPlots))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(diff + grantedPlots))
);
return false;
} else if (diff >= 0 && grantedPlots + diff < sizeX * sizeZ) {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(diff + grantedPlots))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(diff + grantedPlots))
);
return false;
} else {
@ -134,15 +134,15 @@ public class Auto extends SubCommand {
metaDataAccess.set(left);
}
player.sendMessage(
TranslatableCaption.of("economy.removed_granted_plot"),
Template.of("usedGrants", String.valueOf(grantedPlots - left)),
Template.of("remainingGrants", String.valueOf(left))
TranslatableCaption.miniMessage("economy.removed_granted_plot"),
Placeholder.miniMessage("usedGrants", String.valueOf(grantedPlots - left)),
Placeholder.miniMessage("remainingGrants", String.valueOf(left))
);
}
} else {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots())
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots())
)
);
return false;
@ -205,7 +205,7 @@ public class Auto extends SubCommand {
plotarea = this.plotAreaManager.getAllPlotAreas()[0];
}
if (plotarea == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
}
@ -221,13 +221,13 @@ public class Auto extends SubCommand {
sizeZ = Integer.parseInt(split[1]);
} else {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", getUsage())
);
return true;
}
if (sizeX < 1 || sizeZ < 1) {
player.sendMessage(TranslatableCaption.of("error.plot_size_negative"));
player.sendMessage(TranslatableCaption.miniMessage("error.plot_size_negative"));
return true;
}
if (args.length > 1) {
@ -244,8 +244,8 @@ public class Auto extends SubCommand {
.callAuto(player, plotarea, schematic, sizeX, sizeZ);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Auto claim")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Auto claim")
);
return true;
}
@ -255,14 +255,14 @@ public class Auto extends SubCommand {
schematic = event.getSchematic();
if (!force && mega && !Permissions.hasPermission(player, Permission.PERMISSION_AUTO_MEGA)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_AUTO_MEGA))
);
}
if (!force && sizeX * sizeZ > Settings.Claim.MAX_AUTO_AREA) {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots_num"),
Template.of("amount", String.valueOf(Settings.Claim.MAX_AUTO_AREA))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots_num"),
Placeholder.miniMessage("amount", String.valueOf(Settings.Claim.MAX_AUTO_AREA))
);
return false;
}
@ -279,9 +279,9 @@ public class Auto extends SubCommand {
if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.hasSchematic(schematic)) {
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid_named"),
Template.of("schemname", schematic),
Template.of("reason", "non-existent")
TranslatableCaption.miniMessage("schematics.schematic_invalid_named"),
Placeholder.miniMessage("schemname", schematic),
Placeholder.miniMessage("reason", "non-existent")
);
return true;
}
@ -291,8 +291,8 @@ public class Auto extends SubCommand {
) && !Permissions
.hasPermission(player, "plots.admin.command.schematic")) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", "plots.claim.%s0")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", "plots.claim.%s0")
);
return true;
}
@ -305,21 +305,21 @@ public class Auto extends SubCommand {
cost = (sizeX * sizeZ) * cost;
if (cost > 0d) {
if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null"));
player.sendMessage(TranslatableCaption.miniMessage("economy.vault_or_consumer_null"));
return false;
}
if (!force && this.econHandler.getMoney(player) < cost) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
TranslatableCaption.miniMessage("economy.cannot_afford_plot"),
Placeholder.miniMessage("money", this.econHandler.format(cost)),
Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
return false;
}
this.econHandler.withdrawMoney(player, cost);
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(cost))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", this.econHandler.format(cost))
);
}
}
@ -332,7 +332,7 @@ public class Auto extends SubCommand {
plots = this.eventDispatcher.callAutoPlotsChosen(player, plots).getPlots();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("errors.no_free_plots"));
player.sendMessage(TranslatableCaption.miniMessage("errors.no_free_plots"));
return false;
} else if (plots.size() == 1) {
this.claimSingle(player, plots.get(0), plotarea, schematic);
@ -352,8 +352,8 @@ public class Auto extends SubCommand {
);
if (!force && mergeEvent.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Auto merge")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Auto merge")
);
return false;
}

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.nio.file.Files;
@ -73,8 +73,8 @@ public final class Backup extends Command {
private static boolean sendMessage(PlotPlayer<?> player) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot backup <save | list | load>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot backup <save | list | load>")
);
return true;
}
@ -138,42 +138,42 @@ public final class Backup extends Command {
) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (!plot.hasOwner()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_unowned").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_unowned").getComponent(player))
);
} else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
} else if (plot.isMerged()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_merged").getComponent(player))
);
} else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
);
} else {
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_other").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_other").getComponent(player))
);
} else {
backupProfile.createBackup().whenComplete((backup, throwable) -> {
if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("backups.backup_save_failed"),
Template.of("reason", throwable.getMessage())
TranslatableCaption.miniMessage("backups.backup_save_failed"),
Placeholder.miniMessage("reason", throwable.getMessage())
);
throwable.printStackTrace();
} else {
player.sendMessage(TranslatableCaption.of("backups.backup_save_success"));
player.sendMessage(TranslatableCaption.miniMessage("backups.backup_save_success"));
}
});
}
@ -192,51 +192,51 @@ public final class Backup extends Command {
) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (!plot.hasOwner()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_unowned").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_unowned").getComponent(player))
);
} else if (plot.isMerged()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_merged").getComponent(player))
);
} else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
} else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
);
} else {
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_other").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_other").getComponent(player))
);
} else {
backupProfile.listBackups().whenComplete((backups, throwable) -> {
if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("backups.backup_list_failed"),
Template.of("reason", throwable.getMessage())
TranslatableCaption.miniMessage("backups.backup_list_failed"),
Placeholder.miniMessage("reason", throwable.getMessage())
);
throwable.printStackTrace();
} else {
player.sendMessage(
TranslatableCaption.of("backups.backup_list_header"),
Template.of("plot", plot.getId().toCommaSeparatedString())
TranslatableCaption.miniMessage("backups.backup_list_header"),
Placeholder.miniMessage("plot", plot.getId().toCommaSeparatedString())
);
try {
for (int i = 0; i < backups.size(); i++) {
player.sendMessage(
TranslatableCaption.of("backups.backup_list_entry"),
Template.of("number", Integer.toString(i + 1)),
Template.of("value", DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(
TranslatableCaption.miniMessage("backups.backup_list_entry"),
Placeholder.miniMessage("number", Integer.toString(i + 1)),
Placeholder.miniMessage("value", DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(
Instant.ofEpochMilli(backups.get(i).getCreationTime()),
ZoneId.systemDefault()
)))
@ -263,29 +263,29 @@ public final class Backup extends Command {
) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (!plot.hasOwner()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_unowned").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_unowned").getComponent(player))
);
} else if (plot.isMerged()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_merged").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_merged").getComponent(player))
);
} else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
} else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_BACKUP_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_BACKUP_OTHER))
);
} else if (args.length == 0) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Usage: /plot backup save/list/load")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Usage: /plot backup save/list/load")
);
} else {
final int number;
@ -293,32 +293,32 @@ public final class Backup extends Command {
number = Integer.parseInt(args[0]);
} catch (final Exception e) {
player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("invalid.not_a_number"),
Placeholder.miniMessage("value", args[0])
);
return;
}
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of("plot", TranslatableCaption.of("generic.generic_other").getComponent(player))
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage("plot", TranslatableCaption.miniMessage("generic.generic_other").getComponent(player))
);
} else {
backupProfile.listBackups().whenComplete((backups, throwable) -> {
if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("backups.backup_load_failure"),
Template.of("reason", throwable.getMessage())
TranslatableCaption.miniMessage("backups.backup_load_failure"),
Placeholder.miniMessage("reason", throwable.getMessage())
);
throwable.printStackTrace();
} else {
if (number < 1 || number > backups.size()) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of(
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage(
"plot",
TranslatableCaption.of("generic.generic_invalid_choice").getComponent(player)
TranslatableCaption.miniMessage("generic.generic_invalid_choice").getComponent(player)
)
);
} else {
@ -327,10 +327,10 @@ public final class Backup extends Command {
if (backup == null || backup.getFile() == null || !Files
.exists(backup.getFile())) {
player.sendMessage(
TranslatableCaption.of("backups.backup_impossible"),
Template.of(
TranslatableCaption.miniMessage("backups.backup_impossible"),
Placeholder.miniMessage(
"plot",
TranslatableCaption.of("generic.generic_invalid_choice").getComponent(player)
TranslatableCaption.miniMessage("generic.generic_invalid_choice").getComponent(player)
)
);
} else {
@ -339,11 +339,11 @@ public final class Backup extends Command {
.whenComplete((n, error) -> {
if (error != null) {
player.sendMessage(
TranslatableCaption.of("backups.backup_load_failure"),
Template.of("reason", error.getMessage())
TranslatableCaption.miniMessage("backups.backup_load_failure"),
Placeholder.miniMessage("reason", error.getMessage())
);
} else {
player.sendMessage(TranslatableCaption.of("backups.backup_load_success"));
player.sendMessage(TranslatableCaption.miniMessage("backups.backup_load_success"));
}
})
);

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.util.StringMan;
import com.sk89q.worldedit.command.util.SuggestionHelper;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection;
import java.util.Locale;
@ -57,30 +57,30 @@ public class Biome extends SetCommand {
String biomes = StringMan.join(
BiomeType.REGISTRY.values(),
MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption
.of("blocklist.block_list_separator")
.miniMessage("blocklist.block_list_separator")
.getComponent(player)))
);
player.sendMessage(TranslatableCaption.of("biome.need_biome"));
player.sendMessage(TranslatableCaption.miniMessage("biome.need_biome"));
player.sendMessage(
TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
Template.of("values", biomes)
TranslatableCaption.miniMessage("commandconfig.subcommand_set_options_header"),
Placeholder.miniMessage("values", biomes)
);
return false;
}
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
plot.addRunning();
plot.getPlotModificationManager().setBiome(biome, () -> {
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("biome.biome_set_to"),
Template.of("value", value.toLowerCase())
TranslatableCaption.miniMessage("biome.biome_set_to"),
Placeholder.miniMessage("value", value.toLowerCase())
);
});
return true;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
@ -73,8 +73,8 @@ public class Buy extends Command {
) {
PlotArea area = player.getPlotAreaAbs();
check(area, TranslatableCaption.of("errors.not_in_plot_world"));
check(this.econHandler.isEnabled(area), TranslatableCaption.of("economy.econ_disabled"));
check(area, TranslatableCaption.miniMessage("errors.not_in_plot_world"));
check(this.econHandler.isEnabled(area), TranslatableCaption.miniMessage("economy.econ_disabled"));
final Plot plot;
if (args.length != 0) {
if (args.length != 1) {
@ -83,37 +83,37 @@ public class Buy extends Command {
}
plot = check(Plot.getPlotFromString(player, args[0], true), null);
} else {
plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
}
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned"));
checkTrue(!plot.isOwner(player.getUUID()), TranslatableCaption.of("economy.cannot_buy_own"));
checkTrue(plot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
checkTrue(!plot.isOwner(player.getUUID()), TranslatableCaption.miniMessage("economy.cannot_buy_own"));
Set<Plot> plots = plot.getConnectedPlots();
checkTrue(
player.getPlotCount() + plots.size() <= player.getAllowedPlots(),
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots()))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
);
double price = plot.getFlag(PriceFlag.class);
if (price <= 0) {
throw new CommandException(TranslatableCaption.of("economy.not_for_sale"));
throw new CommandException(TranslatableCaption.miniMessage("economy.not_for_sale"));
}
checkTrue(
this.econHandler.isSupported(),
TranslatableCaption.of("economy.vault_or_consumer_null")
TranslatableCaption.miniMessage("economy.vault_or_consumer_null")
);
checkTrue(
this.econHandler.getMoney(player) >= price,
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(price)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
TranslatableCaption.miniMessage("economy.cannot_afford_plot"),
Placeholder.miniMessage("money", this.econHandler.format(price)),
Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
this.econHandler.withdrawMoney(player, price);
// Failure
// Success
confirm.run(this, () -> {
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(price))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", this.econHandler.format(price))
);
this.econHandler.depositMoney(PlotSquared.platform().playerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
@ -121,10 +121,10 @@ public class Buy extends Command {
PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(plot.getOwnerAbs());
if (owner != null) {
owner.sendMessage(
TranslatableCaption.of("economy.plot_sold"),
Template.of("plot", plot.getId().toString()),
Template.of("player", player.getName()),
Template.of("price", this.econHandler.format(price))
TranslatableCaption.miniMessage("economy.plot_sold"),
Placeholder.miniMessage("plot", plot.getId().toString()),
Placeholder.miniMessage("player", player.getName()),
Placeholder.miniMessage("price", this.econHandler.format(price))
);
}
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class);
@ -134,8 +134,8 @@ public class Buy extends Command {
}
plot.setOwner(player.getUUID());
player.sendMessage(
TranslatableCaption.of("working.claimed"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("working.claimed"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
whenDone.run(Buy.this, CommandResult.SUCCESS);
}, () -> {

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.plot.flag.implementations.MiscCapFlag;
import com.plotsquared.core.plot.flag.implementations.MobCapFlag;
import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag;
import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL;
import static com.plotsquared.core.util.entity.EntityCategories.CAP_ENTITY;
@ -55,22 +55,22 @@ public class Caps extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.isAdded(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_CAPS_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_CAPS_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_CAPS_OTHER))
);
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
player.sendMessage(TranslatableCaption.of("info.plot_caps_header"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_caps_header"));
final int[] countedEntities = plot.countEntities();
sendFormatted(plot, player, MobCapFlag.class, countedEntities, "mobs", CAP_MOB);
sendFormatted(plot, player, HostileCapFlag.class, countedEntities, "hostile", CAP_MONSTER);
@ -90,14 +90,14 @@ public class Caps extends SubCommand {
final int max = plot.getFlag(capFlag);
final String percentage = String.format("%.1f", 100 * ((float) current / max));
String maxBeautified = max >= Integer.MAX_VALUE
? TranslatableCaption.of("info.infinite").getComponent(player)
? TranslatableCaption.miniMessage("info.infinite").getComponent(player)
: String.valueOf(max);
player.sendMessage(
TranslatableCaption.of("info.plot_caps_format"),
Template.of("cap", name),
Template.of("current", String.valueOf(current)),
Template.of("limit", maxBeautified),
Template.of("percentage", percentage)
TranslatableCaption.miniMessage("info.plot_caps_format"),
Placeholder.miniMessage("cap", name),
Placeholder.miniMessage("current", String.valueOf(current)),
Placeholder.miniMessage("limit", maxBeautified),
Placeholder.miniMessage("percentage", percentage)
);
}

View File

@ -28,7 +28,7 @@ package com.plotsquared.core.command;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
/**
* @deprecated In favor of "/plot toggle chat" and
@ -45,13 +45,13 @@ public class Chat extends SubCommand {
@Override
public boolean onCommand(PlotPlayer<?> player, String[] args) {
PlotArea area = player.getPlotAreaAbs();
check(area, TranslatableCaption.of("errors.not_in_plot_world"));
check(area, TranslatableCaption.miniMessage("errors.not_in_plot_world"));
player.sendMessage(
TranslatableCaption.of("errors.deprecated_commands"),
Template.of("replacement", "/plot toggle chat")
TranslatableCaption.miniMessage("errors.deprecated_commands"),
Placeholder.miniMessage("replacement", "/plot toggle chat")
);
if (player.getPlotAreaAbs().isForcingPlotChat()) {
player.sendMessage(TranslatableCaption.of("chat.plot_chat_forced"));
player.sendMessage(TranslatableCaption.miniMessage("chat.plot_chat_forced"));
return true;
}
MainCommand.getInstance().toggle.chat(this, player, args, null, null);

View File

@ -45,7 +45,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -81,15 +81,15 @@ public class Claim extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
final PlayerClaimPlotEvent event = this.eventDispatcher.callClaim(player, plot, schematic);
schematic = event.getSchematic();
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Claim")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Claim")
);
return true;
}
@ -107,31 +107,31 @@ public class Claim extends SubCommand {
grants = metaDataAccess.get().orElse(0);
if (grants <= 0) {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(grants))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(grants))
);
metaDataAccess.remove();
}
} else {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots()))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
);
return false;
}
}
if (!plot.canClaim(player)) {
player.sendMessage(TranslatableCaption.of("working.plot_is_claimed"));
player.sendMessage(TranslatableCaption.miniMessage("working.plot_is_claimed"));
return false;
}
if (schematic != null && !schematic.isEmpty()) {
if (area.isSchematicClaimSpecify()) {
if (!area.hasSchematic(schematic)) {
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid_named"),
Template.of("schemname", schematic),
Template.of("reason", "non-existent")
TranslatableCaption.miniMessage("schematics.schematic_invalid_named"),
Placeholder.miniMessage("schemname", schematic),
Placeholder.miniMessage("reason", "non-existent")
);
}
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLAIM_SCHEMATIC
@ -140,8 +140,8 @@ public class Claim extends SubCommand {
"plots.admin.command.schematic"
) && !force) {
player.sendMessage(
TranslatableCaption.of("permission.no_schematic_permission"),
Template.of("value", schematic)
TranslatableCaption.miniMessage("permission.no_schematic_permission"),
Placeholder.miniMessage("value", schematic)
);
}
}
@ -151,22 +151,22 @@ public class Claim extends SubCommand {
double cost = costExr.evaluate(currentPlots);
if (cost > 0d) {
if (!this.econHandler.isSupported()) {
player.sendMessage(TranslatableCaption.of("economy.vault_or_consumer_null"));
player.sendMessage(TranslatableCaption.miniMessage("economy.vault_or_consumer_null"));
return false;
}
if (this.econHandler.getMoney(player) < cost) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
TranslatableCaption.miniMessage("economy.cannot_afford_plot"),
Placeholder.miniMessage("money", this.econHandler.format(cost)),
Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
return false;
}
this.econHandler.withdrawMoney(player, cost);
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(cost)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", this.econHandler.format(cost)),
Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
}
}
@ -177,16 +177,16 @@ public class Claim extends SubCommand {
metaDataAccess.set(grants - 1);
}
player.sendMessage(
TranslatableCaption.of("economy.removed_granted_plot"),
Template.of("usedGrants", String.valueOf((grants - 1))),
Template.of("remainingGrants", String.valueOf(grants))
TranslatableCaption.miniMessage("economy.removed_granted_plot"),
Placeholder.miniMessage("usedGrants", String.valueOf((grants - 1))),
Placeholder.miniMessage("remainingGrants", String.valueOf(grants))
);
}
}
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_BYPASS_BORDER)) {
int border = area.getBorder();
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
player.sendMessage(TranslatableCaption.of("border.denied"));
player.sendMessage(TranslatableCaption.miniMessage("border.denied"));
return false;
}
}
@ -197,15 +197,15 @@ public class Claim extends SubCommand {
TaskManager.getPlatformImplementation().sync(() -> {
if (!plot.claim(player, true, finalSchematic, false, false)) {
LOGGER.info("Failed to claim plot {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) {
PlotMergeEvent mergeEvent = Claim.this.eventDispatcher
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
if (mergeEvent.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Auto merge on claim")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Auto merge on claim")
);
} else {
if (plot.getPlotModificationManager().autoMerge(
@ -226,7 +226,7 @@ public class Claim extends SubCommand {
}
}, () -> {
LOGGER.info("Failed to add plot to database: {}", plot.getId().toCommaSeparatedString());
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
plot.setOwnerAbs(null);
});
return true;

View File

@ -43,7 +43,8 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.CompletableFuture;
@ -80,28 +81,28 @@ public class Clear extends Command {
sendUsage(player);
return CompletableFuture.completedFuture(false);
}
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
Result eventResult = this.eventDispatcher.callClear(plot).getEventResult();
if (eventResult == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Clear")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Clear")
);
return CompletableFuture.completedFuture(true);
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return CompletableFuture.completedFuture(true);
}
boolean force = eventResult == Result.FORCE;
checkTrue(
force || plot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, "plots.admin.command.clear"),
TranslatableCaption.of("permission.no_plot_perms")
TranslatableCaption.miniMessage("permission.no_plot_perms")
);
checkTrue(plot.getRunning() == 0, TranslatableCaption.of("errors.wait_for_timer"));
checkTrue(plot.getRunning() == 0, TranslatableCaption.miniMessage("errors.wait_for_timer"));
checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions
.hasPermission(player, "plots.continue"), TranslatableCaption.of("done.done_already_done"));
.hasPermission(player, "plots.continue"), TranslatableCaption.miniMessage("done.done_already_done"));
confirm.run(this, () -> {
if (Settings.Teleport.ON_CLEAR) {
plot.getPlayersInPlot().forEach(playerInPlot -> plot.teleportPlayer(playerInPlot, TeleportCause.COMMAND_CLEAR,
@ -135,14 +136,14 @@ public class Clear extends Command {
}
}
player.sendMessage(
TranslatableCaption.of("working.clearing_done"),
Template.of("amount", String.valueOf(System.currentTimeMillis() - start)),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("working.clearing_done"),
Placeholder.miniMessage("amount", String.valueOf(System.currentTimeMillis() - start)),
Placeholder.miniMessage("plot", plot.getId().toString())
);
});
});
if (!result) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
} else {
plot.addRunning();
}

View File

@ -42,13 +42,14 @@ import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeoutException;
@ -68,8 +69,8 @@ public class Cluster extends SubCommand {
if (args.length == 0) {
// return arguments
player.sendMessage(
TranslatableCaption.of("cluster.cluster_available_args"),
Template.of(
TranslatableCaption.miniMessage("cluster.cluster_available_args"),
Placeholder.miniMessage(
"list",
"<dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>"
)
@ -78,77 +79,75 @@ public class Cluster extends SubCommand {
}
String sub = args[0].toLowerCase();
switch (sub) {
case "l":
case "list": {
case "l", "list" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LIST)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_LIST))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_LIST))
);
return false;
}
if (args.length != 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster list")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster list")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
Set<PlotCluster> clusters = area.getClusters();
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_heading"),
Template.of("amount", clusters.size() + "")
TranslatableCaption.miniMessage("cluster.cluster_list_heading"),
Placeholder.miniMessage("amount", clusters.size() + "")
);
for (PlotCluster cluster : clusters) {
// Ignore unmanaged clusters
String name = "'" + cluster.getName() + "' : " + cluster;
if (player.getUUID().equals(cluster.owner)) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_owner"),
Template.of("cluster", name)
TranslatableCaption.miniMessage("cluster.cluster_list_element_owner"),
Placeholder.miniMessage("cluster", name)
);
} else if (cluster.helpers.contains(player.getUUID())) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_helpers"),
Template.of("cluster", name)
TranslatableCaption.miniMessage("cluster.cluster_list_element_helpers"),
Placeholder.miniMessage("cluster", name)
);
} else if (cluster.invited.contains(player.getUUID())) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_invited"),
Template.of("cluster", name)
TranslatableCaption.miniMessage("cluster.cluster_list_element_invited"),
Placeholder.miniMessage("cluster", name)
);
} else {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element"),
Template.of("cluster", cluster.toString())
TranslatableCaption.miniMessage("cluster.cluster_list_element"),
Placeholder.miniMessage("cluster", cluster.toString())
);
}
}
return true;
}
case "c":
case "create": {
case "c", "create" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_CREATE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE))
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
if (args.length != 4) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster create <name> <id-bot> <id-top>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster create <name> <id-bot> <id-top>")
);
return false;
}
@ -157,8 +156,8 @@ public class Cluster extends SubCommand {
player.getPlotCount(player.getLocation().getWorldName());
if (currentClusters >= player.getAllowedPlots()) {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_clusters"),
Template.of("amount", String.valueOf(player.getAllowedPlots()))
TranslatableCaption.miniMessage("permission.cant_claim_more_clusters"),
Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
);
}
PlotId pos1;
@ -168,15 +167,15 @@ public class Cluster extends SubCommand {
pos1 = PlotId.fromString(args[2]);
pos2 = PlotId.fromString(args[3]);
} catch (IllegalArgumentException ignored) {
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.not_valid_plot_id"));
return false;
}
// check if name is taken
String name = args[1];
if (area.getCluster(name) != null) {
player.sendMessage(
TranslatableCaption.of("alias.alias_is_taken"),
Template.of("alias", name)
TranslatableCaption.miniMessage("alias.alias_is_taken"),
Placeholder.miniMessage("alias", name)
);
return false;
}
@ -189,16 +188,16 @@ public class Cluster extends SubCommand {
PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2);
if (cluster != null) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"),
Template.of("cluster", cluster.getName())
TranslatableCaption.miniMessage("cluster.cluster_intersection"),
Placeholder.miniMessage("cluster", cluster.getName())
);
return false;
}
// Check if it occupies existing plots
if (!area.contains(pos1) || !area.contains(pos2)) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_outside"),
Template.of("area", String.valueOf(area))
TranslatableCaption.miniMessage("cluster.cluster_outside"),
Placeholder.miniMessage("area", String.valueOf(area))
);
return false;
}
@ -210,8 +209,8 @@ public class Cluster extends SubCommand {
for (Plot plot : plots) {
if (!plot.isOwner(uuid)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_CREATE_OTHER))
);
return false;
}
@ -232,8 +231,8 @@ public class Cluster extends SubCommand {
);
if (current + cluster.getArea() > allowed) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()))
);
return false;
}
@ -251,31 +250,29 @@ public class Cluster extends SubCommand {
}
}
player.sendMessage(
TranslatableCaption.of("cluster.cluster_created"),
Template.of("name", name)
TranslatableCaption.miniMessage("cluster.cluster_created"),
Placeholder.miniMessage("name", name)
);
return true;
}
case "disband":
case "del":
case "delete": {
case "disband", "del", "delete" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE))
);
return false;
}
if (args.length != 1 && args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster delete [name]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster delete [name]")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster;
@ -283,15 +280,15 @@ public class Cluster extends SubCommand {
cluster = area.getCluster(args[1]);
if (cluster == null) {
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Placeholder.miniMessage("cluster", args[1])
);
return false;
}
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
}
@ -299,32 +296,31 @@ public class Cluster extends SubCommand {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_DELETE_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_DELETE_OTHER))
);
return false;
}
}
DBFunc.delete(cluster);
player.sendMessage(TranslatableCaption.of("cluster.cluster_deleted"), Template.of(
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_deleted"), Placeholder.miniMessage(
"cluster",
String.valueOf(cluster)
));
return true;
}
case "res":
case "resize": {
case "res", "resize" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE))
);
return false;
}
if (args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster resize [name]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster resize [name]")
);
return false;
}
@ -335,7 +331,7 @@ public class Cluster extends SubCommand {
pos1 = PlotId.fromString(args[2]);
pos2 = PlotId.fromString(args[3]);
} catch (IllegalArgumentException ignored) {
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.not_valid_plot_id"));
return false;
}
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
@ -345,20 +341,20 @@ public class Cluster extends SubCommand {
// check if in cluster
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_OTHER))
);
return false;
}
@ -367,8 +363,8 @@ public class Cluster extends SubCommand {
PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2);
if (intersect != null) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"),
Template.of("cluster", intersect.getName())
TranslatableCaption.miniMessage("cluster.cluster_intersection"),
Placeholder.miniMessage("cluster", intersect.getName())
);
return false;
}
@ -383,8 +379,8 @@ public class Cluster extends SubCommand {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_SHRINK)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_SHRINK))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_SHRINK))
);
return false;
}
@ -394,8 +390,8 @@ public class Cluster extends SubCommand {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_RESIZE_EXPAND)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_EXPAND))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_RESIZE_EXPAND))
);
return false;
}
@ -413,49 +409,47 @@ public class Cluster extends SubCommand {
);
if (current + cluster.getArea() > allowed) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER + "." + (current + cluster.getArea()))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER + "." + (current + cluster.getArea()))
);
return false;
}
// resize cluster
DBFunc.resizeCluster(cluster, pos1, pos2);
player.sendMessage(TranslatableCaption.of("cluster.cluster_resized"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_resized"));
return true;
}
case "add":
case "inv":
case "invite": {
case "add", "inv", "invite" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_CLUSTER_INVITE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_CLUSTER_INVITE))
);
return false;
}
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster invite <player>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster invite <player>")
);
return false;
}
// check if in cluster
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_INVITE_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_INVITE_OTHER.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_INVITE_OTHER.toString())
);
return false;
}
@ -464,11 +458,11 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[1], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[1])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[1])
);
} else {
if (!cluster.isAdded(uuid)) {
@ -479,48 +473,46 @@ public class Cluster extends SubCommand {
PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (otherPlayer != null) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_invited"),
Template.of("cluster", cluster.getName())
TranslatableCaption.miniMessage("cluster.cluster_invited"),
Placeholder.miniMessage("cluster", cluster.getName())
);
}
}
player.sendMessage(TranslatableCaption.of("cluster.cluster_added_user"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_added_user"));
}
});
return true;
}
case "k":
case "remove":
case "kick": {
case "k", "remove", "kick" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_KICK.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_KICK.toString())
);
return false;
}
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster kick <player>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster kick <player>")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_KICK_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_KICK_OTHER.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_KICK_OTHER.toString())
);
return false;
}
@ -529,19 +521,19 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[1], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[1])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[1])
);
} else {
// Can't kick if the player is yourself, the owner, or not added to the cluster
if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner)
|| !cluster.isAdded(uuid)) {
player.sendMessage(
TranslatableCaption.of("cluster.cannot_kick_player"),
Template.of("value", cluster.getName())
TranslatableCaption.miniMessage("cluster.cannot_kick_player"),
Placeholder.miniMessage("value", cluster.getName())
);
} else {
if (cluster.helpers.contains(uuid)) {
@ -555,8 +547,8 @@ public class Cluster extends SubCommand {
PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (player2 != null) {
player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"),
Template.of("cluster", cluster.getName())
TranslatableCaption.miniMessage("cluster.cluster_removed"),
Placeholder.miniMessage("cluster", cluster.getName())
);
}
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
@ -566,56 +558,55 @@ public class Cluster extends SubCommand {
plot.unclaim();
}
}
player.sendMessage(TranslatableCaption.of("cluster.cluster_kicked_user"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_kicked_user"));
}
}
});
return true;
}
case "quit":
case "leave": {
case "quit", "leave" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_LEAVE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_LEAVE.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_LEAVE.toString())
);
return false;
}
if (args.length != 1 && args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster leave [name]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster leave [name]")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
PlotCluster cluster;
if (args.length == 2) {
cluster = area.getCluster(args[1]);
if (cluster == null) {
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Placeholder.miniMessage("cluster", args[1])
);
return false;
}
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
}
UUID uuid = player.getUUID();
if (!cluster.isAdded(uuid)) {
player.sendMessage(TranslatableCaption.of("cluster.cluster_not_added"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_not_added"));
return false;
}
if (uuid.equals(cluster.owner)) {
player.sendMessage(TranslatableCaption.of("cluster.cluster_cannot_leave"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_cannot_leave"));
return false;
}
if (cluster.helpers.contains(uuid)) {
@ -625,8 +616,8 @@ public class Cluster extends SubCommand {
cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid);
player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"),
Template.of("cluster", cluster.getName())
TranslatableCaption.miniMessage("cluster.cluster_removed"),
Placeholder.miniMessage("cluster", cluster.getName())
);
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName())
.ownedBy(uuid)) {
@ -637,86 +628,84 @@ public class Cluster extends SubCommand {
}
return true;
}
case "members": {
case "members" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_HELPERS)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_HELPERS.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_HELPERS.toString())
);
return false;
}
if (args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster members <add | remove> <player>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster members <add | remove> <player>")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[2], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[2])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[2])
);
} else {
if (args[1].equalsIgnoreCase("add")) {
cluster.helpers.add(uuid);
DBFunc.setHelper(cluster, uuid);
player.sendMessage(TranslatableCaption.of("cluster.cluster_added_helper"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_added_helper"));
} else if (args[1].equalsIgnoreCase("remove")) {
cluster.helpers.remove(uuid);
DBFunc.removeHelper(cluster, uuid);
player.sendMessage(TranslatableCaption.of("cluster.cluster_removed_helper"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_removed_helper"));
} else {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster members <add | remove> <player>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster members <add | remove> <player>")
);
}
}
});
return true;
}
case "spawn":
case "home":
case "tp": {
case "spawn", "home", "tp" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_TP.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_TP.toString())
);
return false;
}
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster tp <name>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster tp <name>")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster = area.getCluster(args[1]);
if (cluster == null) {
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Placeholder.miniMessage("cluster", args[1])
);
return false;
}
@ -724,36 +713,33 @@ public class Cluster extends SubCommand {
if (!cluster.isAdded(uuid)) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_TP_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_TP_OTHER.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_TP_OTHER.toString())
);
return false;
}
}
cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND_CLUSTER_TELEPORT));
player.sendMessage(TranslatableCaption.of("cluster.cluster_teleporting"));
player.sendMessage(TranslatableCaption.miniMessage("cluster.cluster_teleporting"));
return true;
}
case "i":
case "info":
case "show":
case "information": {
case "i", "info", "show", "information" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_INFO)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_TP.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_TP.toString())
);
return false;
}
if (args.length != 1 && args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster info [name]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster info [name]")
);
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster;
@ -761,15 +747,15 @@ public class Cluster extends SubCommand {
cluster = area.getCluster(args[1]);
if (cluster == null) {
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
TranslatableCaption.miniMessage("cluster.invalid_cluster_name"),
Placeholder.miniMessage("cluster", args[1])
);
return false;
}
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
}
@ -778,24 +764,20 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(cluster.owner, (username, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else {
final String owner;
if (username == null) {
owner = "unknown";
} else {
owner = username;
}
owner = Objects.requireNonNullElse(username, "unknown");
String name = cluster.getName();
String size = (cluster.getP2().getX() - cluster.getP1().getX() + 1) + "x" + (
cluster.getP2().getY() - cluster.getP1().getY() + 1);
String rights = cluster.isAdded(player.getUUID()) + "";
Caption message = TranslatableCaption.of("cluster.cluster_info");
Template idTemplate = Template.of("id", id);
Template ownerTemplate = Template.of("owner", owner);
Template nameTemplate = Template.of("name", name);
Template sizeTemplate = Template.of("size", size);
Template rightsTemplate = Template.of("rights", rights);
Caption message = TranslatableCaption.miniMessage("cluster.cluster_info");
Placeholder<?> idTemplate = Placeholder.miniMessage("id", id);
Placeholder<?> ownerTemplate = Placeholder.miniMessage("owner", owner);
Placeholder<?> nameTemplate = Placeholder.miniMessage("name", name);
Placeholder<?> sizeTemplate = Placeholder.miniMessage("size", size);
Placeholder<?> rightsTemplate = Placeholder.miniMessage("rights", rights);
player.sendMessage(
message,
idTemplate,
@ -808,38 +790,36 @@ public class Cluster extends SubCommand {
});
return true;
}
case "sh":
case "setspawn":
case "sethome": {
case "sh", "setspawn", "sethome" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_SETHOME.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_SETHOME.toString())
);
return false;
}
if (args.length != 1 && args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster sethome")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot cluster sethome")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Permission.PERMISSION_CLUSTER_SETHOME_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_CLUSTER_SETHOME_OTHER.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_CLUSTER_SETHOME_OTHER.toString())
);
return false;
}
@ -852,13 +832,13 @@ public class Cluster extends SubCommand {
cluster,
relative.getX() + "," + relative.getY() + "," + relative.getZ()
);
player.sendMessage(TranslatableCaption.of("position.position_set"));
player.sendMessage(TranslatableCaption.miniMessage("position.position_set"));
return true;
}
}
player.sendMessage(
TranslatableCaption.of("cluster.cluster_available_args"),
Template.of(
TranslatableCaption.miniMessage("cluster.cluster_available_args"),
Placeholder.miniMessage(
"list",
"<dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>"
)

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.player.PlayerMetaDataKeys;
import com.plotsquared.core.player.PlotPlayer;
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.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.Nullable;
public class CmdConfirm {
@ -58,10 +58,10 @@ public class CmdConfirm {
removePending(player);
if (commandStr != null) {
player.sendMessage(
TranslatableCaption.of("confirm.requires_confirm"),
Template.of("command", commandStr),
Template.of("timeout", String.valueOf(Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS)),
Template.of("value", "/plot confirm")
TranslatableCaption.miniMessage("confirm.requires_confirm"),
Placeholder.miniMessage("command", commandStr),
Placeholder.miniMessage("timeout", String.valueOf(Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS)),
Placeholder.miniMessage("value", "/plot confirm")
);
}
TaskManager.runTaskLater(() -> {

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.lang.reflect.InvocationTargetException;
@ -213,7 +213,7 @@ public abstract class Command {
}
Collections.reverse(path);
String descriptionKey = String.join(".", path);
this.description = TranslatableCaption.of(String.format("commands.description.%s", descriptionKey));
this.description = TranslatableCaption.miniMessage(String.format("commands.description.%s", descriptionKey));
} else {
this.description = StaticCaption.of(declaration.description());
}
@ -263,9 +263,9 @@ public abstract class Command {
max = c.size();
}
// Send the header
Template curTemplate = Template.of("cur", String.valueOf(page + 1));
Template maxTemplate = Template.of("max", String.valueOf(totalPages + 1));
Template amountTemplate = Template.of("amount", String.valueOf(c.size()));
Placeholder<?> curTemplate = Placeholder.miniMessage("cur", String.valueOf(page + 1));
Placeholder<?> maxTemplate = Placeholder.miniMessage("max", String.valueOf(totalPages + 1));
Placeholder<?> amountTemplate = Placeholder.miniMessage("amount", String.valueOf(c.size()));
player.sendMessage(header, curTemplate, maxTemplate, amountTemplate);
// Send the page content
List<T> subList = c.subList(page * size, max);
@ -274,13 +274,14 @@ public abstract class Command {
i++;
final CaptionHolder msg = new CaptionHolder();
add.run(i, obj, msg);
player.sendMessage(msg.get(), msg.getTemplates());
player.sendMessage(msg.get(), msg.getPlaceholders());
}
// Send the footer
Template command1 = Template.of("command1", baseCommand + " " + page);
Template command2 = Template.of("command2", baseCommand + " " + (page + 2));
Template clickable = Template.of("clickable", TranslatableCaption.of("list.clickable").getComponent(player));
player.sendMessage(TranslatableCaption.of("list.page_turn"), command1, command2, clickable);
Placeholder<?> command1 = Placeholder.miniMessage("command1", baseCommand + " " + page);
Placeholder<?> command2 = Placeholder.miniMessage("command2", baseCommand + " " + (page + 2));
Placeholder<?> clickable = Placeholder.miniMessage("clickable",
TranslatableCaption.miniMessage("list.clickable").getComponent(player));
player.sendMessage(TranslatableCaption.miniMessage("list.page_turn"), command1, command2, clickable);
}
/**
@ -327,12 +328,12 @@ public abstract class Command {
} catch (IllegalArgumentException ignored) {
}
// Command recommendation
player.sendMessage(TranslatableCaption.of("commandconfig.not_valid_subcommand"));
player.sendMessage(TranslatableCaption.miniMessage("commandconfig.not_valid_subcommand"));
List<Command> commands = getCommands(player);
if (commands.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("commandconfig.did_you_mean"),
Template.of("value", MainCommand.getInstance().help.getUsage())
TranslatableCaption.miniMessage("commandconfig.did_you_mean"),
Placeholder.miniMessage("value", MainCommand.getInstance().help.getUsage())
);
return CompletableFuture.completedFuture(false);
}
@ -352,8 +353,8 @@ public abstract class Command {
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
}
player.sendMessage(
TranslatableCaption.of("commandconfig.did_you_mean"),
Template.of("value", cmd.getUsage())
TranslatableCaption.miniMessage("commandconfig.did_you_mean"),
Placeholder.miniMessage("value", cmd.getUsage())
);
return CompletableFuture.completedFuture(false);
}
@ -388,8 +389,8 @@ public abstract class Command {
if (failed) {
// TODO improve or remove the Argument system
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", StringMan.join(fullSplit, " "))
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", StringMan.join(fullSplit, " "))
);
return false;
}
@ -477,8 +478,8 @@ public abstract class Command {
} else if (!Permissions.hasPermission(player, getPermission())) {
if (message) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", getPermission())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", getPermission())
);
}
} else {
@ -502,8 +503,8 @@ public abstract class Command {
public void sendUsage(PlotPlayer<?> player) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", getUsage())
);
}
@ -607,13 +608,13 @@ public abstract class Command {
return this.getFullId().hashCode();
}
public void checkTrue(boolean mustBeTrue, Caption message, Template... args) {
public void checkTrue(boolean mustBeTrue, Caption message, Placeholder<?>... args) {
if (!mustBeTrue) {
throw new CommandException(message, args);
}
}
public <T> T check(T object, Caption message, Template... args) {
public <T> T check(T object, Caption message, Placeholder<?>... args) {
if (object == null) {
throw new CommandException(message, args);
}
@ -629,17 +630,17 @@ public abstract class Command {
public static class CommandException extends RuntimeException {
private final Template[] args;
private final Placeholder<?>[] placeholders;
private final Caption message;
public CommandException(final @Nullable Caption message, final Template... args) {
public CommandException(final @Nullable Caption message, final Placeholder<?>... placeholders) {
this.message = message;
this.args = args;
this.placeholders = placeholders;
}
public void perform(final @Nullable PlotPlayer<?> player) {
if (player != null && message != null) {
player.sendMessage(message, args);
player.sendMessage(message, placeholders);
}
}

View File

@ -26,7 +26,7 @@
package com.plotsquared.core.command;
import com.plotsquared.core.configuration.caption.Caption;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
@ -41,7 +41,7 @@ public interface CommandCaller {
* @param caption Caption to send
* @param replacements Variable replacements
*/
void sendMessage(@NonNull Caption caption, @NonNull Template... replacements);
void sendMessage(@NonNull Caption caption, @NonNull Placeholder<?>... replacements);
/**
* Check the player's permissions. <i>Will be cached if permission caching is enabled.</i>

View File

@ -38,42 +38,42 @@ public enum CommandCategory implements Caption {
* Claiming CommandConfig.
* Such as: /plot claim
*/
CLAIMING(TranslatableCaption.of("category.command_category_claiming")),
CLAIMING(TranslatableCaption.miniMessage("category.command_category_claiming")),
/**
* Teleportation CommandConfig.
* Such as: /plot visit
*/
TELEPORT(TranslatableCaption.of("category.command_category_teleport")),
TELEPORT(TranslatableCaption.miniMessage("category.command_category_teleport")),
/**
* Protection.
*/
SETTINGS(TranslatableCaption.of("category.command_category_settings")),
SETTINGS(TranslatableCaption.miniMessage("category.command_category_settings")),
/**
* Chat.
*/
CHAT(TranslatableCaption.of("category.command_category_chat")),
CHAT(TranslatableCaption.miniMessage("category.command_category_chat")),
/**
* Web.
*/
SCHEMATIC(TranslatableCaption.of("category.command_category_schematic")),
SCHEMATIC(TranslatableCaption.miniMessage("category.command_category_schematic")),
/**
* Cosmetic.
*/
APPEARANCE(TranslatableCaption.of("category.command_category_appearance")),
APPEARANCE(TranslatableCaption.miniMessage("category.command_category_appearance")),
/**
* Information CommandConfig.
* Such as: /plot info
*/
INFO(TranslatableCaption.of("category.command_category_info")),
INFO(TranslatableCaption.miniMessage("category.command_category_info")),
/**
* Debug CommandConfig.
* Such as: /plot debug
*/
DEBUG(TranslatableCaption.of("category.command_category_debug")),
DEBUG(TranslatableCaption.miniMessage("category.command_category_debug")),
/**
* Administration commands.
*/
ADMINISTRATION(TranslatableCaption.of("category.command_category_administration"));
ADMINISTRATION(TranslatableCaption.miniMessage("category.command_category_administration"));
/**
* The category name (Readable).
*/

View File

@ -34,7 +34,7 @@ import com.plotsquared.core.plot.comment.CommentInbox;
import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.comment.PlotComment;
import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Arrays;
import java.util.Locale;
@ -50,9 +50,9 @@ public class Comment extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
TranslatableCaption.miniMessage("comment.comment_syntax"),
Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
);
return false;
}
@ -70,9 +70,9 @@ public class Comment extends SubCommand {
} else {
if (args.length < 3) {
player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
TranslatableCaption.miniMessage("comment.comment_syntax"),
Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
);
return false;
}
@ -82,15 +82,15 @@ public class Comment extends SubCommand {
CommentInbox inbox = CommentManager.inboxes.get(args[index - 1].toLowerCase());
if (inbox == null) {
player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
TranslatableCaption.miniMessage("comment.comment_syntax"),
Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
);
return false;
}
if (!inbox.canWrite(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox"));
player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox"));
return false;
}
@ -101,11 +101,11 @@ public class Comment extends SubCommand {
);
boolean result = inbox.addComment(plot, comment);
if (!result) {
player.sendMessage(TranslatableCaption.of("comment.no_plot_inbox"));
player.sendMessage(TranslatableCaption.miniMessage("comment.no_plot_inbox"));
player.sendMessage(
TranslatableCaption.of("comment.comment_syntax"),
Template.of("command", "/plot comment [X;Z]"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
TranslatableCaption.miniMessage("comment.comment_syntax"),
Placeholder.miniMessage("command", "/plot comment [X;Z]"),
Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), "|"))
);
return false;
}
@ -116,7 +116,7 @@ public class Comment extends SubCommand {
}
}
player.sendMessage(TranslatableCaption.of("comment.comment_added"));
player.sendMessage(TranslatableCaption.miniMessage("comment.comment_added"));
return true;
}

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.WorldUtil;
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.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@ -73,31 +73,31 @@ public class Condense extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length != 2 && args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense <area> <start | stop | info> [radius]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot condense <area> <start | stop | info> [radius]")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
if (area == null || !this.worldUtil.isWorld(area.getWorldName())) {
player.sendMessage(TranslatableCaption.of("invalid.invalid_area"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.invalid_area"));
return false;
}
switch (args[1].toLowerCase()) {
case "start" -> {
if (args.length == 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense" + area + " start <radius>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot condense" + area + " start <radius>")
);
return false;
}
if (Condense.TASK) {
player.sendMessage(TranslatableCaption.of("condense.task_already_started"));
player.sendMessage(TranslatableCaption.miniMessage("condense.task_already_started"));
return false;
}
if (!MathMan.isInteger(args[2])) {
player.sendMessage(TranslatableCaption.of("condense.invalid_radius"));
player.sendMessage(TranslatableCaption.miniMessage("condense.invalid_radius"));
return false;
}
int radius = Integer.parseInt(args[2]);
@ -141,7 +141,7 @@ public class Condense extends SubCommand {
int size = allPlots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) {
player.sendMessage(TranslatableCaption.of("condense.radius_too_small"));
player.sendMessage(TranslatableCaption.miniMessage("condense.radius_too_small"));
return false;
}
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
@ -155,20 +155,20 @@ public class Condense extends SubCommand {
start = start.getNextId();
}
if (free.isEmpty() || toMove.isEmpty()) {
player.sendMessage(TranslatableCaption.of("condense.no_free_plots_found"));
player.sendMessage(TranslatableCaption.miniMessage("condense.no_free_plots_found"));
return false;
}
player.sendMessage(TranslatableCaption.of("condense.task_started"));
player.sendMessage(TranslatableCaption.miniMessage("condense.task_started"));
Condense.TASK = true;
Runnable run = new Runnable() {
@Override
public void run() {
if (!Condense.TASK) {
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_cancelled"));
}
if (allPlots.isEmpty()) {
Condense.TASK = false;
player.sendMessage(TranslatableCaption.of("condense.task_complete"));
player.sendMessage(TranslatableCaption.miniMessage("condense.task_complete"));
return;
}
final Runnable task = this;
@ -186,9 +186,9 @@ public class Condense extends SubCommand {
result.set(origin.getPlotModificationManager().move(possible, player, () -> {
if (result.get()) {
player.sendMessage(
TranslatableCaption.of("condense.moving"),
Template.of("origin", String.valueOf(origin)),
Template.of("possible", String.valueOf(possible))
TranslatableCaption.miniMessage("condense.moving"),
Placeholder.miniMessage("origin", String.valueOf(origin)),
Placeholder.miniMessage("possible", String.valueOf(possible))
);
TaskManager.runTaskLater(task, TaskTime.ticks(1L));
}
@ -202,13 +202,13 @@ public class Condense extends SubCommand {
}
if (free.isEmpty()) {
Condense.TASK = false;
player.sendMessage(TranslatableCaption.of("condense.task_failed"));
player.sendMessage(TranslatableCaption.miniMessage("condense.task_failed"));
return;
}
if (i >= free.size()) {
player.sendMessage(
TranslatableCaption.of("condense.skipping"),
Template.of("plot", String.valueOf(origin))
TranslatableCaption.miniMessage("condense.skipping"),
Placeholder.miniMessage("plot", String.valueOf(origin))
);
}
}
@ -218,23 +218,23 @@ public class Condense extends SubCommand {
}
case "stop" -> {
if (!Condense.TASK) {
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
player.sendMessage(TranslatableCaption.miniMessage("condense.task_stopped"));
return false;
}
Condense.TASK = false;
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
player.sendMessage(TranslatableCaption.miniMessage("condense.task_stopped"));
return true;
}
case "info" -> {
if (args.length == 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense " + area + " info <radius>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot condense " + area + " info <radius>")
);
return false;
}
if (!MathMan.isInteger(args[2])) {
player.sendMessage(TranslatableCaption.of("condense.invalid_radius"));
player.sendMessage(TranslatableCaption.miniMessage("condense.invalid_radius"));
return false;
}
int radius = Integer.parseInt(args[2]);
@ -242,37 +242,37 @@ public class Condense extends SubCommand {
int size = plots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) {
player.sendMessage(TranslatableCaption.of("condense.radius_too_small"));
player.sendMessage(TranslatableCaption.miniMessage("condense.radius_too_small"));
return false;
}
int maxMove = getPlots(plots, minimumRadius).size();
int userMove = getPlots(plots, radius).size();
player.sendMessage(TranslatableCaption.of("condense.default_eval"));
player.sendMessage(TranslatableCaption.miniMessage("condense.default_eval"));
player.sendMessage(
TranslatableCaption.of("condense.minimum_radius"),
Template.of("minimumRadius", String.valueOf(minimumRadius))
TranslatableCaption.miniMessage("condense.minimum_radius"),
Placeholder.miniMessage("minimumRadius", String.valueOf(minimumRadius))
);
player.sendMessage(
TranslatableCaption.of("condense.minimum_radius"),
Template.of("maxMove", String.valueOf(maxMove))
TranslatableCaption.miniMessage("condense.minimum_radius"),
Placeholder.miniMessage("maxMove", String.valueOf(maxMove))
);
player.sendMessage(TranslatableCaption.of("condense.input_eval"));
player.sendMessage(TranslatableCaption.miniMessage("condense.input_eval"));
player.sendMessage(
TranslatableCaption.of("condense.input_radius"),
Template.of("radius", String.valueOf(radius))
TranslatableCaption.miniMessage("condense.input_radius"),
Placeholder.miniMessage("radius", String.valueOf(radius))
);
player.sendMessage(
TranslatableCaption.of("condense.estimated_moves"),
Template.of("userMove", String.valueOf(userMove))
TranslatableCaption.miniMessage("condense.estimated_moves"),
Placeholder.miniMessage("userMove", String.valueOf(userMove))
);
player.sendMessage(TranslatableCaption.of("condense.eta"));
player.sendMessage(TranslatableCaption.of("condense.radius_measured"));
player.sendMessage(TranslatableCaption.miniMessage("condense.eta"));
player.sendMessage(TranslatableCaption.miniMessage("condense.radius_measured"));
return true;
}
}
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense " + area.getWorldName() + " <start | stop | info> [radius]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot condense " + area.getWorldName() + " <start | stop | info> [radius]")
);
return false;
}

View File

@ -39,13 +39,13 @@ public class Confirm extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) {
CmdInstance command = CmdConfirm.getPending(player);
if (command == null) {
player.sendMessage(TranslatableCaption.of("confirm.failed_confirm"));
player.sendMessage(TranslatableCaption.miniMessage("confirm.failed_confirm"));
return false;
}
CmdConfirm.removePending(player);
if ((System.currentTimeMillis() - command.timestamp)
> Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS * 1000) {
player.sendMessage(TranslatableCaption.of("confirm.expired_confirm"));
player.sendMessage(TranslatableCaption.miniMessage("confirm.expired_confirm"));
return false;
}
TaskManager.runTaskAsync(command.command);

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "continue",
@ -57,32 +57,32 @@ public class Continue extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) {
Plot plot = player.getCurrentPlot();
if ((plot == null) || !plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", TranslatableCaption.of("permission.no_plot_perms").getComponent(player))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", TranslatableCaption.miniMessage("permission.no_plot_perms").getComponent(player))
);
return false;
}
if (!DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("done.done_not_done"));
player.sendMessage(TranslatableCaption.miniMessage("done.done_not_done"));
return false;
}
int size = plot.getConnectedPlots().size();
if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots()
< player.getPlotCount() + size)) {
player.sendMessage(
TranslatableCaption.of("permission.cant_claim_more_plots"),
Template.of("amount", String.valueOf(player.getAllowedPlots()))
TranslatableCaption.miniMessage("permission.cant_claim_more_plots"),
Placeholder.miniMessage("amount", String.valueOf(player.getAllowedPlots()))
);
return false;
}
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
@ -90,13 +90,13 @@ public class Continue extends SubCommand {
this.eventDispatcher.callFlagRemove(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Done flag removal")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Done flag removal")
);
return true;
}
plot.removeFlag(event.getFlag());
player.sendMessage(TranslatableCaption.of("done.done_removed"));
player.sendMessage(TranslatableCaption.miniMessage("done.done_removed"));
return true;
}

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "copy",
permission = "plots.copy",
@ -46,18 +46,18 @@ public class Copy extends SubCommand {
Location location = player.getLocation();
Plot plot1 = location.getPlotAbs();
if (plot1 == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN.toString())) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (args.length != 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot copy <X;Z>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot copy <X;Z>")
);
return false;
}
@ -66,21 +66,21 @@ public class Copy extends SubCommand {
return false;
}
if (plot1.equals(plot2)) {
player.sendMessage(TranslatableCaption.of("invalid.origin_cant_be_target"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.origin_cant_be_target"));
return false;
}
if (!plot1.getArea().isCompatible(plot2.getArea())) {
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible"));
player.sendMessage(TranslatableCaption.miniMessage("errors.plotworld_incompatible"));
return false;
}
plot1.getPlotModificationManager().copy(plot2, player).thenAccept(result -> {
if (result) {
player.sendMessage(TranslatableCaption.of("move.copy_success"), Template.of("origin", String.valueOf(plot1)),
Template.of("target", String.valueOf(plot2))
player.sendMessage(TranslatableCaption.miniMessage("move.copy_success"), Placeholder.miniMessage("origin", String.valueOf(plot1)),
Placeholder.miniMessage("target", String.valueOf(plot2))
);
} else {
player.sendMessage(TranslatableCaption.of("move.requires_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("move.requires_unowned"));
}
});

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "createroadschematic",
@ -55,20 +55,20 @@ public class CreateRoadSchematic extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
if (!(location.getPlotArea() instanceof HybridPlotWorld)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
this.hybridUtils.setupRoadSchematic(plot);
player.sendMessage(
TranslatableCaption.of("schematics.schematic_road_created"),
Template.of("command", "/plot debugroadregen")
TranslatableCaption.miniMessage("schematics.schematic_road_created"),
Placeholder.miniMessage("command", "/plot debugroadregen")
);
return true;
}

View File

@ -47,7 +47,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File;
@ -91,13 +91,13 @@ public class DatabaseCommand extends SubCommand {
TaskManager.runTaskAsync(() -> {
try {
ArrayList<Plot> ps = new ArrayList<>(plots);
player.sendMessage(TranslatableCaption.of("database.starting_conversion"));
player.sendMessage(TranslatableCaption.miniMessage("database.starting_conversion"));
manager.createPlotsAndData(ps, () -> {
player.sendMessage(TranslatableCaption.of("database.conversion_done"));
player.sendMessage(TranslatableCaption.miniMessage("database.conversion_done"));
manager.close();
});
} catch (Exception e) {
player.sendMessage(TranslatableCaption.of("database.conversion_failed"));
player.sendMessage(TranslatableCaption.miniMessage("database.conversion_failed"));
e.printStackTrace();
}
});
@ -107,8 +107,8 @@ public class DatabaseCommand extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot database [area] <sqlite | mysql | import>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot database [area] <sqlite | mysql | import>")
);
return false;
}
@ -122,10 +122,10 @@ public class DatabaseCommand extends SubCommand {
}
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot database [area] <sqlite|mysql|import>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot database [area] <sqlite|mysql|import>")
);
player.sendMessage(TranslatableCaption.of("database.arg"));
player.sendMessage(TranslatableCaption.miniMessage("database.arg"));
return false;
}
try {
@ -135,8 +135,8 @@ public class DatabaseCommand extends SubCommand {
case "import" -> {
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot database import <sqlite file> [prefix]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot database import <sqlite file> [prefix]")
);
return false;
}
@ -146,12 +146,12 @@ public class DatabaseCommand extends SubCommand {
);
if (!file.exists()) {
player.sendMessage(
TranslatableCaption.of("database.does_not_exist"),
Template.of("value", String.valueOf(file))
TranslatableCaption.miniMessage("database.does_not_exist"),
Placeholder.miniMessage("value", String.valueOf(file))
);
return false;
}
player.sendMessage(TranslatableCaption.of("database.starting_conversion"));
player.sendMessage(TranslatableCaption.miniMessage("database.starting_conversion"));
implementation = new SQLite(file);
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "",
this.eventDispatcher, this.plotListener, this.worldConfiguration
@ -190,9 +190,9 @@ public class DatabaseCommand extends SubCommand {
}
}
player.sendMessage(
TranslatableCaption.of("database.skipping_duplicated_plot"),
Template.of("plot", String.valueOf(plot)),
Template.of("id", String.valueOf(plot.temp))
TranslatableCaption.miniMessage("database.skipping_duplicated_plot"),
Placeholder.miniMessage("plot", String.valueOf(plot)),
Placeholder.miniMessage("id", String.valueOf(plot.temp))
);
continue;
}
@ -207,7 +207,7 @@ public class DatabaseCommand extends SubCommand {
}
DBFunc.createPlotsAndData(
plots,
() -> player.sendMessage(TranslatableCaption.of("database.conversion_done"))
() -> player.sendMessage(TranslatableCaption.miniMessage("database.conversion_done"))
);
return true;
}
@ -252,19 +252,19 @@ public class DatabaseCommand extends SubCommand {
DatabaseCommand.insertPlots(manager, plots, player);
return true;
} catch (ClassNotFoundException | SQLException e) {
player.sendMessage(TranslatableCaption.of("database.failed_to_save_plots"));
player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin"));
player.sendMessage(TranslatableCaption.miniMessage("database.failed_to_save_plots"));
player.sendMessage(TranslatableCaption.miniMessage("errors.stacktrace_begin"));
e.printStackTrace();
player.sendMessage(TranslatableCaption.of(("errors.stacktrace_end")));
player.sendMessage(TranslatableCaption.of("database.invalid_args"));
player.sendMessage(TranslatableCaption.miniMessage(("errors.stacktrace_end")));
player.sendMessage(TranslatableCaption.miniMessage("database.invalid_args"));
return false;
}
} catch (ClassNotFoundException | SQLException e) {
player.sendMessage(TranslatableCaption.of("database.failed_to_open"));
player.sendMessage(TranslatableCaption.of("errors.stacktrace_begin"));
player.sendMessage(TranslatableCaption.miniMessage("database.failed_to_open"));
player.sendMessage(TranslatableCaption.miniMessage("errors.stacktrace_begin"));
e.printStackTrace();
player.sendMessage(TranslatableCaption.of("errors.stacktrace_end"));
player.sendMessage(TranslatableCaption.of("database.invalid_args"));
player.sendMessage(TranslatableCaption.miniMessage("errors.stacktrace_end"));
player.sendMessage(TranslatableCaption.miniMessage("database.invalid_args"));
return false;
}
}

View File

@ -41,7 +41,8 @@ import com.plotsquared.core.uuid.UUIDMapping;
import com.sk89q.worldedit.world.entity.EntityType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -74,8 +75,8 @@ public class Debug extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length == 0) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot debug <loadedchunks | player | debug-players | entitytypes | msg>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot debug <loadedchunks | player | debug-players | entitytypes | msg>")
);
}
if (args.length > 0) {
@ -90,7 +91,7 @@ public class Debug extends SubCommand {
}
if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) {
final long start = System.currentTimeMillis();
player.sendMessage(TranslatableCaption.of("debug.fetching_loaded_chunks"));
player.sendMessage(TranslatableCaption.miniMessage("debug.fetching_loaded_chunks"));
TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption
.of("Loaded chunks: " + this.worldUtil
.getChunkChunks(player.getLocation().getWorldName())
@ -101,24 +102,24 @@ public class Debug extends SubCommand {
if (args.length > 0 && "uuids".equalsIgnoreCase(args[0])) {
final Collection<UUIDMapping> mappings = PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately();
player.sendMessage(
TranslatableCaption.of("debug.cached_uuids"),
Template.of("value", String.valueOf(mappings.size()))
TranslatableCaption.miniMessage("debug.cached_uuids"),
Placeholder.miniMessage("value", String.valueOf(mappings.size()))
);
return true;
}
if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) {
player.sendMessage(TranslatableCaption.of("debug.player_in_debugmode"));
player.sendMessage(TranslatableCaption.miniMessage("debug.player_in_debugmode"));
for (final PlotPlayer<?> pp : PlotPlayer.getDebugModePlayers()) {
player.sendMessage(
TranslatableCaption.of("debug.player_in_debugmode_list"),
Template.of("value", pp.getName())
TranslatableCaption.miniMessage("debug.player_in_debugmode_list"),
Placeholder.miniMessage("value", pp.getName())
);
}
return true;
}
if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) {
EntityCategories.init();
player.sendMessage(TranslatableCaption.of("debug.entity_categories"));
player.sendMessage(TranslatableCaption.miniMessage("debug.entity_categories"));
EntityCategory.REGISTRY.forEach(category -> {
final StringBuilder builder =
new StringBuilder("§7- §6").append(category.getId()).append("§7: §6");
@ -144,28 +145,30 @@ public class Debug extends SubCommand {
.getCaptionMap(TranslatableCaption.DEFAULT_NAMESPACE)
.getCaptions();
TextComponent.Builder information = Component.text();
Component header = MINI_MESSAGE.parse(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n");
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n";
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n";
Component header = MINI_MESSAGE.parse(TranslatableCaption.miniMessage("debug.debug_header").getComponent(player) + "\n");
String line = TranslatableCaption.miniMessage("debug.debug_line").getComponent(player) + "\n";
String section = TranslatableCaption.miniMessage("debug.debug_section").getComponent(player) + "\n";
information.append(header);
information.append(MINI_MESSAGE.parse(section, Template.of("val", "PlotArea")));
information.append(MINI_MESSAGE.deserialize(section,
PlaceholderResolver.placeholders(Placeholder.miniMessage("val", "PlotArea"))));
information.append(MINI_MESSAGE
.parse(
.deserialize(
line,
Template.of("var", "Plot Worlds"),
Template.of("val", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", "))
PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Plot Worlds"),
Placeholder.miniMessage("val", StringMan.join(this.plotAreaManager.getAllPlotAreas(), ", ")))
));
information.append(
MINI_MESSAGE.parse(
MINI_MESSAGE.deserialize(
line,
Template.of("var", "Owned Plots"),
Template.of("val", String.valueOf(PlotQuery.newQuery().allPlots().count()))
PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Owned Plots"),
Placeholder.miniMessage("val", String.valueOf(PlotQuery.newQuery().allPlots().count())))
));
information.append(MINI_MESSAGE.parse(section, Template.of("val", "Messages")));
information.append(MINI_MESSAGE.parse(
information.append(MINI_MESSAGE.deserialize(section,
PlaceholderResolver.placeholders(Placeholder.miniMessage("val", "Messages"))));
information.append(MINI_MESSAGE.deserialize(
line,
Template.of("var", "Total Messages"),
Template.of("val", String.valueOf(captions.size()))
PlaceholderResolver.placeholders(Placeholder.miniMessage("var", "Total Messages"),
Placeholder.miniMessage("val", String.valueOf(captions.size())))
));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(information.build())));
return true;

View File

@ -46,10 +46,10 @@ public class DebugAllowUnsafe extends SubCommand {
if (unsafeAllowed.contains(player.getUUID())) {
unsafeAllowed.remove(player.getUUID());
player.sendMessage(TranslatableCaption.of("unsafe.debugallowunsafe_off"));
player.sendMessage(TranslatableCaption.miniMessage("unsafe.debugallowunsafe_off"));
} else {
unsafeAllowed.add(player.getUUID());
player.sendMessage(TranslatableCaption.of("unsafe.debugallowunsafe_on"));
player.sendMessage(TranslatableCaption.miniMessage("unsafe.debugallowunsafe_on"));
}
return true;
}

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Arrays;
@ -95,24 +95,24 @@ public class DebugExec extends SubCommand {
case "analyze" -> {
Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
PlotAnalysis analysis = plot.getComplexity(null);
if (analysis != null) {
player.sendMessage(
TranslatableCaption.of("debugexec.changes_column"),
Template.of("value", String.valueOf(analysis.changes))
TranslatableCaption.miniMessage("debugexec.changes_column"),
Placeholder.miniMessage("value", String.valueOf(analysis.changes))
);
return true;
}
player.sendMessage(TranslatableCaption.of("debugexec.starting_task"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.starting_task"));
this.hybridUtils.analyzePlot(plot, new RunnableVal<>() {
@Override
public void run(PlotAnalysis value) {
player.sendMessage(
TranslatableCaption.of("debugexec.analyze_done"),
Template.of("command", "/plot debugexec analyze")
TranslatableCaption.miniMessage("debugexec.analyze_done"),
Placeholder.miniMessage("command", "/plot debugexec analyze")
);
}
});
@ -121,10 +121,10 @@ public class DebugExec extends SubCommand {
case "calibrate-analysis" -> {
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot debugexec analyze <threshold>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot debugexec analyze <threshold>")
);
player.sendMessage(TranslatableCaption.of("debugexec.threshold_default"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.threshold_default"));
return false;
}
double threshold;
@ -132,14 +132,14 @@ public class DebugExec extends SubCommand {
threshold = Integer.parseInt(args[1]) / 100d;
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("debugexec.invalid_threshold"),
Template.of("value", args[1])
TranslatableCaption.miniMessage("debugexec.invalid_threshold"),
Placeholder.miniMessage("value", args[1])
);
player.sendMessage(TranslatableCaption.of("debugexec.threshold_default_double"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.threshold_default_double"));
return false;
}
PlotAnalysis.calcOptimalModifiers(
() -> player.sendMessage(TranslatableCaption.of("debugexec.calibration_done")),
() -> player.sendMessage(TranslatableCaption.miniMessage("debugexec.calibration_done")),
threshold
);
return true;
@ -149,25 +149,25 @@ public class DebugExec extends SubCommand {
ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
}
if (ExpireManager.IMP.runAutomatedTask()) {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_started"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.expiry_started"));
} else {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.expiry_already_started"));
}
return true;
}
case "stop-expire" -> {
if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
player.sendMessage(TranslatableCaption.of("debugexec.task_halted"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_halted"));
} else {
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_cancelled"));
}
return true;
}
case "remove-flag" -> {
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot debugexec remove-flag <flag>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot debugexec remove-flag <flag>")
);
return false;
}
@ -184,24 +184,24 @@ public class DebugExec extends SubCommand {
}
}
player.sendMessage(
TranslatableCaption.of("debugexec.cleared_flag"),
Template.of("value", flag)
TranslatableCaption.miniMessage("debugexec.cleared_flag"),
Placeholder.miniMessage("value", flag)
);
return true;
}
case "start-rgar" -> {
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Invalid syntax: /plot debugexec start-rgar <world>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Invalid syntax: /plot debugexec start-rgar <world>")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) {
player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"),
Template.of("value", args[1])
TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Placeholder.miniMessage("value", args[1])
);
return false;
}
@ -212,18 +212,18 @@ public class DebugExec extends SubCommand {
result = this.hybridUtils.scheduleRoadUpdate(area, 0);
}
if (!result) {
player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.mass_schematic_update_in_progress"));
return false;
}
return true;
}
case "stop-rgar" -> {
if (!HybridUtils.UPDATE) {
player.sendMessage(TranslatableCaption.of("debugexec.task_not_running"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_not_running"));
return false;
}
HybridUtils.UPDATE = false;
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.task_cancelled"));
return true;
}
}

View File

@ -70,14 +70,14 @@ public class DebugImportWorlds extends Command {
) throws CommandException {
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
if (!(this.plotAreaManager instanceof SinglePlotAreaManager)) {
player.sendMessage(TranslatableCaption.of("debugimportworlds.single_plot_area"));
player.sendMessage(TranslatableCaption.miniMessage("debugimportworlds.single_plot_area"));
return CompletableFuture.completedFuture(false);
}
SinglePlotArea area = ((SinglePlotAreaManager) this.plotAreaManager).getArea();
PlotId id = PlotId.of(0, 0);
File container = PlotSquared.platform().worldContainer();
if (container.equals(new File("."))) {
player.sendMessage(TranslatableCaption.of("debugimportworlds.world_container"));
player.sendMessage(TranslatableCaption.miniMessage("debugimportworlds.world_container"));
return CompletableFuture.completedFuture(false);
}
for (File folder : container.listFiles()) {
@ -87,7 +87,7 @@ public class DebugImportWorlds extends Command {
if (name.length() > 16) {
uuid = UUID.fromString(name);
} else {
player.sendMessage(TranslatableCaption.of("players.fetching_player"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_player"));
uuid = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(name, 60000L);
}
if (uuid == null) {
@ -103,7 +103,7 @@ public class DebugImportWorlds extends Command {
}
}
}
player.sendMessage(TranslatableCaption.of("players.done"));
player.sendMessage(TranslatableCaption.miniMessage("players.done"));
return CompletableFuture.completedFuture(true);
}

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.inject.annotations.WorldFile;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File;
@ -132,9 +132,9 @@ public class DebugPaste extends SubCommand {
.addFile(logFile);
} catch (IOException ignored) {
player.sendMessage(
TranslatableCaption.of("debugpaste.latest_log"),
Template.of("file", "latest.log"),
Template.of("size", "14MB")
TranslatableCaption.miniMessage("debugpaste.latest_log"),
Placeholder.miniMessage("file", "latest.log"),
Placeholder.miniMessage("size", "14MB")
);
}
@ -142,16 +142,16 @@ public class DebugPaste extends SubCommand {
incendoPaster.addFile(this.configFile);
} catch (final IllegalArgumentException ignored) {
player.sendMessage(
TranslatableCaption.of("debugpaste.empty_file"),
Template.of("file", "settings.yml")
TranslatableCaption.miniMessage("debugpaste.empty_file"),
Placeholder.miniMessage("file", "settings.yml")
);
}
try {
incendoPaster.addFile(this.worldfile);
} catch (final IllegalArgumentException ignored) {
player.sendMessage(
TranslatableCaption.of("debugpaste.empty_file"),
Template.of("file", "worlds.yml")
TranslatableCaption.miniMessage("debugpaste.empty_file"),
Placeholder.miniMessage("file", "worlds.yml")
);
}
@ -163,8 +163,8 @@ public class DebugPaste extends SubCommand {
incendoPaster.addFile(MultiverseWorlds, "Multiverse-Core/worlds.yml");
} catch (final IOException ignored) {
player.sendMessage(
TranslatableCaption.of("debugpaste.skip_multiverse"),
Template.of("file", "worlds.yml")
TranslatableCaption.miniMessage("debugpaste.skip_multiverse"),
Placeholder.miniMessage("file", "worlds.yml")
);
}
@ -178,21 +178,21 @@ public class DebugPaste extends SubCommand {
final String link =
String.format("https://athion.net/ISPaster/paste/view/%s", pasteId);
player.sendMessage(
TranslatableCaption.of("debugpaste.debug_report_created"),
Template.of("url", link)
TranslatableCaption.miniMessage("debugpaste.debug_report_created"),
Placeholder.miniMessage("url", link)
);
} else {
final String responseMessage = jsonObject.get("response").getAsString();
player.sendMessage(
TranslatableCaption.of("debugpaste.creation_failed"),
Template.of("value", responseMessage)
TranslatableCaption.miniMessage("debugpaste.creation_failed"),
Placeholder.miniMessage("value", responseMessage)
);
}
} catch (final Throwable throwable) {
throwable.printStackTrace();
player.sendMessage(
TranslatableCaption.of("debugpaste.creation_failed"),
Template.of("value", throwable.getMessage())
TranslatableCaption.miniMessage("debugpaste.creation_failed"),
Placeholder.miniMessage("value", throwable.getMessage())
);
}
} catch (IOException e) {

View File

@ -35,7 +35,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.queue.QueueCoordinator;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Arrays;
@ -66,16 +66,16 @@ public class DebugRoadRegen extends SubCommand {
Plot plot = location.getPlotAbs();
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE)
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
);
return false;
}
PlotArea area = player.getPlotAreaAbs();
check(area, TranslatableCaption.of("errors.not_in_plot_world"));
check(area, TranslatableCaption.miniMessage("errors.not_in_plot_world"));
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
String kind = args[0].toLowerCase();
@ -86,8 +86,8 @@ public class DebugRoadRegen extends SubCommand {
return regenRegion(player, Arrays.copyOfRange(args, 1, args.length));
default:
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE)
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
);
return false;
}
@ -97,24 +97,24 @@ public class DebugRoadRegen extends SubCommand {
Location location = player.getLocation();
PlotArea area = location.getPlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
} else if (plot.isMerged()) {
player.sendMessage(TranslatableCaption.of("debug.requires_unmerged"));
player.sendMessage(TranslatableCaption.miniMessage("debug.requires_unmerged"));
} else {
PlotManager manager = area.getPlotManager();
QueueCoordinator queue = area.getQueue();
queue.setCompleteTask(() -> {
player.sendMessage(
TranslatableCaption.of("debugroadregen.regen_done"),
Template.of("value", plot.getId().toString())
TranslatableCaption.miniMessage("debugroadregen.regen_done"),
Placeholder.miniMessage("value", plot.getId().toString())
);
player.sendMessage(
TranslatableCaption.of("debugroadregen.regen_all"),
Template.of("value", "/plot regenallroads")
TranslatableCaption.miniMessage("debugroadregen.regen_all"),
Placeholder.miniMessage("value", "/plot regenallroads")
);
});
manager.createRoadEast(plot, queue);
@ -132,19 +132,19 @@ public class DebugRoadRegen extends SubCommand {
height = Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"),
Template.of("value", "0, 256")
TranslatableCaption.miniMessage("invalid.not_valid_number"),
Placeholder.miniMessage("value", "0, 256")
);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE)
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
);
return false;
}
} else if (args.length != 0) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", DebugRoadRegen.USAGE)
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", DebugRoadRegen.USAGE)
);
return false;
}
@ -152,25 +152,25 @@ public class DebugRoadRegen extends SubCommand {
Location location = player.getLocation();
PlotArea area = location.getPlotArea();
if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
}
Plot plot = player.getCurrentPlot();
PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) {
player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_plot_world"));
return true;
}
player.sendMessage(
TranslatableCaption.of("debugroadregen.schematic"),
Template.of("command", "/plot createroadschematic")
TranslatableCaption.miniMessage("debugroadregen.schematic"),
Placeholder.miniMessage("command", "/plot createroadschematic")
);
player.sendMessage(
TranslatableCaption.of("debugroadregen.regenallroads"),
Template.of("command", "/plot regenallroads")
TranslatableCaption.miniMessage("debugroadregen.regenallroads"),
Placeholder.miniMessage("command", "/plot regenallroads")
);
boolean result = this.hybridUtils.scheduleSingleRegionRoadUpdate(plot, height);
if (!result) {
player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.mass_schematic_update_in_progress"));
return false;
}
return true;

View File

@ -43,10 +43,10 @@ public class DebugSaveTest extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
final List<Plot> plots = PlotQuery.newQuery().allPlots().asList();
player.sendMessage(TranslatableCaption.of("debugsavetest.starting"));
player.sendMessage(TranslatableCaption.miniMessage("debugsavetest.starting"));
DBFunc.createPlotsAndData(
plots,
() -> player.sendMessage(TranslatableCaption.of("debugsavetest.done"))
() -> player.sendMessage(TranslatableCaption.miniMessage("debugsavetest.done"))
);
return true;
}

View File

@ -40,7 +40,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -70,29 +70,29 @@ public class Delete extends SubCommand {
Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
Result eventResult = this.eventDispatcher.callDelete(plot).getEventResult();
if (eventResult == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Delete")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Delete")
);
return true;
}
boolean force = eventResult == Result.FORCE;
if (!force && !plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DELETE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
final PlotArea plotArea = plot.getArea();
@ -102,7 +102,7 @@ public class Delete extends SubCommand {
player.getPlotCount(location.getWorldName());
Runnable run = () -> {
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return;
}
final long start = System.currentTimeMillis();
@ -120,22 +120,22 @@ public class Delete extends SubCommand {
if (value > 0d) {
this.econHandler.depositMoney(player, value);
player.sendMessage(
TranslatableCaption.of("economy.added_balance"),
Template.of("money", this.econHandler.format(value))
TranslatableCaption.miniMessage("economy.added_balance"),
Placeholder.miniMessage("money", this.econHandler.format(value))
);
}
}
player.sendMessage(
TranslatableCaption.of("working.deleting_done"),
Template.of("amount", String.valueOf(System.currentTimeMillis() - start)),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("working.deleting_done"),
Placeholder.miniMessage("amount", String.valueOf(System.currentTimeMillis() - start)),
Placeholder.miniMessage("plot", plot.getId().toString())
);
eventDispatcher.callPostDelete(plot);
});
if (result) {
plot.addRunning();
} else {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
}
};
if (hasConfirmation(player)) {

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil;
import com.sk89q.worldedit.world.gamemode.GameModes;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -79,16 +79,16 @@ public class Deny extends SubCommand {
Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return true;
}
@ -96,19 +96,19 @@ public class Deny extends SubCommand {
int size = plot.getDenied().size();
if (size >= maxDenySize) {
player.sendMessage(
TranslatableCaption.of("members.plot_max_members_denied"),
Template.of("amount", String.valueOf(size))
TranslatableCaption.miniMessage("members.plot_max_members_denied"),
Placeholder.miniMessage("amount", String.valueOf(size))
);
return false;
}
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
} else {
for (UUID uuid : uuids) {
@ -116,16 +116,16 @@ public class Deny extends SubCommand {
Permissions.hasPermission(player, Permission.PERMISSION_DENY_EVERYONE) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DENY))) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
} else if (plot.isOwner(uuid)) {
player.sendMessage(TranslatableCaption.of("deny.cant_remove_owner"));
player.sendMessage(TranslatableCaption.miniMessage("deny.cant_remove_owner"));
return;
} else if (plot.getDenied().contains(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_added"),
Template.of("player", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("member.already_added"),
Placeholder.miniMessage("player", PlayerManager.getName(uuid))
);
return;
} else {
@ -148,7 +148,7 @@ public class Deny extends SubCommand {
}
}
}
player.sendMessage(TranslatableCaption.of("deny.denied_added"));
player.sendMessage(TranslatableCaption.miniMessage("deny.denied_added"));
}
});
@ -175,7 +175,7 @@ public class Deny extends SubCommand {
}
Location location = player.getLocation();
Location spawn = this.worldUtil.getSpawn(location.getWorldName());
player.sendMessage(TranslatableCaption.of("deny.you_got_denied"));
player.sendMessage(TranslatableCaption.miniMessage("deny.you_got_denied"));
if (plot.equals(spawn.getPlot())) {
Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
if (plot.equals(newSpawn.getPlot())) {

View File

@ -34,7 +34,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
import com.plotsquared.core.util.EventDispatcher;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "setdescription",
@ -60,13 +60,13 @@ public class Desc extends SetCommand {
.getFlag(DescriptionFlag.class), plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Description removal")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Description removal")
);
return false;
}
plot.removeFlag(event.getFlag());
player.sendMessage(TranslatableCaption.of("desc.desc_unset"));
player.sendMessage(TranslatableCaption.miniMessage("desc.desc_unset"));
return true;
}
PlotFlagAddEvent event = this.eventDispatcher.callFlagAdd(plot
@ -75,17 +75,17 @@ public class Desc extends SetCommand {
.createFlagInstance(desc), plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Description set")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Description set")
);
return false;
}
boolean result = plot.setFlag(event.getFlag());
if (!result) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_added"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_added"));
return false;
}
player.sendMessage(TranslatableCaption.of("desc.desc_set"));
player.sendMessage(TranslatableCaption.miniMessage("desc.desc_set"));
return true;
}

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "done",
@ -70,35 +70,35 @@ public class Done extends SubCommand {
Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if ((plot == null) || !plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
PlotDoneEvent event = this.eventDispatcher.callDone(plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Done")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Done")
);
return true;
}
boolean force = event.getEventResult() == Result.FORCE;
if (!force && !plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DONE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("done.done_already_done"));
player.sendMessage(TranslatableCaption.miniMessage("done.done_already_done"));
return false;
}
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
plot.addRunning();
player.sendMessage(
TranslatableCaption.of("web.generating_link"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("web.generating_link"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done");
if (ExpireManager.IMP == null || doneRequirements == null) {
@ -120,7 +120,7 @@ public class Done extends SubCommand {
private void finish(Plot plot, PlotPlayer<?> player, boolean success) {
if (!success) {
player.sendMessage(TranslatableCaption.of("done.done_insufficient_complexity"));
player.sendMessage(TranslatableCaption.miniMessage("done.done_insufficient_complexity"));
return;
}
long flagValue = System.currentTimeMillis() / 1000;
@ -128,11 +128,11 @@ public class Done extends SubCommand {
.createFlagInstance(Long.toString(flagValue));
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(TranslatableCaption.of("events.event_denied"));
player.sendMessage(TranslatableCaption.miniMessage("events.event_denied"));
return;
}
plot.setFlag(plotFlag);
player.sendMessage(TranslatableCaption.of("done.done_success"));
player.sendMessage(TranslatableCaption.miniMessage("done.done_success"));
}
}

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.URL;
@ -82,36 +82,36 @@ public class Download extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
String world = player.getLocation().getWorldName();
if (!this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
player.sendMessage(TranslatableCaption.of("done.done_not_done"));
player.sendMessage(TranslatableCaption.miniMessage("done.done_not_done"));
return false;
}
if ((!plot.isOwner(player.getUUID())) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN.toString())) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
if (args.length == 0 || (args.length == 1 && StringMan
.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
plot.addRunning();
@ -120,12 +120,12 @@ public class Download extends SubCommand {
.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_DOWNLOAD_WORLD)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_DOWNLOAD_WORLD.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_DOWNLOAD_WORLD.toString())
);
return false;
}
player.sendMessage(TranslatableCaption.of("schematics.mca_file_size"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.mca_file_size"));
plot.addRunning();
this.worldUtil.saveWorld(world);
this.worldUtil.upload(plot, null, null, new RunnableVal<>() {
@ -134,19 +134,19 @@ public class Download extends SubCommand {
plot.removeRunning();
if (url == null) {
player.sendMessage(
TranslatableCaption.of("web.generating_link_failed"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("web.generating_link_failed"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
return;
}
player.sendMessage(TranslatableCaption.of("web.generation_link_success_legacy_world"), Template.of("url", url.toString()));
player.sendMessage(TranslatableCaption.miniMessage("web.generation_link_success_legacy_world"), Placeholder.miniMessage("url", url.toString()));
}
});
} else {
sendUsage(player);
return false;
}
player.sendMessage(TranslatableCaption.of("web.generating_link"), Template.of("plot", plot.getId().toString()));
player.sendMessage(TranslatableCaption.miniMessage("web.generating_link"), Placeholder.miniMessage("plot", plot.getId().toString()));
return true;
}
@ -189,9 +189,9 @@ public class Download extends SubCommand {
@Override
public void run(URL value) {
player.sendMessage(
TranslatableCaption.of("web.generation_link_success"),
Template.of("download", value.toString()),
Template.of("delete", "Not available")
TranslatableCaption.miniMessage("web.generation_link_success"),
Placeholder.miniMessage("download", value.toString()),
Placeholder.miniMessage("delete", "Not available")
);
player.sendMessage(StaticCaption.of(value.toString()));
}
@ -204,14 +204,14 @@ public class Download extends SubCommand {
.whenComplete((result, throwable) -> {
if (throwable != null || !result.isSuccess()) {
player.sendMessage(
TranslatableCaption.of("web.generating_link_failed"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("web.generating_link_failed"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("web.generation_link_success"),
Template.of("download", result.getDownloadUrl()),
Template.of("delete", result.getDeletionUrl())
TranslatableCaption.miniMessage("web.generation_link_success"),
Placeholder.miniMessage("download", result.getDownloadUrl()),
Placeholder.miniMessage("delete", result.getDeletionUrl())
);
}
});

View File

@ -29,7 +29,7 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.CaptionUtility;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -53,7 +53,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -85,8 +86,8 @@ public final class FlagCommand extends Command {
private static boolean sendMessage(PlotPlayer<?> player) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot flag <set | remove | add | list | info> <flag> <value>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot flag <set | remove | add | list | info> <flag> <value>")
);
return true;
}
@ -111,8 +112,8 @@ public final class FlagCommand extends Command {
}
if (!result) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of(
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage(
"node",
perm
)
@ -131,16 +132,16 @@ public final class FlagCommand extends Command {
);
final boolean result = Permissions.hasPermission(player, permission);
if (!result) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", permission));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_permission"), Placeholder.miniMessage("node", permission));
return false;
}
}
} catch (final FlagParseException e) {
player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"),
Template.of("flag_name", flag.getName()),
Template.of("flag_value", e.getValue()),
Template.of("error", e.getErrorMessage().getComponent(player))
TranslatableCaption.miniMessage("flag.flag_parse_error"),
Placeholder.miniMessage("flag_name", flag.getName()),
Placeholder.miniMessage("flag_value", e.getValue()),
Placeholder.miniMessage("error", e.getErrorMessage().getComponent(player))
);
return false;
} catch (final Exception e) {
@ -157,7 +158,7 @@ public final class FlagCommand extends Command {
perm = basePerm;
}
if (!result) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", perm));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_permission"), Placeholder.miniMessage("node", perm));
}
return result;
}
@ -171,18 +172,18 @@ public final class FlagCommand extends Command {
final Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_SET_FLAG_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SET_FLAG_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SET_FLAG_OTHER))
);
return false;
}
@ -216,14 +217,14 @@ public final class FlagCommand extends Command {
final String best = stringComparison.getBestMatch();
if (best != null) {
player.sendMessage(
TranslatableCaption.of("flag.not_valid_flag_suggested"),
Template.of("value", best)
TranslatableCaption.miniMessage("flag.not_valid_flag_suggested"),
Placeholder.miniMessage("value", best)
);
suggested = true;
}
} catch (final Exception ignored) { /* Happens sometimes because of mean code */ }
if (!suggested) {
player.sendMessage(TranslatableCaption.of("flag.not_valid_flag"));
player.sendMessage(TranslatableCaption.miniMessage("flag.not_valid_flag"));
}
return null;
}
@ -325,8 +326,8 @@ public final class FlagCommand extends Command {
}
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot flag set <flag> <value>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot flag set <flag> <value>")
);
return;
}
@ -338,8 +339,8 @@ public final class FlagCommand extends Command {
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Flag set")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Flag set")
);
return;
}
@ -354,16 +355,16 @@ public final class FlagCommand extends Command {
parsed = plotFlag.parse(value);
} catch (final FlagParseException e) {
player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"),
Template.of("flag_name", plotFlag.getName()),
Template.of("flag_value", e.getValue()),
Template.of("error", e.getErrorMessage().getComponent(player))
TranslatableCaption.miniMessage("flag.flag_parse_error"),
Placeholder.miniMessage("flag_name", plotFlag.getName()),
Placeholder.miniMessage("flag_value", e.getValue()),
Placeholder.miniMessage("error", e.getErrorMessage().getComponent(player))
);
return;
}
plot.setFlag(parsed);
player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(args[0])),
Template.of("value", String.valueOf(parsed))
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_added"), Placeholder.miniMessage("flag", String.valueOf(args[0])),
Placeholder.miniMessage("value", String.valueOf(parsed))
);
}
@ -383,8 +384,8 @@ public final class FlagCommand extends Command {
}
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot flag add <flag> <values>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot flag add <flag> <values>")
);
return;
}
@ -396,8 +397,8 @@ public final class FlagCommand extends Command {
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Flag add")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Flag add")
);
return;
}
@ -417,21 +418,21 @@ public final class FlagCommand extends Command {
parsed = event.getFlag().parse(value);
} catch (FlagParseException e) {
player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"),
Template.of("flag_name", plotFlag.getName()),
Template.of("flag_value", e.getValue()),
Template.of("error", e.getErrorMessage().getComponent(player))
TranslatableCaption.miniMessage("flag.flag_parse_error"),
Placeholder.miniMessage("flag_name", plotFlag.getName()),
Placeholder.miniMessage("flag_value", e.getValue()),
Placeholder.miniMessage("error", e.getErrorMessage().getComponent(player))
);
return;
}
boolean result =
player.getLocation().getPlotAbs().setFlag(localFlag.merge(parsed.getValue()));
if (!result) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_added"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_added"));
return;
}
player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(args[0])),
Template.of("value", String.valueOf(parsed))
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_added"), Placeholder.miniMessage("flag", String.valueOf(args[0])),
Placeholder.miniMessage("value", String.valueOf(parsed))
);
}
@ -451,8 +452,8 @@ public final class FlagCommand extends Command {
}
if (args.length != 1 && args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot flag remove <flag> [values]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot flag remove <flag> [values]")
);
return;
}
@ -464,8 +465,8 @@ public final class FlagCommand extends Command {
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Flag remove")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Flag remove")
);
return;
}
@ -474,8 +475,8 @@ public final class FlagCommand extends Command {
if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))) {
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_SET_FLAG_KEY.format(args[0].toLowerCase()))
);
return;
}
@ -489,27 +490,27 @@ public final class FlagCommand extends Command {
parsedFlag = listFlag.parse(value);
} catch (final FlagParseException e) {
player.sendMessage(
TranslatableCaption.of("flag.flag_parse_error"),
Template.of("flag_name", flag.getName()),
Template.of("flag_value", e.getValue()),
Template.of("error", String.valueOf(e.getErrorMessage()))
TranslatableCaption.miniMessage("flag.flag_parse_error"),
Placeholder.miniMessage("flag_name", flag.getName()),
Placeholder.miniMessage("flag_value", e.getValue()),
Placeholder.miniMessage("error", String.valueOf(e.getErrorMessage()))
);
return;
}
if (((List<?>) parsedFlag.getValue()).isEmpty()) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return;
}
if (list.removeAll((List) parsedFlag.getValue())) {
if (list.isEmpty()) {
if (plot.removeFlag(flag)) {
player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", args[0]), Template.of(
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_removed"), Placeholder.miniMessage("flag", args[0]), Placeholder.miniMessage(
"value",
String.valueOf(flag)
));
return;
} else {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return;
}
} else {
@ -517,31 +518,31 @@ public final class FlagCommand extends Command {
PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot);
if (addEvent.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Re-addition of " + plotFlag.getName())
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Re-addition of " + plotFlag.getName())
);
return;
}
if (plot.setFlag(addEvent.getFlag())) {
player.sendMessage(TranslatableCaption.of("flag.flag_partially_removed"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_partially_removed"));
return;
} else {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return;
}
}
} else {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return;
}
} else {
boolean result = plot.removeFlag(flag);
if (!result) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_not_removed"));
return;
}
}
player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", args[0]), Template.of(
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_removed"), Placeholder.miniMessage("flag", args[0]), Placeholder.miniMessage(
"value",
String.valueOf(flag)
));
@ -576,20 +577,22 @@ public final class FlagCommand extends Command {
for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
Collections.sort(entry.getValue());
Component category =
MINI_MESSAGE.parse(
TranslatableCaption.of("flag.flag_list_categories").getComponent(player),
Template.of("category", entry.getKey())
MINI_MESSAGE.deserialize(
TranslatableCaption.miniMessage("flag.flag_list_categories").getComponent(player),
PlaceholderResolver.placeholders(Placeholder.miniMessage("category", entry.getKey()))
);
TextComponent.Builder builder = Component.text().append(category);
final Iterator<String> flagIterator = entry.getValue().iterator();
while (flagIterator.hasNext()) {
final String flag = flagIterator.next();
builder.append(MINI_MESSAGE
.parse(
TranslatableCaption.of("flag.flag_list_flag").getComponent(player),
Template.of("command", "/plot flag info " + flag),
Template.of("flag", flag),
Template.of("suffix", flagIterator.hasNext() ? ", " : "")
.deserialize(
TranslatableCaption.miniMessage("flag.flag_list_flag").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("command", "/plot flag info " + flag),
Placeholder.miniMessage("flag", flag),
Placeholder.miniMessage("suffix", flagIterator.hasNext() ? ", " : "")
)
));
}
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build())));
@ -612,41 +615,41 @@ public final class FlagCommand extends Command {
}
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot flag info <flag>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot flag info <flag>")
);
return;
}
final PlotFlag<?, ?> plotFlag = getFlag(player, args[0]);
if (plotFlag != null) {
player.sendMessage(TranslatableCaption.of("flag.flag_info_header"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_header"));
// Flag name
player.sendMessage(TranslatableCaption.of("flag.flag_info_name"), Template.of("flag", plotFlag.getName()));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_name"), Placeholder.miniMessage("flag", plotFlag.getName()));
// Flag category
player.sendMessage(
TranslatableCaption.of("flag.flag_info_category"),
Templates.of(player, "value", plotFlag.getFlagCategory())
TranslatableCaption.miniMessage("flag.flag_info_category"),
Placeholders.miniMessage(player, "value", plotFlag.getFlagCategory())
);
// Flag description
// TODO maybe merge and \n instead?
player.sendMessage(TranslatableCaption.of("flag.flag_info_description"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_description"));
player.sendMessage(plotFlag.getFlagDescription());
// Flag example
player.sendMessage(
TranslatableCaption.of("flag.flag_info_example"),
Template.of("command", "/plot flag set"),
Template.of("flag", plotFlag.getName()),
Template.of("value", plotFlag.getExample())
TranslatableCaption.miniMessage("flag.flag_info_example"),
Placeholder.miniMessage("command", "/plot flag set"),
Placeholder.miniMessage("flag", plotFlag.getName()),
Placeholder.miniMessage("value", plotFlag.getExample())
);
// Default value
final String defaultValue = player.getLocation().getPlotArea().getFlagContainer()
.getFlagErased(plotFlag.getClass()).toString();
player.sendMessage(
TranslatableCaption.of("flag.flag_info_default_value"),
Template.of("value", defaultValue)
TranslatableCaption.miniMessage("flag.flag_info_default_value"),
Placeholder.miniMessage("value", defaultValue)
);
// Footer. Done this way to prevent the duplicate-message-thingy from catching it
player.sendMessage(TranslatableCaption.of("flag.flag_info_footer"));
player.sendMessage(TranslatableCaption.miniMessage("flag.flag_info_footer"));
}
}

View File

@ -40,7 +40,7 @@ import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection;
import java.util.Collections;
@ -70,16 +70,16 @@ public class Grant extends Command {
) throws CommandException {
checkTrue(
args.length >= 1 && args.length <= 2,
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot grant <check | add> [player]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot grant <check | add> [player]")
);
final String arg0 = args[0].toLowerCase();
switch (arg0) {
case "add", "check" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_GRANT.format(arg0))) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_GRANT.format(arg0))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_GRANT.format(arg0))
);
return CompletableFuture.completedFuture(false);
}
@ -88,11 +88,11 @@ public class Grant extends Command {
}
PlayerManager.getUUIDsFromString(args[1], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.size() != 1) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", String.valueOf(uuids))
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", String.valueOf(uuids))
);
} else {
final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0];
@ -102,8 +102,8 @@ public class Grant extends Command {
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
if (args[0].equalsIgnoreCase("check")) {
player.sendMessage(
TranslatableCaption.of("grants.granted_plots"),
Template.of("amount", String.valueOf(access.get().orElse(0)))
TranslatableCaption.miniMessage("grants.granted_plots"),
Placeholder.miniMessage("amount", String.valueOf(access.get().orElse(0)))
);
} else {
access.set(access.get().orElse(0) + 1);
@ -122,8 +122,8 @@ public class Grant extends Command {
granted = Ints.fromByteArray(array);
}
player.sendMessage(
TranslatableCaption.of("grants.granted_plots"),
Template.of("amount", String.valueOf(granted))
TranslatableCaption.miniMessage("grants.granted_plots"),
Placeholder.miniMessage("amount", String.valueOf(granted))
);
} else { // add
int amount;
@ -137,8 +137,8 @@ public class Grant extends Command {
byte[] rawData = Ints.toByteArray(amount);
DBFunc.addPersistentMeta(uuid.getUuid(), key, rawData, replace);
player.sendMessage(
TranslatableCaption.of("grants.added"),
Template.of("grants", String.valueOf(amount))
TranslatableCaption.miniMessage("grants.added"),
Placeholder.miniMessage("grants", String.valueOf(amount))
);
}
}

View File

@ -35,7 +35,8 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import java.util.Collection;
import java.util.Locale;
@ -117,25 +118,29 @@ public class Help extends Command {
}
if (cat == null && page == 0) {
TextComponent.Builder builder = Component.text();
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_header").getComponent(player)));
builder.append(MINI_MESSAGE.parse(TranslatableCaption.miniMessage("help.help_header").getComponent(player)));
for (CommandCategory c : CommandCategory.values()) {
builder.append(Component.newline()).append(MINI_MESSAGE
.parse(
TranslatableCaption.of("help.help_info_item").getComponent(player),
Template.of("command", "/plot help"),
Template.of("category", c.name().toLowerCase()),
Template.of("category_desc", c.getComponent(player))
.deserialize(
TranslatableCaption.miniMessage("help.help_info_item").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("command", "/plot help"),
Placeholder.miniMessage("category", c.name().toLowerCase()),
Placeholder.miniMessage("category_desc", c.getComponent(player))
)
));
}
builder.append(Component.newline()).append(MINI_MESSAGE
.parse(
TranslatableCaption.of("help.help_info_item").getComponent(player),
Template.of("command", "/plot help"),
Template.of("category", "all"),
Template.of("category_desc", "Display all commands")
.deserialize(
TranslatableCaption.miniMessage("help.help_info_item").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("command", "/plot help"),
Placeholder.miniMessage("category", "all"),
Placeholder.miniMessage("category_desc", "Display all commands")
)
));
builder.append(Component.newline()).append(MINI_MESSAGE.parse(TranslatableCaption
.of("help.help_footer")
.miniMessage("help.help_footer")
.getComponent(player)));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.asComponent())));
return true;

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@ -74,13 +74,13 @@ public class HomeCommand extends Command {
) {
List<Plot> plots = query.asList();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return;
} else if (plots.size() < page || page < 1) {
player.sendMessage(
TranslatableCaption.of("invalid.number_not_in_range"),
Template.of("min", "1"),
Template.of("max", String.valueOf(plots.size()))
TranslatableCaption.miniMessage("invalid.number_not_in_range"),
Placeholder.miniMessage("min", "1"),
Placeholder.miniMessage("max", String.valueOf(plots.size()))
);
return;
}
@ -114,8 +114,8 @@ public class HomeCommand extends Command {
if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OWNED) && !Permissions
.hasPermission(player, Permission.PERMISSION_HOME)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_VISIT_OWNED.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_VISIT_OWNED.toString())
);
return CompletableFuture.completedFuture(false);
}
@ -136,8 +136,8 @@ public class HomeCommand extends Command {
page = Integer.parseInt(identifier);
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"),
Template.of("value", identifier)
TranslatableCaption.miniMessage("invalid.not_a_number"),
Placeholder.miniMessage("value", identifier)
);
return CompletableFuture.completedFuture(false);
}
@ -177,8 +177,8 @@ public class HomeCommand extends Command {
page = Integer.parseInt(identifier);
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"),
Template.of("value", identifier)
TranslatableCaption.miniMessage("invalid.not_a_number"),
Placeholder.miniMessage("value", identifier)
);
return CompletableFuture.completedFuture(false);
}

View File

@ -26,8 +26,8 @@
package com.plotsquared.core.command;
import com.google.inject.TypeLiteral;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.MetaDataAccess;
@ -43,7 +43,8 @@ import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import java.util.Collection;
import java.util.Collections;
@ -60,7 +61,7 @@ public class Inbox extends SubCommand {
public void displayComments(PlotPlayer<?> player, List<PlotComment> oldComments, int page) {
if (oldComments == null || oldComments.isEmpty()) {
player.sendMessage(TranslatableCaption.of("comment.inbox_empty"));
player.sendMessage(TranslatableCaption.miniMessage("comment.inbox_empty"));
return;
}
PlotComment[] comments = oldComments.toArray(new PlotComment[0]);
@ -79,9 +80,11 @@ public class Inbox extends SubCommand {
max = comments.length;
}
TextComponent.Builder builder = Component.text();
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("list.comment_list_header_paged").getComponent(player) + '\n',
Template.of("amount", String.valueOf(comments.length)), Template.of("cur", String.valueOf(page + 1)),
Template.of("max", String.valueOf(totalPages + 1)), Template.of("word", "all")
builder.append(MINI_MESSAGE.deserialize(TranslatableCaption.miniMessage("list.comment_list_header_paged").getComponent(player) + '\n',
PlaceholderResolver.placeholders(
Placeholder.miniMessage("amount", String.valueOf(comments.length)), Placeholder.miniMessage("cur", String.valueOf(page + 1)),
Placeholder.miniMessage("max", String.valueOf(totalPages + 1)), Placeholder.miniMessage("word", "all")
)
));
// This might work xD
@ -90,31 +93,34 @@ public class Inbox extends SubCommand {
Component commentColored;
if (player.getName().equals(comment.senderName)) {
commentColored = MINI_MESSAGE
.parse(
TranslatableCaption.of("list.comment_list_by_lister").getComponent(player),
Template.of("comment", comment.comment)
);
.deserialize(
TranslatableCaption.miniMessage("list.comment_list_by_lister").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("comment", comment.comment)
));
} else {
commentColored = MINI_MESSAGE
.parse(
TranslatableCaption.of("list.comment_list_by_other").getComponent(player),
Template.of("comment", comment.comment)
);
.deserialize(
TranslatableCaption.miniMessage("list.comment_list_by_other").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("comment", comment.comment)
));
}
Template number = Template.of("number", String.valueOf(x));
Template world = Template.of("world", comment.world);
Template plot_id = Template.of("plot_id", comment.id.getX() + ";" + comment.id.getY());
Template commenter = Template.of("commenter", comment.senderName);
Template commentTemplate = Template.of("comment", commentColored);
Placeholder<?> number = Placeholder.miniMessage("number", String.valueOf(x));
Placeholder<?> world = Placeholder.miniMessage("world", comment.world);
Placeholder<?> plot_id = Placeholder.miniMessage("plot_id", comment.id.getX() + ";" + comment.id.getY());
Placeholder<?> commenter = Placeholder.miniMessage("commenter", comment.senderName);
Placeholder<?> commentTemplate = Placeholder.miniMessage("comment", commentColored.toString());
builder.append(MINI_MESSAGE
.parse(
TranslatableCaption.of("list.comment_list_comment").getComponent(player),
number,
world,
plot_id,
commenter,
commentTemplate
));
.deserialize(
TranslatableCaption.miniMessage("list.comment_list_comment").getComponent(player),
PlaceholderResolver.placeholders(
number,
world,
plot_id,
commenter,
commentTemplate
)));
}
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.build())));
}
@ -123,11 +129,11 @@ public class Inbox extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (args.length == 0) {
@ -149,21 +155,21 @@ public class Inbox extends SubCommand {
}
if (total != 0) {
player.sendMessage(
TranslatableCaption.of("comment.inbox_item"),
Template.of("value", inbox + " (" + total + '/' + unread + ')')
TranslatableCaption.miniMessage("comment.inbox_item"),
Placeholder.miniMessage("value", inbox + " (" + total + '/' + unread + ')')
);
return;
}
}
player.sendMessage(
TranslatableCaption.of("comment.inbox_item"),
Template.of("value", inbox.toString())
TranslatableCaption.miniMessage("comment.inbox_item"),
Placeholder.miniMessage("value", inbox.toString())
);
}
})) {
player.sendMessage(
TranslatableCaption.of("comment.inbox_item"),
Template.of("value", inbox.toString())
TranslatableCaption.miniMessage("comment.inbox_item"),
Placeholder.miniMessage("value", inbox.toString())
);
}
}
@ -173,8 +179,8 @@ public class Inbox extends SubCommand {
final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
if (inbox == null) {
player.sendMessage(
TranslatableCaption.of("comment.invalid_inbox"),
Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), ", "))
TranslatableCaption.miniMessage("comment.invalid_inbox"),
Placeholder.miniMessage("list", StringMan.join(CommentManager.inboxes.keySet(), ", "))
);
return false;
}
@ -191,13 +197,13 @@ public class Inbox extends SubCommand {
switch (args[1].toLowerCase()) {
case "delete":
if (!inbox.canModify(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify"));
player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox_modify"));
return false;
}
if (args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot inbox " + inbox + " delete <index>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot inbox " + inbox + " delete <index>")
);
return true;
}
@ -206,15 +212,15 @@ public class Inbox extends SubCommand {
index = Integer.parseInt(args[2]);
if (index < 1) {
player.sendMessage(
TranslatableCaption.of("comment.not_valid_inbox_index"),
Templates.of("number", index)
TranslatableCaption.miniMessage("comment.not_valid_inbox_index"),
Placeholders.miniMessage("number", index)
);
return false;
}
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot inbox " + inbox + " delete <index>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot inbox " + inbox + " delete <index>")
);
return false;
}
@ -224,8 +230,8 @@ public class Inbox extends SubCommand {
public void run(List<PlotComment> value) {
if (index > value.size()) {
player.sendMessage(
TranslatableCaption.of("comment.not_valid_inbox_index"),
Templates.of("number", index)
TranslatableCaption.miniMessage("comment.not_valid_inbox_index"),
Placeholders.miniMessage("number", index)
);
return;
}
@ -234,29 +240,29 @@ public class Inbox extends SubCommand {
boolean success = plot.getPlotCommentContainer().removeComment(comment);
if (success) {
player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"),
Template.of("value", comment.comment)
TranslatableCaption.miniMessage("comment.comment_removed_success"),
Placeholder.miniMessage("value", comment.comment)
);
} else {
player.sendMessage(
TranslatableCaption.of("comment.comment_removed_failure"));
TranslatableCaption.miniMessage("comment.comment_removed_failure"));
}
}
})) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
return true;
case "clear":
if (!inbox.canModify(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox_modify"));
player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox_modify"));
}
inbox.clearInbox(plot);
List<PlotComment> comments = plot.getPlotCommentContainer().getComments(inbox.toString());
if (!comments.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("comment.comment_removed_success"),
Template.of("value", String.valueOf(comments))
TranslatableCaption.miniMessage("comment.comment_removed_success"),
Placeholder.miniMessage("value", String.valueOf(comments))
);
plot.getPlotCommentContainer().removeComments(comments);
}
@ -273,7 +279,7 @@ public class Inbox extends SubCommand {
page = 1;
}
if (!inbox.canRead(plot, player)) {
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox"));
player.sendMessage(TranslatableCaption.miniMessage("comment.no_perm_inbox"));
return false;
}
if (!inbox.getComments(plot, new RunnableVal<>() {
@ -282,7 +288,7 @@ public class Inbox extends SubCommand {
displayComments(player, value, page);
}
})) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
return true;

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.HideInfoFlag;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection;
import java.util.Collections;
@ -76,7 +76,7 @@ public class Info extends SubCommand {
plot = player.getCurrentPlot();
}
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
@ -96,8 +96,8 @@ public class Info extends SubCommand {
if (!player
.hasPermission(Permission.PERMISSION_AREA_INFO_FORCE.toString())) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_AREA_INFO_FORCE.toString())
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_AREA_INFO_FORCE.toString())
);
return true;
}
@ -106,7 +106,7 @@ public class Info extends SubCommand {
}
}
if (!allowed) {
player.sendMessage(TranslatableCaption.of("info.plot_info_hidden"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_info_hidden"));
return true;
}
}
@ -118,12 +118,12 @@ public class Info extends SubCommand {
// Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) {
player.sendMessage(
TranslatableCaption.of("info.plot_info_unclaimed"),
Template.of("plot", plot.getId().getX() + ";" + plot.getId().getY())
TranslatableCaption.miniMessage("info.plot_info_unclaimed"),
Placeholder.miniMessage("plot", plot.getId().getX() + ";" + plot.getId().getY())
);
return true;
}
Caption info = TranslatableCaption.of("info.plot_info_format");
Caption info = TranslatableCaption.miniMessage("info.plot_info_format");
boolean full;
if (arg != null) {
info = getCaption(arg);
@ -169,19 +169,19 @@ public class Info extends SubCommand {
private Caption getCaption(String string) {
return switch (string) {
case "trusted" -> TranslatableCaption.of("info.plot_info_trusted");
case "alias" -> TranslatableCaption.of("info.plot_info_alias");
case "biome" -> TranslatableCaption.of("info.plot_info_biome");
case "denied" -> TranslatableCaption.of("info.plot_info_denied");
case "flags" -> TranslatableCaption.of("info.plot_info_flags");
case "id" -> TranslatableCaption.of("info.plot_info_id");
case "size" -> TranslatableCaption.of("info.plot_info_size");
case "members" -> TranslatableCaption.of("info.plot_info_members");
case "owner" -> TranslatableCaption.of("info.plot_info_owner");
case "rating" -> TranslatableCaption.of("info.plot_info_rating");
case "likes" -> TranslatableCaption.of("info.plot_info_likes");
case "seen" -> TranslatableCaption.of("info.plot_info_seen");
case "creationdate" -> TranslatableCaption.of("info.plot_info_creationdate");
case "trusted" -> TranslatableCaption.miniMessage("info.plot_info_trusted");
case "alias" -> TranslatableCaption.miniMessage("info.plot_info_alias");
case "biome" -> TranslatableCaption.miniMessage("info.plot_info_biome");
case "denied" -> TranslatableCaption.miniMessage("info.plot_info_denied");
case "flags" -> TranslatableCaption.miniMessage("info.plot_info_flags");
case "id" -> TranslatableCaption.miniMessage("info.plot_info_id");
case "size" -> TranslatableCaption.miniMessage("info.plot_info_size");
case "members" -> TranslatableCaption.miniMessage("info.plot_info_members");
case "owner" -> TranslatableCaption.miniMessage("info.plot_info_owner");
case "rating" -> TranslatableCaption.miniMessage("info.plot_info_rating");
case "likes" -> TranslatableCaption.miniMessage("info.plot_info_likes");
case "seen" -> TranslatableCaption.miniMessage("info.plot_info_seen");
case "creationdate" -> TranslatableCaption.miniMessage("info.plot_info_creationdate");
default -> null;
};
}

View File

@ -38,7 +38,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -74,22 +74,22 @@ public class Kick extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_KICK)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
} else {
Set<PlotPlayer<?>> players = new HashSet<>();
@ -112,28 +112,28 @@ public class Kick extends SubCommand {
players.remove(player); // Don't ever kick the calling player
if (players.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
return;
}
for (PlotPlayer<?> player2 : players) {
if (!plot.equals(player2.getCurrentPlot())) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
return;
}
if (Permissions.hasPermission(player2, Permission.PERMISSION_ADMIN_ENTRY_DENIED)) {
player.sendMessage(
TranslatableCaption.of("cluster.cannot_kick_player"),
Template.of("name", player2.getName())
TranslatableCaption.miniMessage("cluster.cannot_kick_player"),
Placeholder.miniMessage("name", player2.getName())
);
return;
}
Location spawn = this.worldUtil.getSpawn(location.getWorldName());
player2.sendMessage(TranslatableCaption.of("kick.you_got_kicked"));
player2.sendMessage(TranslatableCaption.miniMessage("kick.you_got_kicked"));
if (plot.equals(spawn.getPlot())) {
Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
if (plot.equals(newSpawn.getPlot())) {

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
@ -59,10 +59,10 @@ public class Leave extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone
) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned"));
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
if (plot.isOwner(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("member.plot_cant_leave_owner"));
player.sendMessage(TranslatableCaption.miniMessage("member.plot_cant_leave_owner"));
} else {
UUID uuid = player.getUUID();
if (plot.isAdded(uuid)) {
@ -73,12 +73,12 @@ public class Leave extends Command {
this.eventDispatcher.callMember(player, plot, uuid, false);
}
player.sendMessage(
TranslatableCaption.of("member.plot_left"),
Template.of("player", player.getName())
TranslatableCaption.miniMessage("member.plot_left"),
Placeholder.miniMessage("player", player.getName())
);
} else {
player.sendMessage(
TranslatableCaption.of("members.not_added_trusted")
TranslatableCaption.miniMessage("members.not_added_trusted")
);
}
}

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -115,17 +115,17 @@ public class Like extends SubCommand {
.isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
plot.teleportPlayer(player, TeleportCause.COMMAND_LIKE, result -> {
});
player.sendMessage(TranslatableCaption.of("tutorial.rate_this"));
player.sendMessage(TranslatableCaption.miniMessage("tutorial.rate_this"));
return true;
}
}
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return true;
}
case "purge" -> {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!Permissions
@ -133,34 +133,34 @@ public class Like extends SubCommand {
return false;
}
plot.clearRatings();
player.sendMessage(TranslatableCaption.of("ratings.ratings_purged"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.ratings_purged"));
return true;
}
}
}
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_owned"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_owned"));
return false;
}
if (plot.isOwner(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_your_own"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_your_own"));
return false;
}
if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_done"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_done"));
return false;
}
final Runnable run = () -> {
final Boolean oldRating = plot.getLikes().get(uuid);
if (oldRating != null) {
player.sendMessage(
TranslatableCaption.of("ratings.rating_already_exists"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_already_exists"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
return;
}
@ -177,13 +177,13 @@ public class Like extends SubCommand {
plot.addRating(uuid, event.getRating());
if (like) {
player.sendMessage(
TranslatableCaption.of("ratings.rating_liked"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_liked"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("ratings.rating_disliked"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_disliked"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
}
}

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
@ -53,7 +53,8 @@ import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@ -129,8 +130,8 @@ public class ListCmd extends SubCommand {
public void noArgs(PlotPlayer<?> player) {
player.sendMessage(
TranslatableCaption.of("commandconfig.subcommand_set_options_header"),
Templates.of("values", Arrays.toString(getArgumentList(player)))
TranslatableCaption.miniMessage("commandconfig.subcommand_set_options_header"),
Placeholders.miniMessage("values", Arrays.toString(getArgumentList(player)))
);
}
@ -165,8 +166,8 @@ public class ListCmd extends SubCommand {
final Consumer<PlotQuery> plotConsumer = query -> {
if (query == null) {
player.sendMessage(
TranslatableCaption.of("commandconfig.did_you_mean"),
Template.of(
TranslatableCaption.miniMessage("commandconfig.did_you_mean"),
Placeholder.miniMessage(
"value",
new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch()
)
@ -185,7 +186,7 @@ public class ListCmd extends SubCommand {
final List<Plot> plots = query.asList();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return;
}
displayPlots(player, plots, 12, page, args);
@ -195,8 +196,8 @@ public class ListCmd extends SubCommand {
case "mine" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.mine")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.mine")
);
return false;
}
@ -210,8 +211,8 @@ public class ListCmd extends SubCommand {
case "shared" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.shared")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.shared")
);
return false;
}
@ -223,15 +224,15 @@ public class ListCmd extends SubCommand {
case "world" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.world")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.world")
);
return false;
}
if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.world." + world)
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.world." + world)
);
return false;
}
@ -240,8 +241,8 @@ public class ListCmd extends SubCommand {
case "expired" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.expired")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.expired")
);
return false;
}
@ -254,15 +255,15 @@ public class ListCmd extends SubCommand {
case "area" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.area")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.area")
);
return false;
}
if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.world." + world)
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.world." + world)
);
return false;
}
@ -275,8 +276,8 @@ public class ListCmd extends SubCommand {
case "all" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.all")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.all")
);
return false;
}
@ -285,8 +286,8 @@ public class ListCmd extends SubCommand {
case "done" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.done")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.done")
);
return false;
}
@ -300,8 +301,8 @@ public class ListCmd extends SubCommand {
case "top" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.top")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.top")
);
return false;
}
@ -311,8 +312,8 @@ public class ListCmd extends SubCommand {
case "forsale" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.forsale")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.forsale")
);
return false;
}
@ -324,8 +325,8 @@ public class ListCmd extends SubCommand {
case "unowned" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.unowned")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.unowned")
);
return false;
}
@ -334,15 +335,15 @@ public class ListCmd extends SubCommand {
case "fuzzy" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.fuzzy")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.fuzzy")
);
return false;
}
if (args.length < (page == -1 ? 2 : 3)) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", "/plot list fuzzy <search...> [#]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", "/plot list fuzzy <search...> [#]")
);
return false;
}
@ -359,15 +360,15 @@ public class ListCmd extends SubCommand {
if (this.plotAreaManager.hasPlotArea(args[0])) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.world")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.world")
);
return false;
}
if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.world." + args[0])
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.world." + args[0])
);
return false;
}
@ -376,7 +377,7 @@ public class ListCmd extends SubCommand {
}
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null) {
if (uuid == null) {
try {
@ -386,12 +387,12 @@ public class ListCmd extends SubCommand {
}
}
if (uuid == null) {
player.sendMessage(TranslatableCaption.of("errors.invalid_player"), Templates.of("value", args[0]));
player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_player"), Placeholders.miniMessage("value", args[0]));
} else {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.player")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.list.player")
);
} else {
sort[0] = false;
@ -416,28 +417,30 @@ public class ListCmd extends SubCommand {
public void run(Integer i, Plot plot, CaptionHolder caption) {
Caption color;
if (plot.getOwner() == null) {
color = TranslatableCaption.of("info.plot_list_no_owner");
color = TranslatableCaption.miniMessage("info.plot_list_no_owner");
} else if (plot.isOwner(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_owned_by");
color = TranslatableCaption.miniMessage("info.plot_list_owned_by");
} else if (plot.isAdded(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_added_to");
color = TranslatableCaption.miniMessage("info.plot_list_added_to");
} else if (plot.isDenied(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_denied_on");
color = TranslatableCaption.miniMessage("info.plot_list_denied_on");
} else {
color = TranslatableCaption.of("info.plot_list_default");
color = TranslatableCaption.miniMessage("info.plot_list_default");
}
Component trusted = MINI_MESSAGE.parse(
TranslatableCaption.of("info.plot_info_trusted").getComponent(player),
Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted(), player))
Component trusted = MINI_MESSAGE.deserialize(
TranslatableCaption.miniMessage("info.plot_info_trusted").getComponent(player),
PlaceholderResolver.placeholders(Placeholder.miniMessage("trusted",
PlayerManager.getPlayerList(plot.getTrusted(), player).toString()))
);
Component members = MINI_MESSAGE.parse(
TranslatableCaption.of("info.plot_info_members").getComponent(player),
Template.of("members", PlayerManager.getPlayerList(plot.getMembers(), player))
Component members = MINI_MESSAGE.deserialize(
TranslatableCaption.miniMessage("info.plot_info_members").getComponent(player),
PlaceholderResolver.placeholders(Placeholder.miniMessage("trusted",
PlayerManager.getPlayerList(plot.getTrusted(), player).toString()))
);
Template command_tp = Template.of("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId());
Template command_info = Template.of("command_info", "/plot info " + plot.getArea() + ";" + plot.getId());
Template hover_info =
Template.of(
Placeholder<?> command_tp = Placeholder.miniMessage("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId());
Placeholder<?> command_info = Placeholder.miniMessage("command_info", "/plot info " + plot.getArea() + ";" + plot.getId());
Placeholder<?> hover_info =
Placeholder.miniMessage(
"hover_info",
MINI_MESSAGE.serialize(Component
.text()
@ -446,27 +449,28 @@ public class ListCmd extends SubCommand {
.append(members)
.asComponent())
);
Template numberTemplate = Template.of("number", String.valueOf(i));
Template plotTemplate = Template.of(
Placeholder<?> numberTemplate = Placeholder.miniMessage("number", String.valueOf(i));
Placeholder<?> plotTemplate = Placeholder.miniMessage(
"plot",
MINI_MESSAGE.parse(color.getComponent(player), Template.of("plot", plot.toString()))
MINI_MESSAGE.deserialize(color.getComponent(player),
PlaceholderResolver.placeholders(Placeholder.miniMessage("plot", plot.toString()))).toString()
);
String prefix = "";
String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player);
String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player);
String online = TranslatableCaption.miniMessage("info.plot_list_player_online").getComponent(player);
String offline = TranslatableCaption.miniMessage("info.plot_list_player_offline").getComponent(player);
TextComponent.Builder builder = Component.text();
try {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid());
Template prefixTemplate = Template.of("prefix", prefix);
Template playerTemplate = Template.of("player", uuidMapping.getUsername());
Placeholder<?> prefixTemplate = Placeholder.miniMessage("prefix", prefix);
Placeholder<?> playerTemplate = Placeholder.miniMessage("player", uuidMapping.getUsername());
if (pp != null) {
builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate));
builder.append(MINI_MESSAGE.deserialize(online, PlaceholderResolver.placeholders(prefixTemplate, playerTemplate)));
} else {
builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate));
builder.append(MINI_MESSAGE.deserialize(offline, PlaceholderResolver.placeholders(prefixTemplate, playerTemplate)));
}
prefix = ", ";
}
@ -481,17 +485,17 @@ public class ListCmd extends SubCommand {
}
}
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Templates.of("value", playerBuilder.toString())
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholders.miniMessage("value", playerBuilder.toString())
);
} catch (TimeoutException e) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
}
Template players = Template.of("players", builder.asComponent());
caption.set(TranslatableCaption.of("info.plot_list_item"));
caption.setTemplates(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players);
Placeholder<?> players = Placeholder.miniMessage("players", builder.asComponent().toString());
caption.set(TranslatableCaption.miniMessage("info.plot_list_item"));
caption.setPlaceholders(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players);
}
}, "/plot list " + args[0], TranslatableCaption.of("list.plot_list_header_paged"));
}, "/plot list " + args[0], TranslatableCaption.miniMessage("list.plot_list_header_paged"));
}
@Override

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.MalformedURLException;
@ -74,25 +74,25 @@ public class Load extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
final String world = player.getLocation().getWorldName();
if (!this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_LOAD)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
@ -104,8 +104,8 @@ public class Load extends SubCommand {
if (schematics == null) {
// No schematics found:
player.sendMessage(
TranslatableCaption.of("web.load_null"),
Template.of("command", "/plot load")
TranslatableCaption.miniMessage("web.load_null"),
Placeholder.miniMessage("command", "/plot load")
);
return false;
}
@ -115,8 +115,8 @@ public class Load extends SubCommand {
} catch (Exception ignored) {
// use /plot load <index>
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"),
Template.of("value", "(1, " + schematics.size() + ')')
TranslatableCaption.miniMessage("invalid.not_valid_number"),
Placeholder.miniMessage("value", "(1, " + schematics.size() + ')')
);
return false;
}
@ -125,18 +125,18 @@ public class Load extends SubCommand {
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic);
} catch (MalformedURLException e) {
e.printStackTrace();
player.sendMessage(TranslatableCaption.of("web.load_failed"));
player.sendMessage(TranslatableCaption.miniMessage("web.load_failed"));
return false;
}
plot.addRunning();
player.sendMessage(TranslatableCaption.of("working.generating_component"));
player.sendMessage(TranslatableCaption.miniMessage("working.generating_component"));
TaskManager.runTaskAsync(() -> {
Schematic taskSchematic = this.schematicHandler.getSchematic(url);
if (taskSchematic == null) {
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid"),
Template.of("reason", "non-existent or not in gzip format")
TranslatableCaption.miniMessage("schematics.schematic_invalid"),
Placeholder.miniMessage("reason", "non-existent or not in gzip format")
);
return;
}
@ -154,9 +154,9 @@ public class Load extends SubCommand {
public void run(Boolean value) {
plot.removeRunning();
if (value) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_success"));
} else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_failed"));
}
}
}
@ -166,8 +166,8 @@ public class Load extends SubCommand {
}
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot load <index>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot load <index>")
);
return false;
}
@ -181,7 +181,7 @@ public class Load extends SubCommand {
List<String> schematics1 = this.schematicHandler.getSaves(player.getUUID());
plot.removeRunning();
if ((schematics1 == null) || schematics1.isEmpty()) {
player.sendMessage(TranslatableCaption.of("web.load_failed"));
player.sendMessage(TranslatableCaption.miniMessage("web.load_failed"));
return;
}
metaDataAccess.set(schematics1);
@ -217,8 +217,8 @@ public class Load extends SubCommand {
}
}
player.sendMessage(
TranslatableCaption.of("web.load_list"),
Template.of("command", "/plot load #")
TranslatableCaption.miniMessage("web.load_list"),
Placeholder.miniMessage("command", "/plot load #")
);
}
}

View File

@ -43,6 +43,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -274,7 +275,7 @@ public class MainCommand extends Command {
}
tp = true;
} else {
player.sendMessage(TranslatableCaption.of("border.denied"));
player.sendMessage(TranslatableCaption.miniMessage("border.denied"));
}
// Trim command
args = Arrays.copyOfRange(args, 1, args.length);
@ -303,7 +304,7 @@ public class MainCommand extends Command {
};
args = Arrays.copyOfRange(args, 1, args.length);
} else {
player.sendMessage(TranslatableCaption.of("errors.invalid_command_flag"));
player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_command_flag"));
return CompletableFuture.completedFuture(false);
}
}
@ -317,12 +318,12 @@ public class MainCommand extends Command {
String message = e.getMessage();
if (message != null) {
player.sendMessage(
TranslatableCaption.of("errors.error"),
net.kyori.adventure.text.minimessage.Template.of("value", message)
TranslatableCaption.miniMessage("errors.error"),
Placeholder.miniMessage("value", message)
);
} else {
player.sendMessage(
TranslatableCaption.of("errors.error_console"));
TranslatableCaption.miniMessage("errors.error_console"));
}
}
// Reset command scope //

View File

@ -42,7 +42,8 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlotExpression;
import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
@ -88,15 +89,15 @@ public class Merge extends SubCommand {
Location location = player.getLocationFull();
final Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
Direction direction = null;
@ -121,12 +122,12 @@ public class Merge extends SubCommand {
}
if (direction == null) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]")
);
player.sendMessage(
TranslatableCaption.of("help.direction"),
Template.of("dir", direction(location.getYaw()))
TranslatableCaption.miniMessage("help.direction"),
Placeholder.miniMessage("dir", direction(location.getYaw()))
);
return false;
}
@ -136,8 +137,8 @@ public class Merge extends SubCommand {
this.eventDispatcher.callMerge(plot, direction, max, player);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Merge")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Merge")
);
return false;
}
@ -147,8 +148,8 @@ public class Merge extends SubCommand {
if (!force && size - 1 > maxSize) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_MERGE + "." + (size + 1))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_MERGE + "." + (size + 1))
);
return false;
}
@ -160,7 +161,7 @@ public class Merge extends SubCommand {
if (!force && !plot.isOwner(uuid)) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_MERGE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
} else {
uuid = plot.getOwnerAbs();
@ -174,8 +175,8 @@ public class Merge extends SubCommand {
if (!force && !terrain && !Permissions
.hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD))
);
return true;
}
@ -183,23 +184,23 @@ public class Merge extends SubCommand {
if (this.econHandler.isEnabled(plotArea) && price > 0d) {
this.econHandler.withdrawMoney(player, price);
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(price)),
Template.of("balance", this.econHandler.format(this.econHandler.getMoney(player)))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", this.econHandler.format(price)),
Placeholder.miniMessage("balance", this.econHandler.format(this.econHandler.getMoney(player)))
);
}
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
player.sendMessage(TranslatableCaption.miniMessage("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
return true;
}
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
player.sendMessage(TranslatableCaption.miniMessage("merge.no_available_automerge"));
return false;
}
if (!force && this.econHandler.isEnabled(plotArea) && price > 0d
&& this.econHandler.getMoney(player) < price) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"),
Template.of("money", this.econHandler.format(price))
TranslatableCaption.miniMessage("economy.cannot_afford_merge"),
Placeholder.miniMessage("money", this.econHandler.format(price))
);
return false;
}
@ -212,8 +213,8 @@ public class Merge extends SubCommand {
if (!force && !terrain && !Permissions
.hasPermission(player, Permission.PERMISSION_MERGE_KEEP_ROAD)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_MERGE_KEEP_ROAD))
);
return true;
}
@ -221,24 +222,24 @@ public class Merge extends SubCommand {
if (this.econHandler.isEnabled(plotArea) && price > 0d) {
this.econHandler.withdrawMoney(player, price);
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(price))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", this.econHandler.format(price))
);
}
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
player.sendMessage(TranslatableCaption.miniMessage("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
return true;
}
Plot adjacent = plot.getRelative(direction);
if (adjacent == null || !adjacent.hasOwner() || adjacent
.isMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) {
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
player.sendMessage(TranslatableCaption.miniMessage("merge.no_available_automerge"));
return false;
}
if (!force && !Permissions.hasPermission(player, Permission.PERMISSION_MERGE_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_MERGE_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_MERGE_OTHER))
);
return false;
}
@ -252,36 +253,38 @@ public class Merge extends SubCommand {
isOnline = true;
final Direction dir = direction;
Runnable run = () -> {
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
accepter.sendMessage(TranslatableCaption.miniMessage("merge.merge_accepted"));
plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain);
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
if (plotPlayer == null) {
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
accepter.sendMessage(TranslatableCaption.miniMessage("merge.merge_not_valid"));
return;
}
if (this.econHandler.isEnabled(plotArea) && price > 0d) {
if (!force && this.econHandler.getMoney(player) < price) {
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_merge"),
Template.of("money", this.econHandler.format(price))
TranslatableCaption.miniMessage("economy.cannot_afford_merge"),
Placeholder.miniMessage("money", this.econHandler.format(price))
);
return;
}
this.econHandler.withdrawMoney(player, price);
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", this.econHandler.format(price))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", this.econHandler.format(price))
);
}
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
player.sendMessage(TranslatableCaption.miniMessage("merge.success_merge"));
eventDispatcher.callPostMerge(player, plot);
};
if (!force && hasConfirmation(player)) {
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(
TranslatableCaption.of("merge.merge_request_confirm").getComponent(player),
Template.of("player", player.getName()),
Template.of("location", plot.getWorldName() + ";" + plot.getId())
.deserialize(
TranslatableCaption.miniMessage("merge.merge_request_confirm").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("player", player.getName()),
Placeholder.miniMessage("location", plot.getWorldName() + ";" + plot.getId())
)
)),
run
);
@ -290,10 +293,10 @@ public class Merge extends SubCommand {
}
}
if (!force && !isOnline) {
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
player.sendMessage(TranslatableCaption.miniMessage("merge.no_available_automerge"));
return false;
}
player.sendMessage(TranslatableCaption.of("merge.merge_requested"));
player.sendMessage(TranslatableCaption.miniMessage("merge.merge_requested"));
return true;
}

View File

@ -46,11 +46,11 @@ public class Middle extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND_MIDDLE));
player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot"));
player.sendMessage(TranslatableCaption.miniMessage("teleport.teleported_to_plot"));
return true;
}

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.concurrent.CompletableFuture;
@ -64,12 +64,12 @@ public class Move extends SubCommand {
Location location = player.getLocation();
Plot plot1 = location.getPlotAbs();
if (plot1 == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return CompletableFuture.completedFuture(false);
}
if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return CompletableFuture.completedFuture(false);
}
boolean override = false;
@ -92,16 +92,16 @@ public class Move extends SubCommand {
plot2 = area.getPlotAbs(plot1.getId());
}
if (plot1.equals(plot2)) {
player.sendMessage(TranslatableCaption.of("invalid.origin_cant_be_target"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.origin_cant_be_target"));
return CompletableFuture.completedFuture(false);
}
if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN))) {
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible"));
player.sendMessage(TranslatableCaption.miniMessage("errors.plotworld_incompatible"));
return CompletableFuture.completedFuture(false);
}
if (plot1.isMerged() || plot2.isMerged()) {
player.sendMessage(TranslatableCaption.of("move.move_merged"));
player.sendMessage(TranslatableCaption.miniMessage("move.move_merged"));
return CompletableFuture.completedFuture(false);
}
@ -109,13 +109,13 @@ public class Move extends SubCommand {
}, false).thenApply(result -> {
if (result) {
player.sendMessage(
TranslatableCaption.of("move.move_success"),
Template.of("origin", plot1.toString()),
Template.of("target", plot2.toString())
TranslatableCaption.miniMessage("move.move_success"),
Placeholder.miniMessage("origin", plot1.toString()),
Placeholder.miniMessage("target", plot2.toString())
);
return true;
} else {
player.sendMessage(TranslatableCaption.of("move.requires_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("move.requires_unowned"));
return false;
}
});

View File

@ -41,7 +41,7 @@ import com.plotsquared.core.plot.flag.implementations.MusicFlag;
import com.plotsquared.core.util.InventoryUtil;
import com.plotsquared.core.util.Permissions;
import com.sk89q.worldedit.world.item.ItemTypes;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import javax.annotation.Nullable;
import java.util.Arrays;
@ -73,14 +73,14 @@ public class Music extends SubCommand {
Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.isAdded(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_MUSIC_OTHER)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_MUSIC_OTHER))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_ADMIN_MUSIC_OTHER))
);
return true;
}
@ -88,7 +88,7 @@ public class Music extends SubCommand {
this.inventoryUtil,
player,
2,
TranslatableCaption.of("plotjukebox.jukebox_header").getComponent(player)
TranslatableCaption.miniMessage("plotjukebox.jukebox_header").getComponent(player)
) {
@Override
public boolean onClick(int index) {
@ -102,16 +102,16 @@ public class Music extends SubCommand {
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
getPlayer().sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Music removal")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Music removal")
);
return true;
}
plot.removeFlag(event.getFlag());
getPlayer().sendMessage(
TranslatableCaption.of("flag.flag_removed"),
Template.of("flag", "music"),
Template.of("value", "music_disc")
TranslatableCaption.miniMessage("flag.flag_removed"),
Placeholder.miniMessage("flag", "music"),
Placeholder.miniMessage("value", "music_disc")
);
} else if (item.getName().toLowerCase(Locale.ENGLISH).contains("disc")) {
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
@ -119,17 +119,17 @@ public class Music extends SubCommand {
PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot);
if (event.getEventResult() == Result.DENY) {
getPlayer().sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Music addition")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Music addition")
);
return true;
}
plot.setFlag(event.getFlag());
getPlayer().sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", "music"),
Template.of("value", String.valueOf(event.getFlag().getValue()))
getPlayer().sendMessage(TranslatableCaption.miniMessage("flag.flag_added"), Placeholder.miniMessage("flag", "music"),
Placeholder.miniMessage("value", String.valueOf(event.getFlag().getValue()))
);
} else {
getPlayer().sendMessage(TranslatableCaption.of("flag.flag_not_added"));
getPlayer().sendMessage(TranslatableCaption.miniMessage("flag.flag_not_added"));
}
return false;
}
@ -138,15 +138,15 @@ public class Music extends SubCommand {
for (final String disc : DISCS) {
final String name = String.format("<gold>%s</gold>", disc);
final String[] lore = {TranslatableCaption.of("plotjukebox.click_to_play").getComponent(player)};
final String[] lore = {TranslatableCaption.miniMessage("plotjukebox.click_to_play").getComponent(player)};
final PlotItemStack item = new PlotItemStack(disc, 1, name, lore);
inv.setItem(index++, item);
}
// Always add the cancel button
// if (player.getMeta("music") != null) {
String name = TranslatableCaption.of("plotjukebox.cancel_music").getComponent(player);
String[] lore = {TranslatableCaption.of("plotjukebox.reset_music").getComponent(player)};
String name = TranslatableCaption.miniMessage("plotjukebox.cancel_music").getComponent(player);
String[] lore = {TranslatableCaption.miniMessage("plotjukebox.reset_music").getComponent(player)};
inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore));
// }

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.concurrent.CompletableFuture;
@ -52,10 +52,10 @@ public class Near extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone
) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.miniMessage("errors.not_in_plot"));
player.sendMessage(
TranslatableCaption.of("near.plot_near"),
Template.of("list", StringMan.join(plot.getPlayersInPlot(), ", "))
TranslatableCaption.miniMessage("near.plot_near"),
Placeholder.miniMessage("list", StringMan.join(plot.getPlayersInPlot(), ", "))
);
return CompletableFuture.completedFuture(true);
}

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@ -72,8 +72,8 @@ public class Owner extends SetCommand {
public boolean set(final PlotPlayer<?> player, final Plot plot, String value) {
if (value == null || value.isEmpty()) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot setowner <owner>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot setowner <owner>")
);
return false;
}
@ -84,8 +84,8 @@ public class Owner extends SetCommand {
if (uuid == null && !value.equalsIgnoreCase("none") && !value.equalsIgnoreCase("null")
&& !value.equalsIgnoreCase("-")) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", value)
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", value)
);
return;
}
@ -98,8 +98,8 @@ public class Owner extends SetCommand {
);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Owner change")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Owner change")
);
return;
}
@ -121,8 +121,8 @@ public class Owner extends SetCommand {
);
if (unlinkEvent.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Unlink on owner change")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Unlink on owner change")
);
return;
}
@ -135,14 +135,14 @@ public class Owner extends SetCommand {
current.getPlotModificationManager().removeSign();
}
eventDispatcher.callPostOwnerChange(player, plot, oldOwner);
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
player.sendMessage(TranslatableCaption.miniMessage("owner.set_owner"));
return;
}
final PlotPlayer<?> other = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (plot.isOwner(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_owner"),
Template.of("player", PlayerManager.getName(uuid, false))
TranslatableCaption.miniMessage("member.already_owner"),
Placeholder.miniMessage("player", PlayerManager.getName(uuid, false))
);
return;
}
@ -150,8 +150,8 @@ public class Owner extends SetCommand {
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
if (other == null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player_offline"),
Template.of("player", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("errors.invalid_player_offline"),
Placeholder.miniMessage("player", PlayerManager.getName(uuid))
);
return;
}
@ -166,7 +166,7 @@ public class Owner extends SetCommand {
grants = metaDataAccess.get().orElse(0);
if (grants <= 0) {
metaDataAccess.remove();
player.sendMessage(TranslatableCaption.of("permission.cant_transfer_more_plots"));
player.sendMessage(TranslatableCaption.miniMessage("permission.cant_transfer_more_plots"));
return;
}
}
@ -182,16 +182,16 @@ public class Owner extends SetCommand {
plot.removeDenied(finalUUID);
}
plot.getPlotModificationManager().setSign(finalName);
player.sendMessage(TranslatableCaption.of("owner.set_owner"));
player.sendMessage(TranslatableCaption.miniMessage("owner.set_owner"));
eventDispatcher.callPostOwnerChange(player, plot, oldOwner);
if (other != null) {
other.sendMessage(
TranslatableCaption.of("owner.now_owner"),
Template.of("plot", plot.getArea() + ";" + plot.getId())
TranslatableCaption.miniMessage("owner.now_owner"),
Placeholder.miniMessage("plot", plot.getArea() + ";" + plot.getId())
);
}
} else {
player.sendMessage(TranslatableCaption.of("owner.set_owner_cancelled"));
player.sendMessage(TranslatableCaption.miniMessage("owner.set_owner_cancelled"));
}
};
if (hasConfirmation(player)) {

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "plugin",
permission = "plots.use",
@ -46,7 +46,7 @@ public class PluginCmd extends SubCommand {
StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared
.platform()
.pluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"),
Template.of("version", String.valueOf(PlotSquared.get().getVersion()))
Placeholder.miniMessage("version", String.valueOf(PlotSquared.get().getVersion()))
);
player.sendMessage(StaticCaption.of(
"<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>"));
@ -56,7 +56,7 @@ public class PluginCmd extends SubCommand {
"<gray>>> </gray><gold><bold>Discord<reset><gray>: </gray><gold><click:open_url:https://discord.gg/intellectualsites>https://discord.gg/intellectualsites</gold>"));
player.sendMessage(
StaticCaption.of("<gray>>> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"),
Template.of("value", String.valueOf(PremiumVerification.isPremium()))
Placeholder.miniMessage("value", String.valueOf(PremiumVerification.isPremium()))
);
});
return true;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -102,8 +102,8 @@ public class Purge extends SubCommand {
area = this.plotAreaManager.getPlotAreaByString(split[1]);
if (area == null) {
player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"),
Template.of("value", split[1])
TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Placeholder.miniMessage("value", split[1])
);
return false;
}
@ -114,8 +114,8 @@ public class Purge extends SubCommand {
id = PlotId.fromString(split[1]);
} catch (IllegalArgumentException ignored) {
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_plot_id"),
Template.of("value", split[1])
TranslatableCaption.miniMessage("invalid.not_valid_plot_id"),
Placeholder.miniMessage("value", split[1])
);
return false;
}
@ -125,8 +125,8 @@ public class Purge extends SubCommand {
UUIDMapping ownerMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]);
if (ownerMapping == null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", split[1])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", split[1])
);
return false;
}
@ -137,8 +137,8 @@ public class Purge extends SubCommand {
UUIDMapping addedMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(split[1]);
if (addedMapping == null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", split[1])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", split[1])
);
return false;
}
@ -198,7 +198,7 @@ public class Purge extends SubCommand {
}
}
if (toDelete.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return false;
}
String cmd =
@ -242,8 +242,8 @@ public class Purge extends SubCommand {
TaskManager.runTask(() -> {
DBFunc.purgeIds(ids);
player.sendMessage(
TranslatableCaption.of("purge.purge_success"),
Template.of("amount", ids.size() + "/" + toDelete.size())
TranslatableCaption.miniMessage("purge.purge_success"),
Placeholder.miniMessage("amount", ids.size() + "/" + toDelete.size())
);
});
}

View File

@ -45,7 +45,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -108,17 +108,17 @@ public class Rate extends SubCommand {
.isAdded(uuid)) {
p.teleportPlayer(player, TeleportCause.COMMAND_RATE, result -> {
});
player.sendMessage(TranslatableCaption.of("tutorial.rate_this"));
player.sendMessage(TranslatableCaption.miniMessage("tutorial.rate_this"));
return true;
}
}
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return false;
}
case "purge" -> {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!Permissions
@ -126,26 +126,26 @@ public class Rate extends SubCommand {
return false;
}
plot.clearRatings();
player.sendMessage(TranslatableCaption.of("ratings.ratings_purged"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.ratings_purged"));
return true;
}
}
}
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_owned"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_owned"));
return false;
}
if (plot.isOwner(player.getUUID())) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_your_own"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_your_own"));
return false;
}
if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_done"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_done"));
return false;
}
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
@ -154,8 +154,8 @@ public class Rate extends SubCommand {
public void run() {
if (plot.getRatings().containsKey(player.getUUID())) {
player.sendMessage(
TranslatableCaption.of("ratings.rating_already_exists"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_already_exists"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
return;
}
@ -174,8 +174,8 @@ public class Rate extends SubCommand {
if (event.getRating() != null) {
plot.addRating(this.getPlayer().getUUID(), event.getRating());
getPlayer().sendMessage(
TranslatableCaption.of("ratings.rating_applied"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_applied"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
}
return false;
@ -185,31 +185,31 @@ public class Rate extends SubCommand {
}
};
inventory.setItem(0, new PlotItemStack(Settings.Ratings.BLOCK_0, 1,
TranslatableCaption.of("ratings.0-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.0-8").getComponent(player)
));
inventory.setItem(1, new PlotItemStack(Settings.Ratings.BLOCK_1, 1,
TranslatableCaption.of("ratings.1-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.1-8").getComponent(player)
));
inventory.setItem(2, new PlotItemStack(Settings.Ratings.BLOCK_2, 2,
TranslatableCaption.of("ratings.2-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.2-8").getComponent(player)
));
inventory.setItem(3, new PlotItemStack(Settings.Ratings.BLOCK_3, 3,
TranslatableCaption.of("ratings.3-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.3-8").getComponent(player)
));
inventory.setItem(4, new PlotItemStack(Settings.Ratings.BLOCK_4, 4,
TranslatableCaption.of("ratings.4-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.4-8").getComponent(player)
));
inventory.setItem(5, new PlotItemStack(Settings.Ratings.BLOCK_5, 5,
TranslatableCaption.of("ratings.5-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.5-8").getComponent(player)
));
inventory.setItem(6, new PlotItemStack(Settings.Ratings.BLOCK_6, 6,
TranslatableCaption.of("ratings.6-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.6-8").getComponent(player)
));
inventory.setItem(7, new PlotItemStack(Settings.Ratings.BLOCK_7, 7,
TranslatableCaption.of("ratings.7-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.7-8").getComponent(player)
));
inventory.setItem(8, new PlotItemStack(Settings.Ratings.BLOCK_8, 8,
TranslatableCaption.of("ratings.8-8").getComponent(player)
TranslatableCaption.miniMessage("ratings.8-8").getComponent(player)
));
inventory.openInventory();
}
@ -228,7 +228,7 @@ public class Rate extends SubCommand {
return true;
}
if (args.length < 1) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_valid"));
return true;
}
String arg = args[0];
@ -236,19 +236,19 @@ public class Rate extends SubCommand {
if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) {
rating = Integer.parseInt(arg);
if (rating > 10 || rating < 1) {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_valid"));
return false;
}
} else {
player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid"));
player.sendMessage(TranslatableCaption.miniMessage("ratings.rating_not_valid"));
return false;
}
final UUID uuid = player.getUUID();
final Runnable run = () -> {
if (plot.getRatings().containsKey(uuid)) {
player.sendMessage(
TranslatableCaption.of("ratings.rating_already_exists"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_already_exists"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
return;
}
@ -257,8 +257,8 @@ public class Rate extends SubCommand {
if (event.getRating() != null) {
plot.addRating(uuid, event.getRating());
player.sendMessage(
TranslatableCaption.of("ratings.rating_applied"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("ratings.rating_applied"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
}
};

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "regenallroads",
@ -64,44 +64,44 @@ public class RegenAllRoads extends SubCommand {
height = Integer.parseInt(args[1]);
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"),
Template.of("value", "(0, 256)")
TranslatableCaption.miniMessage("invalid.not_valid_number"),
Placeholder.miniMessage("value", "(0, 256)")
);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot regenallroads <world> [height]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot regenallroads <world> [height]")
);
return false;
}
} else if (args.length != 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot regenallroads <world> [height]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot regenallroads <world> [height]")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
if (area == null) {
player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Placeholder.miniMessage("value", args[0])
);
return false;
}
String name = args[0];
PlotManager manager = area.getPlotManager();
if (!(manager instanceof HybridPlotManager)) {
player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_plot_world"));
return false;
}
player.sendMessage(
TranslatableCaption.of("debugroadregen.schematic"),
Template.of("command", "/plot createroadschematic")
TranslatableCaption.miniMessage("debugroadregen.schematic"),
Placeholder.miniMessage("command", "/plot createroadschematic")
);
player.sendMessage(TranslatableCaption.of("debugroadregen.regenallroads_started"));
player.sendMessage(TranslatableCaption.miniMessage("debugroadregen.regenallroads_started"));
boolean result = this.hybridUtils.scheduleRoadUpdate(area, height);
if (!result) {
player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress"));
player.sendMessage(TranslatableCaption.miniMessage("debugexec.mass_schematic_update_in_progress"));
return false;
}
return true;

View File

@ -120,10 +120,10 @@ public class Reload extends SubCommand {
}
});
this.worldConfiguration.save(this.worldFile);
player.sendMessage(TranslatableCaption.of("reload.reloaded_configs"));
player.sendMessage(TranslatableCaption.miniMessage("reload.reloaded_configs"));
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(TranslatableCaption.of("reload.reload_failed"));
player.sendMessage(TranslatableCaption.miniMessage("reload.reload_failed"));
}
return true;
}

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -65,28 +65,28 @@ public class Remove extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_REMOVE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return true;
}
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
int count = 0;
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
return;
} else if (throwable != null) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
return;
} else if (!uuids.isEmpty()) {
@ -122,13 +122,13 @@ public class Remove extends SubCommand {
}
if (count == 0) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
} else {
player.sendMessage(
TranslatableCaption.of("member.removed_players"),
Template.of("amount", count + "")
TranslatableCaption.miniMessage("member.removed_players"),
Placeholder.miniMessage("amount", count + "")
);
}
});

View File

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

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.URL;
@ -73,29 +73,29 @@ public class Save extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
final String world = player.getLocation().getWorldName();
if (!this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SAVE)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
plot.addRunning();
@ -117,13 +117,13 @@ public class Save extends SubCommand {
public void run(URL url) {
plot.removeRunning();
if (url == null) {
player.sendMessage(TranslatableCaption.of("backups.backup_save_failed"));
player.sendMessage(TranslatableCaption.miniMessage("backups.backup_save_failed"));
return;
}
player.sendMessage(TranslatableCaption.of("web.save_success"));
player.sendMessage(TranslatableCaption.miniMessage("web.save_success"));
player.sendMessage(
TranslatableCaption.of("errors.deprecated_commands"),
Template.of("replacement", "/plot download")
TranslatableCaption.miniMessage("errors.deprecated_commands"),
Placeholder.miniMessage("replacement", "/plot download")
);
try (final MetaDataAccess<List<String>> schematicAccess =
player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) {

View File

@ -43,7 +43,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.net.URL;
@ -79,8 +79,8 @@ public class SchematicCmd extends SubCommand {
public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length < 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Possible values: save, paste, exportall, list")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Possible values: save, paste, exportall, list")
);
return true;
}
@ -89,39 +89,39 @@ public class SchematicCmd extends SubCommand {
case "paste" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_PASTE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_PASTE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_PASTE))
);
return false;
}
if (args.length < 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Possible values: save, paste, exportall, list")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Possible values: save, paste, exportall, list")
);
break;
}
Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.command.schematic.paste")) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
if (this.running) {
player.sendMessage(TranslatableCaption.of("error.task_in_process"));
player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false;
}
final String location = args[1];
@ -137,8 +137,8 @@ public class SchematicCmd extends SubCommand {
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid"),
Template.of("reason", "non-existent url: " + location)
TranslatableCaption.miniMessage("schematics.schematic_invalid"),
Placeholder.miniMessage("reason", "non-existent url: " + location)
);
SchematicCmd.this.running = false;
return;
@ -153,8 +153,8 @@ public class SchematicCmd extends SubCommand {
if (schematic == null) {
SchematicCmd.this.running = false;
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid"),
Template.of("reason", "non-existent or not in gzip format")
TranslatableCaption.miniMessage("schematics.schematic_invalid"),
Placeholder.miniMessage("reason", "non-existent or not in gzip format")
);
return;
}
@ -171,9 +171,9 @@ public class SchematicCmd extends SubCommand {
public void run(Boolean value) {
SchematicCmd.this.running = false;
if (value) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_success"));
} else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_failed"));
}
}
}
@ -184,108 +184,108 @@ public class SchematicCmd extends SubCommand {
Location loc = player.getLocation();
final Plot plot = loc.getPlotAbs();
if (!(player instanceof ConsolePlayer)) {
player.sendMessage(TranslatableCaption.of("console.not_console"));
player.sendMessage(TranslatableCaption.miniMessage("console.not_console"));
return false;
}
if (args.length != 2) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_world_args"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_world_args"));
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Use /plot schematic exportall <area>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Use /plot schematic exportall <area>")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) {
player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"),
Template.of("value", args[1])
TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Placeholder.miniMessage("value", args[1])
);
return false;
}
Collection<Plot> plots = area.getPlots();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("schematic.schematic_exportall_world"));
player.sendMessage(TranslatableCaption.miniMessage("schematic.schematic_exportall_world"));
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Use /plot sch exportall <area>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Use /plot sch exportall <area>")
);
return false;
}
boolean result = this.schematicHandler.exportAll(plots, null, null,
() -> player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_finished"))
() -> player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_finished"))
);
if (!result) {
player.sendMessage(TranslatableCaption.of("error.task_in_process"));
player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false;
} else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_started"));
player.sendMessage(
TranslatableCaption.of("schematics.plot_to_schem"),
Template.of("amount", String.valueOf(plots.size()))
TranslatableCaption.miniMessage("schematics.plot_to_schem"),
Placeholder.miniMessage("amount", String.valueOf(plots.size()))
);
}
}
case "export", "save" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_SAVE)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_SAVE))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_SAVE))
);
return false;
}
if (this.running) {
player.sendMessage(TranslatableCaption.of("error.task_in_process"));
player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false;
}
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.command.schematic.save")) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
ArrayList<Plot> plots = Lists.newArrayList(plot);
boolean result = this.schematicHandler.exportAll(plots, null, null, () -> {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_single_finished"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_single_finished"));
SchematicCmd.this.running = false;
});
if (!result) {
player.sendMessage(TranslatableCaption.of("error.task_in_process"));
player.sendMessage(TranslatableCaption.miniMessage("error.task_in_process"));
return false;
} else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_exportall_started"));
}
}
case "list" -> {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SCHEMATIC_LIST)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_LIST))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_SCHEMATIC_LIST))
);
return false;
}
final String string = StringMan.join(this.schematicHandler.getSchematicNames(), "$2, $1");
player.sendMessage(
TranslatableCaption.of("schematics.schematic_list"),
Template.of("list", string)
TranslatableCaption.miniMessage("schematics.schematic_list"),
Placeholder.miniMessage("list", string)
);
}
default -> player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Possible values: save, paste, exportall, list")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Possible values: save, paste, exportall, list")
);
}
return true;

View File

@ -47,7 +47,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockCategory;
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.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@ -129,8 +129,8 @@ public class Set extends SubCommand {
continue;
}
player.sendMessage(
TranslatableCaption.of("invalid.component_illegal_block"),
Template.of("value", forbiddenType)
TranslatableCaption.miniMessage("invalid.component_illegal_block"),
Placeholder.miniMessage("value", forbiddenType)
);
return true;
}
@ -141,20 +141,20 @@ public class Set extends SubCommand {
if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SET_COMPONENT.format(component))) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_SET_COMPONENT.format(component))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_SET_COMPONENT.format(component))
);
return false;
}
if (args.length < 2) {
player.sendMessage(TranslatableCaption.of("need.need_block"));
player.sendMessage(TranslatableCaption.miniMessage("need.need_block"));
return true;
}
Pattern pattern = PatternUtil.parse(player, material, false);
if (plot.getRunning() > 0) {
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
player.sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
@ -164,8 +164,8 @@ public class Set extends SubCommand {
queue.setCompleteTask(() -> {
plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("working.component_complete"),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("working.component_complete"),
Placeholder.miniMessage("plot", plot.getId().toString())
);
});
if (Settings.QUEUE.NOTIFY_PROGRESS) {
@ -180,7 +180,7 @@ public class Set extends SubCommand {
current.getPlotModificationManager().setComponent(component, pattern, player, queue);
}
queue.enqueue();
player.sendMessage(TranslatableCaption.of("working.generating_component"));
player.sendMessage(TranslatableCaption.miniMessage("working.generating_component"));
});
return true;
}
@ -205,9 +205,9 @@ public class Set extends SubCommand {
newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
}
player.sendMessage(StaticCaption.of(TranslatableCaption
.of("commandconfig.subcommand_set_options_header_only")
.miniMessage("commandconfig.subcommand_set_options_header_only")
.getComponent(player) + StringMan
.join(newValues, TranslatableCaption.of("blocklist.block_list_separator").getComponent(player))));
.join(newValues, TranslatableCaption.miniMessage("blocklist.block_list_separator").getComponent(player))));
return false;
}
@ -227,11 +227,11 @@ public class Set extends SubCommand {
// Additional checks
Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
// components

View File

@ -32,7 +32,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
public abstract class SetCommand extends SubCommand {
@ -41,26 +41,26 @@ public abstract class SetCommand extends SubCommand {
Location location = player.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))
);
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
player.sendMessage(TranslatableCaption.miniMessage("working.plot_not_claimed"));
return false;
}
}
if (!plot.isOwner(player.getUUID())) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", Permission.PERMISSION_ADMIN_COMMAND.format(getFullId()))
);
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return false;
}
}

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "sethome",
permission = "plots.set.home",
@ -43,14 +43,14 @@ public class SetHome extends SetCommand {
@Override
public boolean set(PlotPlayer<?> player, Plot plot, String value) {
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
switch (value.toLowerCase()) {
case "unset", "reset", "remove", "none" -> {
Plot base = plot.getBasePlot(false);
base.setHome(null);
player.sendMessage(TranslatableCaption.of("position.position_unset"));
player.sendMessage(TranslatableCaption.miniMessage("position.position_unset"));
return true;
}
case "" -> {
@ -61,13 +61,13 @@ public class SetHome extends SetCommand {
location.getZ() - bottom.getZ(), location.getYaw(), location.getPitch()
);
base.setHome(rel);
player.sendMessage(TranslatableCaption.of("position.position_set"));
player.sendMessage(TranslatableCaption.miniMessage("position.position_set"));
return true;
}
default -> {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Use /plot set home [none]")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Use /plot set home [none]")
);
return false;
}

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.setup.SetupProcess;
import com.plotsquared.core.setup.SetupStep;
import com.plotsquared.core.util.SetupUtils;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@ -61,7 +61,7 @@ public class Setup extends SubCommand {
public void displayGenerators(PlotPlayer<?> player) {
StringBuilder message = new StringBuilder();
message.append(TranslatableCaption.of("setup.choose_generator").getComponent(player));
message.append(TranslatableCaption.miniMessage("setup.choose_generator").getComponent(player));
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
if (entry.getKey().equals(PlotSquared.platform().pluginName())) {
message.append("\n<dark_gray> - </dark_gray><dark_green>").append(entry.getKey()).append(
@ -82,10 +82,10 @@ public class Setup extends SubCommand {
SetupProcess process = metaDataAccess.get().orElse(null);
if (process == null) {
if (args.length > 0) {
player.sendMessage(TranslatableCaption.of("setup.setup_not_started"));
player.sendMessage(TranslatableCaption.miniMessage("setup.setup_not_started"));
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Use /plot setup to start a setup process.")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "Use /plot setup to start a setup process.")
);
return true;
}
@ -103,7 +103,7 @@ public class Setup extends SubCommand {
process.getCurrentStep().announce(player);
} else if ("cancel".equalsIgnoreCase(args[0])) {
metaDataAccess.remove();
player.sendMessage(TranslatableCaption.of("setup.setup_cancelled"));
player.sendMessage(TranslatableCaption.miniMessage("setup.setup_cancelled"));
} else {
process.handleInput(player, args[0]);
if (process.getCurrentStep() != null) {

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.concurrent.CompletableFuture;
@ -53,12 +53,12 @@ public class Swap extends SubCommand {
Location location = player.getLocation();
Plot plot1 = location.getPlotAbs();
if (plot1 == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return CompletableFuture.completedFuture(false);
}
if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return CompletableFuture.completedFuture(false);
}
if (args.length != 1) {
@ -70,27 +70,27 @@ public class Swap extends SubCommand {
return CompletableFuture.completedFuture(false);
}
if (plot1.equals(plot2)) {
player.sendMessage(TranslatableCaption.of("invalid.origin_cant_be_target"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.origin_cant_be_target"));
return CompletableFuture.completedFuture(false);
}
if (!plot1.getArea().isCompatible(plot2.getArea())) {
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible"));
player.sendMessage(TranslatableCaption.miniMessage("errors.plotworld_incompatible"));
return CompletableFuture.completedFuture(false);
}
if (plot1.isMerged() || plot2.isMerged()) {
player.sendMessage(TranslatableCaption.of("swap.swap_merged"));
player.sendMessage(TranslatableCaption.miniMessage("swap.swap_merged"));
return CompletableFuture.completedFuture(false);
}
return plot1.getPlotModificationManager().move(plot2, player, () -> {
}, true).thenApply(result -> {
if (result) {
player.sendMessage(TranslatableCaption.of("swap.swap_success"), Template.of("origin", String.valueOf(plot1)),
Template.of("target", String.valueOf(plot2))
player.sendMessage(TranslatableCaption.miniMessage("swap.swap_success"), Placeholder.miniMessage("origin", String.valueOf(plot1)),
Placeholder.miniMessage("target", String.valueOf(plot2))
);
return true;
} else {
player.sendMessage(TranslatableCaption.of("swap.swap_overlap"));
player.sendMessage(TranslatableCaption.miniMessage("swap.swap_overlap"));
return false;
}
});

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import java.util.Collection;
import java.util.Locale;
@ -53,13 +53,13 @@ public class Target extends SubCommand {
public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation();
if (!location.isPlotArea()) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot_world"));
return false;
}
if (args.length == 0) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot target <<X;Z> | nearest>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot target <<X;Z> | nearest>")
);
return false;
}
@ -74,7 +74,7 @@ public class Target extends SubCommand {
}
}
if (target == null) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return false;
}
} else if ((target = Plot.getPlotFromString(player, args[0], true)) == null) {
@ -82,8 +82,8 @@ public class Target extends SubCommand {
}
target.getCenter(player::setCompassTarget);
player.sendMessage(
TranslatableCaption.of("compass.compass_target"),
Template.of("target", target.toString())
TranslatableCaption.miniMessage("compass.compass_target"),
Placeholder.miniMessage("target", target.toString())
);
return true;
}

View File

@ -51,6 +51,7 @@ import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.io.File;
@ -175,14 +176,14 @@ public class Template extends SubCommand {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("export")) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
net.kyori.adventure.text.minimessage.Template.of("value", "/plot template export <world>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot template export <world>")
);
return true;
} else if (args[0].equalsIgnoreCase("import")) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
net.kyori.adventure.text.minimessage.Template.of("value", "/plot template import <world> <template>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot template import <world> <template>")
);
return true;
}
@ -195,23 +196,23 @@ public class Template extends SubCommand {
case "import" -> {
if (args.length != 3) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
net.kyori.adventure.text.minimessage.Template.of("value", "/plot template import <world> <template>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot template import <world> <template>")
);
return false;
}
if (this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(
TranslatableCaption.of("setup.setup_world_taken"),
net.kyori.adventure.text.minimessage.Template.of("value", world)
TranslatableCaption.miniMessage("setup.setup_world_taken"),
Placeholder.miniMessage("value", world)
);
return false;
}
boolean result = extractAllFiles(world, args[2]);
if (!result) {
player.sendMessage(
TranslatableCaption.of("template.invalid_template"),
net.kyori.adventure.text.minimessage.Template.of("value", args[2])
TranslatableCaption.miniMessage("template.invalid_template"),
Placeholder.miniMessage("value", args[2])
);
return false;
}
@ -241,23 +242,23 @@ public class Template extends SubCommand {
this.setupUtils.setupWorld(builder);
TaskManager.runTask(() -> {
player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND_TEMPLATE);
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
player.sendMessage(TranslatableCaption.miniMessage("setup.setup_finished"));
});
return true;
}
case "export" -> {
if (args.length != 2) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
net.kyori.adventure.text.minimessage.Template.of("value", "/plot template export <world>")
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholder.miniMessage("value", "/plot template export <world>")
);
return false;
}
final PlotArea area = this.plotAreaManager.getPlotAreaByString(world);
if (area == null) {
player.sendMessage(
TranslatableCaption.of("errors.not_valid_plot_world"),
net.kyori.adventure.text.minimessage.Template.of("value", args[1])
TranslatableCaption.miniMessage("errors.not_valid_plot_world"),
Placeholder.miniMessage("value", args[1])
);
return false;
}
@ -268,12 +269,12 @@ public class Template extends SubCommand {
} catch (Exception e) { // Must recover from any exception thrown a third party template manager
e.printStackTrace();
player.sendMessage(
TranslatableCaption.of("template.template_failed"),
net.kyori.adventure.text.minimessage.Template.of("value", e.getMessage())
TranslatableCaption.miniMessage("template.template_failed"),
Placeholder.miniMessage("value", e.getMessage())
);
return;
}
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
player.sendMessage(TranslatableCaption.miniMessage("setup.setup_finished"));
});
return true;
}

View File

@ -29,7 +29,7 @@ import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
@CommandDeclaration(command = "toggle",
aliases = {"attribute"},
@ -53,13 +53,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "chatspy")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
}
@ -74,13 +74,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "worldedit")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
}
@ -94,13 +94,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "chat")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
}
@ -114,13 +114,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "ignoreExpireTask")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
}
@ -134,13 +134,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "disabletitles")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
}
@ -154,13 +154,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "disabletime")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
}
@ -174,13 +174,13 @@ public class Toggle extends Command {
) {
if (toggle(player, "debug")) {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_disabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_disabled"),
Placeholder.miniMessage("setting", command.toString())
);
} else {
player.sendMessage(
TranslatableCaption.of("toggle.toggle_enabled"),
Template.of("setting", command.toString())
TranslatableCaption.miniMessage("toggle.toggle_enabled"),
Placeholder.miniMessage("setting", command.toString())
);
}
player.refreshDebug();

View File

@ -97,7 +97,7 @@ public class Trim extends SubCommand {
if (result == null) {
return false;
}
TranslatableCaption.of("trim.trim_starting");
TranslatableCaption.miniMessage("trim.trim_starting");
final List<Plot> plots = PlotQuery.newQuery().inWorld(world).asList();
if (ExpireManager.IMP != null) {
plots.removeAll(ExpireManager.IMP.getPendingExpired());
@ -138,11 +138,11 @@ public class Trim extends SubCommand {
}
final String world = args[0];
if (!this.worldUtil.isWorld(world) || !this.plotAreaManager.hasPlotArea(world)) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_valid_world"));
return false;
}
if (Trim.TASK) {
player.sendMessage(TranslatableCaption.of("trim.trim_in_progress"));
player.sendMessage(TranslatableCaption.miniMessage("trim.trim_in_progress"));
return false;
}
Trim.TASK = true;
@ -160,7 +160,7 @@ public class Trim extends SubCommand {
public void run() {
if (nonViable.isEmpty()) {
Trim.TASK = false;
player.sendMessage(TranslatableCaption.of("trim.trim_done"));
player.sendMessage(TranslatableCaption.miniMessage("trim.trim_done"));
LOGGER.info("Trim done!");
return;
}
@ -211,7 +211,7 @@ public class Trim extends SubCommand {
} else {
regenTask = () -> {
Trim.TASK = false;
player.sendMessage(TranslatableCaption.of("trim.trim_done"));
player.sendMessage(TranslatableCaption.miniMessage("trim.trim_done"));
LOGGER.info("Trim done!");
};
}

View File

@ -27,7 +27,7 @@ package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.permissions.Permission;
@ -39,7 +39,7 @@ import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
@ -72,35 +72,35 @@ public class Trust extends Command {
) throws CommandException {
final Plot currentPlot = player.getCurrentPlot();
if (currentPlot == null) {
throw new CommandException(TranslatableCaption.of("errors.not_in_plot"));
throw new CommandException(TranslatableCaption.miniMessage("errors.not_in_plot"));
}
checkTrue(currentPlot.hasOwner(), TranslatableCaption.of("info.plot_unowned"));
checkTrue(currentPlot.hasOwner(), TranslatableCaption.miniMessage("info.plot_unowned"));
checkTrue(
currentPlot.isOwner(player.getUUID()) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST),
TranslatableCaption.of("permission.no_plot_perms")
TranslatableCaption.miniMessage("permission.no_plot_perms")
);
checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage())
checkTrue(args.length == 1, TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", getUsage())
);
final CompletableFuture<Boolean> future = new CompletableFuture<>();
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable != null) {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", args[0])
);
}
future.completeExceptionally(throwable);
return;
} else {
checkTrue(!uuids.isEmpty(), TranslatableCaption.of("errors.invalid_player"),
Templates.of("value", args[0])
checkTrue(!uuids.isEmpty(), TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholders.miniMessage("value", args[0])
);
Iterator<UUID> iterator = uuids.iterator();
@ -111,24 +111,24 @@ public class Trust extends Command {
Permissions.hasPermission(player, Permission.PERMISSION_TRUST_EVERYONE) || Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", PlayerManager.getName(uuid))
);
iterator.remove();
continue;
}
if (currentPlot.isOwner(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_added"),
Template.of("value", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("member.already_added"),
Placeholder.miniMessage("value", PlayerManager.getName(uuid))
);
iterator.remove();
continue;
}
if (currentPlot.getTrusted().contains(uuid)) {
player.sendMessage(
TranslatableCaption.of("member.already_added"),
Template.of("value", PlayerManager.getName(uuid))
TranslatableCaption.miniMessage("member.already_added"),
Placeholder.miniMessage("value", PlayerManager.getName(uuid))
);
iterator.remove();
continue;
@ -140,8 +140,8 @@ public class Trust extends Command {
int maxTrustSize = Permissions.hasPermissionRange(player, Permission.PERMISSION_TRUST, Settings.Limit.MAX_PLOTS);
if (localTrustSize >= maxTrustSize) {
player.sendMessage(
TranslatableCaption.of("members.plot_max_members_trusted"),
Template.of("amount", String.valueOf(localTrustSize))
TranslatableCaption.miniMessage("members.plot_max_members_trusted"),
Placeholder.miniMessage("amount", String.valueOf(localTrustSize))
);
return;
}
@ -157,7 +157,7 @@ public class Trust extends Command {
}
currentPlot.addTrusted(uuid);
this.eventDispatcher.callTrusted(player, currentPlot, uuid, true);
player.sendMessage(TranslatableCaption.of("trusted.trusted_added"));
player.sendMessage(TranslatableCaption.miniMessage("trusted.trusted_added"));
}
}, null);
}

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
@CommandDeclaration(command = "unlink",
@ -60,19 +60,19 @@ public class Unlink extends SubCommand {
Location location = player.getLocation();
final Plot plot = location.getPlotAbs();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return false;
}
if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return false;
}
if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return false;
}
if (!plot.isMerged()) {
player.sendMessage(TranslatableCaption.of("merge.unlink_impossible"));
player.sendMessage(TranslatableCaption.miniMessage("merge.unlink_impossible"));
return false;
}
final boolean createRoad;
@ -92,23 +92,23 @@ public class Unlink extends SubCommand {
);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Unlink")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Unlink")
);
return true;
}
boolean force = event.getEventResult() == Result.FORCE;
if (!force && !plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_UNLINK)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return true;
}
Runnable runnable = () -> {
if (!plot.getPlotModificationManager().unlinkPlot(createRoad, createRoad)) {
player.sendMessage(TranslatableCaption.of("merge.unmerge_cancelled"));
player.sendMessage(TranslatableCaption.miniMessage("merge.unmerge_cancelled"));
return;
}
player.sendMessage(TranslatableCaption.of("merge.unlink_success"));
player.sendMessage(TranslatableCaption.miniMessage("merge.unlink_success"));
eventDispatcher.callPostUnlink(plot, PlotUnlinkEvent.REASON.PLAYER_COMMAND);
};
if (hasConfirmation(player)) {

View File

@ -28,7 +28,7 @@ package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.Placeholders;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.permissions.Permission;
@ -45,7 +45,7 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
@ -102,13 +102,13 @@ public class Visit extends Command {
final List<Plot> plots = query.asList();
if (plots.isEmpty()) {
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.found_no_plots"));
return;
} else if (plots.size() < page || page < 1) {
player.sendMessage(
TranslatableCaption.of("invalid.number_not_in_range"),
Template.of("min", "1"),
Template.of("max", String.valueOf(plots.size()))
TranslatableCaption.miniMessage("invalid.number_not_in_range"),
Placeholder.miniMessage("min", "1"),
Placeholder.miniMessage("max", String.valueOf(plots.size()))
);
return;
}
@ -117,8 +117,8 @@ public class Visit extends Command {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_UNOWNED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.visit.unowned")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.visit.unowned")
);
return;
}
@ -126,16 +126,16 @@ public class Visit extends Command {
if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OWNED) && !Permissions
.hasPermission(player, Permission.PERMISSION_HOME)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.visit.owned")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.visit.owned")
);
return;
}
} else if (plot.isAdded(player.getUUID())) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_SHARED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.visit.shared")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.visit.shared")
);
return;
}
@ -145,16 +145,16 @@ public class Visit extends Command {
if (!plot.getFlag(UntrustedVisitFlag.class) && !Permissions.hasPermission(player, Permission.PERMISSION_VISIT_OTHER)
&& !Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_VISIT_UNTRUSTED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.visit.other")
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholders.miniMessage("node", "plots.visit.other")
);
return;
}
if (plot.isDenied(player.getUUID())) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_DENIED)) {
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", String.valueOf(Permission.PERMISSION_VISIT_DENIED))
TranslatableCaption.miniMessage("permission.no_permission"),
Placeholder.miniMessage("node", String.valueOf(Permission.PERMISSION_VISIT_DENIED))
);
return;
}
@ -195,12 +195,12 @@ public class Visit extends Command {
case 3:
if (!MathMan.isInteger(args[2])) {
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"),
Templates.of("value", "(1, ∞)")
TranslatableCaption.miniMessage("invalid.not_valid_number"),
Placeholders.miniMessage("value", "(1, ∞)")
);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", getUsage())
);
return CompletableFuture.completedFuture(false);
}
@ -212,12 +212,12 @@ public class Visit extends Command {
sortByArea = this.plotAreaManager.getPlotAreaByString(args[1]);
if (sortByArea == null) {
player.sendMessage(
TranslatableCaption.of("invalid.not_valid_number"),
Templates.of("value", "(1, ∞)")
TranslatableCaption.miniMessage("invalid.not_valid_number"),
Placeholders.miniMessage("value", "(1, ∞)")
);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", getUsage())
);
return CompletableFuture.completedFuture(false);
}
@ -226,11 +226,11 @@ public class Visit extends Command {
int finalPage1 = page;
PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> {
if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (throwable != null || uuids.size() != 1) {
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", getUsage())
);
} else {
final UUID uuid = uuids.toArray(new UUID[0])[0];
@ -256,8 +256,8 @@ public class Visit extends Command {
page = Integer.parseInt(args[1]);
} catch (NumberFormatException ignored) {
player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"),
Template.of("value", args[1])
TranslatableCaption.miniMessage("invalid.not_a_number"),
Placeholder.miniMessage("value", args[1])
);
return CompletableFuture.completedFuture(false);
}
@ -272,10 +272,10 @@ public class Visit extends Command {
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
// The request timed out
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
player.sendMessage(TranslatableCaption.miniMessage("players.fetching_players_timeout"));
} else if (uuid != null && !PlotQuery.newQuery().ownedBy(uuid).anyMatch()) {
// It was a valid UUID but the player has no plots
player.sendMessage(TranslatableCaption.of("errors.player_no_plots"));
player.sendMessage(TranslatableCaption.miniMessage("errors.player_no_plots"));
} else if (uuid == null) {
// player not found, so we assume it's an alias if no page was provided
if (finalPage == Integer.MIN_VALUE) {
@ -289,8 +289,8 @@ public class Visit extends Command {
);
} else {
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", finalArgs[0])
TranslatableCaption.miniMessage("errors.invalid_player"),
Placeholder.miniMessage("value", finalArgs[0])
);
}
} else {
@ -315,8 +315,8 @@ public class Visit extends Command {
case 0:
// /p v is invalid
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", getUsage())
TranslatableCaption.miniMessage("commandconfig.command_syntax"),
Placeholders.miniMessage("value", getUsage())
);
return CompletableFuture.completedFuture(false);
default:

View File

@ -46,7 +46,8 @@ import com.plotsquared.core.util.Permissions;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.item.ItemTypes;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -154,19 +155,19 @@ public class ComponentPresetManager {
final Plot plot = player.getCurrentPlot();
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
player.sendMessage(TranslatableCaption.miniMessage("errors.not_in_plot"));
return null;
} else if (!plot.hasOwner()) {
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
player.sendMessage(TranslatableCaption.miniMessage("info.plot_unowned"));
return null;
} else if (!plot.isOwner(player.getUUID()) && !plot.getTrusted().contains(player.getUUID()) && !Permissions.hasPermission(
player,
Permission.PERMISSION_ADMIN_COMPONENTS_OTHER
)) {
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
player.sendMessage(TranslatableCaption.miniMessage("permission.no_plot_perms"));
return null;
} else if (plot.getVolume() > Integer.MAX_VALUE) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_too_large"));
return null;
}
@ -182,7 +183,7 @@ public class ComponentPresetManager {
}
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size,
TranslatableCaption.of("preset.title").getComponent(player)) {
TranslatableCaption.miniMessage("preset.title").getComponent(player)) {
@Override
public boolean onClick(final int index) {
if (!getPlayer().getCurrentPlot().equals(plot)) {
@ -199,25 +200,25 @@ public class ComponentPresetManager {
}
if (plot.getRunning() > 0) {
getPlayer().sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
getPlayer().sendMessage(TranslatableCaption.miniMessage("errors.wait_for_timer"));
return false;
}
final Pattern pattern = PatternUtil.parse(null, componentPreset.getPattern(), false);
if (pattern == null) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_invalid"));
getPlayer().sendMessage(TranslatableCaption.miniMessage("preset.preset_invalid"));
return false;
}
if (componentPreset.getCost() > 0.0D && econHandler.isEnabled(plot.getArea())) {
if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) {
getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford"));
getPlayer().sendMessage(TranslatableCaption.miniMessage("preset.preset_cannot_afford"));
return false;
} else {
econHandler.withdrawMoney(getPlayer(), componentPreset.getCost());
getPlayer().sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", econHandler.format(componentPreset.getCost()))
TranslatableCaption.miniMessage("economy.removed_balance"),
Placeholder.miniMessage("money", econHandler.format(componentPreset.getCost()))
);
}
}
@ -235,7 +236,7 @@ public class ComponentPresetManager {
);
}
queue.enqueue();
getPlayer().sendMessage(TranslatableCaption.of("working.generating_component"));
getPlayer().sendMessage(TranslatableCaption.miniMessage("working.generating_component"));
});
return false;
}
@ -246,15 +247,17 @@ public class ComponentPresetManager {
final ComponentPreset preset = allowedPresets.get(i);
final List<String> lore = new ArrayList<>();
if (preset.getCost() > 0 && this.econHandler.isEnabled(plot.getArea())) {
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(
TranslatableCaption.of("preset.preset_lore_cost").getComponent(player),
Template.of("cost", String.format("%.2f", preset.getCost()))
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.miniMessage("preset.preset_lore_cost").getComponent(player),
PlaceholderResolver.placeholders(Placeholder.miniMessage("cost", String.format("%.2f", preset.getCost())))
)));
}
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(
TranslatableCaption.of("preset.preset_lore_component").getComponent(player),
Template.of("component", preset.getComponent().name().toLowerCase()),
Template.of("prefix", TranslatableCaption.of("core.prefix").getComponent(player))
lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize(
TranslatableCaption.miniMessage("preset.preset_lore_component").getComponent(player),
PlaceholderResolver.placeholders(
Placeholder.miniMessage("component", preset.getComponent().name().toLowerCase()),
Placeholder.miniMessage("prefix", TranslatableCaption.miniMessage("core.prefix").getComponent(player))
)
)));
lore.removeIf(String::isEmpty);
lore.addAll(preset.getDescription());

View File

@ -25,12 +25,12 @@
*/
package com.plotsquared.core.configuration.caption;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
public class CaptionHolder {
private Caption caption = StaticCaption.of("");
private Template[] templates = new Template[0];
private Placeholder<?>[] placeholders = new Placeholder[0];
public void set(Caption caption) {
this.caption = caption;
@ -40,12 +40,12 @@ public class CaptionHolder {
return this.caption;
}
public Template[] getTemplates() {
return this.templates;
public Placeholder<?>[] getPlaceholders() {
return this.placeholders;
}
public void setTemplates(Template... templates) {
this.templates = templates;
public void setPlaceholders(Placeholder<?>... placeholders) {
this.placeholders = placeholders;
}
}

View File

@ -61,6 +61,7 @@ public class CaptionUtility {
)
);
private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
/**
* Format a chat message but keep the formatting keys
@ -106,9 +107,9 @@ public class CaptionUtility {
*/
public static String stripClickEvents(final @NonNull String miniMessageString) {
// parse, transform and serialize again
Component component = MiniMessage.get().parse(miniMessageString);
Component component = MINI_MESSAGE.deserialize(miniMessageString);
component = CLICK_STRIP_TRANSFORM.transform(component);
return MiniMessage.get().serialize(component);
return MINI_MESSAGE.serialize(component);
}
/**

View File

@ -28,83 +28,90 @@ package com.plotsquared.core.configuration.caption;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.PlayerManager;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* Utility class that generates {@link net.kyori.adventure.text.minimessage.Template templates}
* Utility class that generates {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder placeholder}
*/
public final class Templates {
public final class Placeholders {
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
private Templates() {
private Placeholders() {
throw new UnsupportedOperationException(
"This is a utility class and cannot be instantiated");
}
/**
* Create a {@link net.kyori.adventure.text.minimessage.Template} from a PlotSquared {@link Caption}
* Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a PlotSquared {@link Caption}
*
* @param localeHolder Locale holder
* @param key Template key
* @param caption Caption object
* @param replacements Replacements
* @return Generated template
* @since 6.3.0
*/
public static @NonNull Template of(
public static @NonNull Placeholder<?> miniMessage(
final @NonNull LocaleHolder localeHolder,
final @NonNull String key, final @NonNull Caption caption,
final @NonNull Template... replacements
final @NonNull Placeholder<?>... replacements
) {
return Template.of(key, MINI_MESSAGE.parse(caption.getComponent(localeHolder), replacements));
return Placeholder.miniMessage(key, MINI_MESSAGE.deserialize(caption.getComponent(localeHolder),
PlaceholderResolver.placeholders(replacements)).toString());
}
/**
* Create a {@link Template} from a username (using UUID mappings)
* Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a username (using UUID mappings)
*
* @param key Template key
* @param uuid Player UUID
* @return Generated template
* @since 6.3.0
*/
public static @NonNull Template of(final @NonNull String key, final @NonNull UUID uuid) {
public static @NonNull Placeholder<?> miniMessage(final @NonNull String key, final @NonNull UUID uuid) {
final String username = PlayerManager.getName(uuid);
return Template.of(key, username);
return Placeholder.miniMessage(key, username);
}
/**
* Create a {@link Template} from a string
* Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a string
*
* @param key Template key
* @param value Template value
* @return Generated template
* @since 6.3.0
*/
public static @NonNull Template of(final @NonNull String key, final @NonNull String value) {
return Template.of(key, value);
public static @NonNull Placeholder<?> miniMessage(final @NonNull String key, final @NonNull String value) {
return Placeholder.miniMessage(key, value);
}
/**
* Create a {@link Template} from a plot area
* Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a plot area
*
* @param key Template Key
* @param area Plot area
* @return Generated template
* @since 6.3.0
*/
public static @NonNull Template of(final @NonNull String key, final @NonNull PlotArea area) {
return Template.of(key, area.toString());
public static @NonNull Placeholder<?> miniMessage(final @NonNull String key, final @NonNull PlotArea area) {
return Placeholder.miniMessage(key, area.toString());
}
/**
* Create a {@link Template} from a number
* Create a {@link net.kyori.adventure.text.minimessage.placeholder.Placeholder} from a number
*
* @param key Template key
* @param number Number
* @return Generated template
* @since 6.3.0
*/
public static @NonNull Template of(final @NonNull String key, final @NonNull Number number) {
return Template.of(key, number.toString());
public static @NonNull Placeholder<?> miniMessage(final @NonNull String key, final @NonNull Number number) {
return Placeholder.miniMessage(key, number.toString());
}
}

View File

@ -56,7 +56,9 @@ public final class TranslatableCaption implements NamespacedCaption {
* @param rawKey Caption key in the format namespace:key. If no namespace is
* included, {@link #DEFAULT_NAMESPACE} will be used.
* @return Caption instance
* @deprecated Use {@link #miniMessage(String)} instead
*/
@Deprecated(forRemoval = true, since = "6.3.0")
public static @NonNull TranslatableCaption of(final @NonNull String rawKey) {
final String namespace;
final String key;
@ -74,13 +76,40 @@ public final class TranslatableCaption implements NamespacedCaption {
);
}
/**
* Get a new {@link TranslatableCaption} instance
*
* @param rawKey Caption key in the format namespace:key. If no namespace is
* included, {@link #DEFAULT_NAMESPACE} will be used.
* @return Caption instance
* @since 6.3.0
*/
public static @NonNull TranslatableCaption miniMessage(final @NonNull String rawKey) {
final String namespace;
final String key;
if (rawKey.contains(":")) {
final String[] split = rawKey.split(Pattern.quote(":"));
namespace = split[0];
key = split[1];
} else {
namespace = DEFAULT_NAMESPACE;
key = rawKey;
}
return new TranslatableCaption(
namespace.toLowerCase(Locale.ENGLISH),
key.toLowerCase(Locale.ENGLISH)
);
}
/**
* Get a new {@link TranslatableCaption} instance
*
* @param namespace Caption namespace
* @param key Caption key
* @return Caption instance
* @deprecated Use {@link #miniMessage(String)} instead
*/
@Deprecated(forRemoval = true, since = "6.3.0")
public static @NonNull TranslatableCaption of(
final @NonNull String namespace,
final @NonNull String key
@ -91,6 +120,24 @@ public final class TranslatableCaption implements NamespacedCaption {
);
}
/**
* Get a new {@link TranslatableCaption} instance
*
* @param namespace Caption namespace
* @param key Caption key
* @return Caption instance
* @since 6.3.0
*/
public static @NonNull TranslatableCaption miniMessage(
final @NonNull String namespace,
final @NonNull String key
) {
return new TranslatableCaption(
namespace.toLowerCase(Locale.ENGLISH),
key.toLowerCase(Locale.ENGLISH)
);
}
@Override
public @NonNull String getComponent(final @NonNull LocaleHolder localeHolder) {
return PlotSquared.get().getCaptionMap(this.namespace).getMessage(this, localeHolder);

View File

@ -214,7 +214,7 @@ public final class CaptionLoader {
}
return new LocalizedCaptionMap(locale, map.entrySet().stream()
.collect(Collectors.toMap(
entry -> TranslatableCaption.of(this.namespace, entry.getKey()),
entry -> TranslatableCaption.miniMessage(this.namespace, entry.getKey()),
Map.Entry::getValue
)
));

View File

@ -77,43 +77,43 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
@Override
public ConfigurationNode[] getSettingNodes() {
return new ConfigurationNode[]{
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, TranslatableCaption.of("setup.plot_height"),
new ConfigurationNode("plot.height", this.PLOT_HEIGHT, TranslatableCaption.miniMessage("setup.plot_height"),
ConfigurationUtil.INTEGER
),
new ConfigurationNode("plot.size", this.PLOT_WIDTH, TranslatableCaption.of("setup.plot_width"),
new ConfigurationNode("plot.size", this.PLOT_WIDTH, TranslatableCaption.miniMessage("setup.plot_width"),
ConfigurationUtil.INTEGER
),
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, TranslatableCaption.of("setup.plot_block"),
new ConfigurationNode("plot.filling", this.MAIN_BLOCK, TranslatableCaption.miniMessage("setup.plot_block"),
ConfigurationUtil.BLOCK_BUCKET
),
new ConfigurationNode("wall.place_top_block", this.PLACE_TOP_BLOCK,
TranslatableCaption.of("setup.top_block_boolean"), ConfigurationUtil.BOOLEAN
TranslatableCaption.miniMessage("setup.top_block_boolean"), ConfigurationUtil.BOOLEAN
),
new ConfigurationNode("plot.floor", this.TOP_BLOCK, TranslatableCaption.of("setup.plot_block_floor"),
new ConfigurationNode("plot.floor", this.TOP_BLOCK, TranslatableCaption.miniMessage("setup.plot_block_floor"),
ConfigurationUtil.BLOCK_BUCKET
),
new ConfigurationNode("wall.block", this.WALL_BLOCK, TranslatableCaption.of("setup.top_wall_block"),
new ConfigurationNode("wall.block", this.WALL_BLOCK, TranslatableCaption.miniMessage("setup.top_wall_block"),
ConfigurationUtil.BLOCK_BUCKET
),
new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK,
TranslatableCaption.of("setup.wall_block_claimed"), ConfigurationUtil.BLOCK_BUCKET
TranslatableCaption.miniMessage("setup.wall_block_claimed"), ConfigurationUtil.BLOCK_BUCKET
),
new ConfigurationNode("road.width", this.ROAD_WIDTH, TranslatableCaption.of("setup.road_width"),
new ConfigurationNode("road.width", this.ROAD_WIDTH, TranslatableCaption.miniMessage("setup.road_width"),
ConfigurationUtil.INTEGER
),
new ConfigurationNode("road.height", this.ROAD_HEIGHT, TranslatableCaption.of("setup.road_height"),
new ConfigurationNode("road.height", this.ROAD_HEIGHT, TranslatableCaption.miniMessage("setup.road_height"),
ConfigurationUtil.INTEGER
),
new ConfigurationNode("road.block", this.ROAD_BLOCK, TranslatableCaption.of("setup.road_block"),
new ConfigurationNode("road.block", this.ROAD_BLOCK, TranslatableCaption.miniMessage("setup.road_block"),
ConfigurationUtil.BLOCK_BUCKET
),
new ConfigurationNode("wall.filling", this.WALL_FILLING, TranslatableCaption.of("setup.wall_filling_block"),
new ConfigurationNode("wall.filling", this.WALL_FILLING, TranslatableCaption.miniMessage("setup.wall_filling_block"),
ConfigurationUtil.BLOCK_BUCKET
),
new ConfigurationNode("wall.height", this.WALL_HEIGHT, TranslatableCaption.of("setup.wall_height"),
new ConfigurationNode("wall.height", this.WALL_HEIGHT, TranslatableCaption.miniMessage("setup.wall_height"),
ConfigurationUtil.INTEGER
),
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, TranslatableCaption.of("setup.bedrock_boolean"),
new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, TranslatableCaption.miniMessage("setup.bedrock_boolean"),
ConfigurationUtil.BOOLEAN
)};
}

View File

@ -73,7 +73,7 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
@ -145,8 +145,8 @@ public class PlotListener {
if (plot.isDenied(player.getUUID()) && !Permissions
.hasPermission(player, "plots.admin.entry.denied")) {
player.sendMessage(
TranslatableCaption.of("deny.no_enter"),
Template.of("plot", plot.toString())
TranslatableCaption.miniMessage("deny.no_enter"),
Placeholder.miniMessage("plot", plot.toString())
);
return false;
}
@ -175,19 +175,19 @@ public class PlotListener {
if (!greeting.isEmpty()) {
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
player.sendMessage(
TranslatableCaption.of("flags.greeting_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("greeting", greeting)
TranslatableCaption.miniMessage("flags.greeting_flag_format"),
Placeholder.miniMessage("world", plot.getWorldName()),
Placeholder.miniMessage("plot_id", plot.getId().toString()),
Placeholder.miniMessage("alias", plot.getAlias()),
Placeholder.miniMessage("greeting", greeting)
);
} else {
player.sendActionBar(
TranslatableCaption.of("flags.greeting_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("greeting", greeting)
TranslatableCaption.miniMessage("flags.greeting_flag_format"),
Placeholder.miniMessage("world", plot.getWorldName()),
Placeholder.miniMessage("plot_id", plot.getId().toString()),
Placeholder.miniMessage("alias", plot.getAlias()),
Placeholder.miniMessage("greeting", greeting)
);
}
}
@ -197,9 +197,9 @@ public class PlotListener {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
Caption caption = TranslatableCaption.of("notification.notify_enter");
Template playerTemplate = Template.of("player", player.getName());
Template plotTemplate = Template.of("plot", plot.getId().toString());
Caption caption = TranslatableCaption.miniMessage("notification.notify_enter");
Placeholder<?> playerTemplate = Placeholder.miniMessage("player", player.getName());
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot", plot.getId().toString());
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
owner.sendMessage(caption, playerTemplate, plotTemplate);
} else {
@ -231,9 +231,9 @@ public class PlotListener {
player.setGameMode(gameMode);
} else {
player.sendMessage(
TranslatableCaption.of("gamemode.gamemode_was_bypassed"),
Template.of("gamemode", String.valueOf(gameMode)),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("gamemode.gamemode_was_bypassed"),
Placeholder.miniMessage("gamemode", String.valueOf(gameMode)),
Placeholder.miniMessage("plot", plot.getId().toString())
);
}
}
@ -246,9 +246,9 @@ public class PlotListener {
player.setGameMode(guestGameMode);
} else {
player.sendMessage(
TranslatableCaption.of("gamemode.gamemode_was_bypassed"),
Template.of("gamemode", String.valueOf(guestGameMode)),
Template.of("plot", plot.getId().toString())
TranslatableCaption.miniMessage("gamemode.gamemode_was_bypassed"),
Placeholder.miniMessage("gamemode", String.valueOf(guestGameMode)),
Placeholder.miniMessage("plot", plot.getId().toString())
);
}
}
@ -328,14 +328,14 @@ public class PlotListener {
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) {
final UUID plotOwner = plot.getOwnerAbs();
String owner = PlayerManager.getName(plotOwner, false);
Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.of("titles" +
Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.miniMessage("titles" +
".title_entered_plot");
Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.of("titles" +
Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.miniMessage("titles" +
".title_entered_plot_sub");
Template plotTemplate = Template.of("plot", lastPlot.getId().toString());
Template worldTemplate = Template.of("world", player.getLocation().getWorldName());
Template ownerTemplate = Template.of("owner", owner);
Template aliasTemplate = Template.of("alias", plot.getAlias());
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot", lastPlot.getId().toString());
Placeholder<?> worldTemplate = Placeholder.miniMessage("world", player.getLocation().getWorldName());
Placeholder<?> ownerTemplate = Placeholder.miniMessage("owner", owner);
Placeholder<?> aliasTemplate = Placeholder.miniMessage("alias", plot.getAlias());
final Consumer<String> userConsumer = user -> {
if (Settings.Titles.TITLES_AS_ACTIONBAR) {
@ -408,9 +408,9 @@ public class PlotListener {
player.setGameMode(pw.getGameMode());
} else {
player.sendMessage(
TranslatableCaption.of("gamemode.gamemode_was_bypassed"),
Template.of("gamemode", pw.getGameMode().getName().toLowerCase()),
Template.of("plot", plot.toString())
TranslatableCaption.miniMessage("gamemode.gamemode_was_bypassed"),
Placeholder.miniMessage("gamemode", pw.getGameMode().getName().toLowerCase()),
Placeholder.miniMessage("plot", plot.toString())
);
}
}
@ -420,19 +420,19 @@ public class PlotListener {
if (!farewell.isEmpty()) {
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
player.sendMessage(
TranslatableCaption.of("flags.farewell_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("farewell", farewell)
TranslatableCaption.miniMessage("flags.farewell_flag_format"),
Placeholder.miniMessage("world", plot.getWorldName()),
Placeholder.miniMessage("plot_id", plot.getId().toString()),
Placeholder.miniMessage("alias", plot.getAlias()),
Placeholder.miniMessage("farewell", farewell)
);
} else {
player.sendActionBar(
TranslatableCaption.of("flags.farewell_flag_format"),
Template.of("world", plot.getWorldName()),
Template.of("plot_id", plot.getId().toString()),
Template.of("alias", plot.getAlias()),
Template.of("farewell", farewell)
TranslatableCaption.miniMessage("flags.farewell_flag_format"),
Placeholder.miniMessage("world", plot.getWorldName()),
Placeholder.miniMessage("plot_id", plot.getId().toString()),
Placeholder.miniMessage("alias", plot.getAlias()),
Placeholder.miniMessage("farewell", farewell)
);
}
}
@ -442,9 +442,9 @@ public class PlotListener {
for (UUID uuid : plot.getOwners()) {
final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) {
Caption caption = TranslatableCaption.of("notification.notify_leave");
Template playerTemplate = Template.of("player", player.getName());
Template plotTemplate = Template.of("plot", plot.getId().toString());
Caption caption = TranslatableCaption.miniMessage("notification.notify_leave");
Placeholder<?> playerTemplate = Placeholder.miniMessage("player", player.getName());
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot", plot.getId().toString());
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
owner.sendMessage(caption, playerTemplate, plotTemplate);
} else {

View File

@ -45,7 +45,7 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Set;
@ -97,8 +97,8 @@ public class WESubscriber {
if (mask.isEmpty()) {
if (Permissions.hasPermission(plotPlayer, "plots.worldedit.bypass")) {
plotPlayer.sendMessage(
TranslatableCaption.of("worldedit.worldedit_bypass"),
Template.of("command", "/plot toggle worldedit")
TranslatableCaption.miniMessage("worldedit.worldedit_bypass"),
Placeholder.miniMessage("command", "/plot toggle worldedit")
);
}
if (this.plotAreaManager.hasPlotArea(world)) {

View File

@ -49,7 +49,8 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
@ -117,7 +118,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
@Override
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 int fadeIn, final int stay, final int fadeOut, final @NonNull Placeholder<?>... replacements
) {
}
@ -151,7 +152,7 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
@Override
public void sendMessage(
final @NonNull Caption caption,
final @NonNull Template... replacements
final @NonNull Placeholder<?>... replacements
) {
String message = caption.getComponent(this);
if (message.isEmpty()) {
@ -159,9 +160,10 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
}
message = CaptionUtility.format(this, message)
.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&')
.replace("<prefix>", TranslatableCaption.of("core.prefix").getComponent(this));
.replace("<prefix>", TranslatableCaption.miniMessage("core.prefix").getComponent(this));
// Parse the message
PlotSquared.platform().consoleAudience().sendMessage(MINI_MESSAGE.parse(message, replacements));
PlotSquared.platform().consoleAudience().sendMessage(MINI_MESSAGE.deserialize(message,
PlaceholderResolver.placeholders(replacements)));
}
@Override

View File

@ -66,7 +66,8 @@ 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.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import net.kyori.adventure.title.Title;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -714,7 +715,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
if (getMeta("teleportOnLogin", true)) {
teleport(location, TeleportCause.LOGIN);
sendMessage(
TranslatableCaption.of("teleport.teleported_to_plot"));
TranslatableCaption.miniMessage("teleport.teleported_to_plot"));
}
});
} else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
@ -726,7 +727,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
if (plot.isLoaded()) {
teleport(location, TeleportCause.LOGIN);
sendMessage(TranslatableCaption
.of("teleport.teleported_to_plot"));
.miniMessage("teleport.teleported_to_plot"));
}
}
})
@ -795,11 +796,10 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
final @NonNull MetaDataKey<T> key,
final @NonNull T value
) {
final Object rawValue = value;
if (key.getType().getRawType().equals(Integer.class)) {
this.setPersistentMeta(key.toString(), Ints.toByteArray((int) rawValue));
this.setPersistentMeta(key.toString(), Ints.toByteArray((int) (Object) value));
} else if (key.getType().getRawType().equals(Boolean.class)) {
this.setPersistentMeta(key.toString(), ByteArrayUtilities.booleanToBytes((boolean) rawValue));
this.setPersistentMeta(key.toString(), ByteArrayUtilities.booleanToBytes((boolean) (Object) value));
} else {
throw new IllegalArgumentException(String.format("Unknown meta data type '%s'", key.getType()));
}
@ -839,7 +839,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
*/
public void sendTitle(
final @NonNull Caption title, final @NonNull Caption subtitle,
final @NonNull Template... replacements
final @NonNull Placeholder<?>... replacements
) {
sendTitle(
title,
@ -864,12 +864,14 @@ public abstract class PlotPlayer<P> 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 Placeholder<?>... replacements
) {
final Component titleComponent = MiniMessage.get().parse(title.getComponent(this), replacements);
final Component titleComponent = MiniMessage.miniMessage().deserialize(title.getComponent(this),
PlaceholderResolver.placeholders(replacements));
final Component subtitleComponent =
MiniMessage.get().parse(subtitle.getComponent(this), replacements);
final Title.Times times = Title.Times.of(
MiniMessage.miniMessage().deserialize(subtitle.getComponent(this),
PlaceholderResolver.placeholders(replacements));
final Title.Times times = Title.Times.times(
Duration.of(Settings.Titles.TITLES_FADE_IN * 50L, ChronoUnit.MILLIS),
Duration.of(Settings.Titles.TITLES_STAY * 50L, ChronoUnit.MILLIS),
Duration.of(Settings.Titles.TITLES_FADE_OUT * 50L, ChronoUnit.MILLIS)
@ -886,7 +888,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
*/
public void sendActionBar(
final @NonNull Caption caption,
final @NonNull Template... replacements
final @NonNull Placeholder<?>... replacements
) {
String message;
try {
@ -903,17 +905,18 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
// Replace placeholders, etc
message = CaptionUtility.format(this, message)
.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&')
.replace("<prefix>", TranslatableCaption.of("core.prefix").getComponent(this));
.replace("<prefix>", TranslatableCaption.miniMessage("core.prefix").getComponent(this));
final Component component = MiniMessage.get().parse(message, replacements);
final Component component = MiniMessage.miniMessage().deserialize(message,
PlaceholderResolver.placeholders(replacements));
getAudience().sendActionBar(component);
}
@Override
public void sendMessage(
final @NonNull Caption caption,
final @NonNull Template... replacements
final @NonNull Placeholder<?>... replacements
) {
String message;
try {
@ -930,9 +933,9 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
// Replace placeholders, etc
message = CaptionUtility.format(this, message)
.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&')
.replace("<prefix>", TranslatableCaption.of("core.prefix").getComponent(this));
.replace("<prefix>", TranslatableCaption.miniMessage("core.prefix").getComponent(this));
// Parse the message
final Component component = MiniMessage.get().parse(message, replacements);
final Component component = MiniMessage.miniMessage().deserialize(message, PlaceholderResolver.placeholders(replacements));
if (!Objects.equal(component, this.getMeta("lastMessage"))
|| System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000) {
setMeta("lastMessage", component);

View File

@ -79,7 +79,8 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import net.kyori.adventure.text.Component;
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.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -372,13 +373,13 @@ public class Plot {
}
}
if (message && player != null) {
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id"));
player.sendMessage(TranslatableCaption.miniMessage("invalid.not_valid_plot_id"));
}
return null;
}
if (area == null) {
if (message && player != null) {
player.sendMessage(TranslatableCaption.of("errors.invalid_plot_world"));
player.sendMessage(TranslatableCaption.miniMessage("errors.invalid_plot_world"));
}
return null;
}
@ -1707,7 +1708,7 @@ public class Plot {
updateWorldBorder();
}
this.getPlotModificationManager().setSign(player.getName());
player.sendMessage(TranslatableCaption.of("working.claimed"), Template.of("plot", this.getId().toString()));
player.sendMessage(TranslatableCaption.miniMessage("working.claimed"), Placeholder.miniMessage("plot", this.getId().toString()));
if (teleport) {
if (!auto && Settings.Teleport.ON_CLAIM) {
teleportPlayer(player, TeleportCause.COMMAND_CLAIM, result -> {
@ -1745,9 +1746,9 @@ public class Plot {
@Override
public void run(Boolean value) {
if (value) {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_success"));
} else {
player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed"));
player.sendMessage(TranslatableCaption.miniMessage("schematics.schematic_paste_failed"));
}
}
}
@ -2574,9 +2575,9 @@ public class Plot {
if (players.isEmpty()) {
return;
}
Caption caption = TranslatableCaption.of("debug.plot_debug");
Template plotTemplate = Template.of("plot", this.toString());
Template messageTemplate = Template.of("message", message);
Caption caption = TranslatableCaption.miniMessage("debug.plot_debug");
Placeholder<?> plotTemplate = Placeholder.miniMessage("plot", this.toString());
Placeholder<?> messageTemplate = Placeholder.miniMessage("message", message);
for (final PlotPlayer<?> player : players) {
if (isOwner(player.getUUID()) || Permissions.hasPermission(player, Permission.PERMISSION_ADMIN_DEBUG_OTHER)) {
player.sendMessage(caption, plotTemplate, messageTemplate);
@ -2608,8 +2609,8 @@ public class Plot {
Result result = this.eventDispatcher.callTeleport(player, player.getLocation(), plot, cause).getEventResult();
if (result == Result.DENY) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Teleport")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Teleport")
);
resultConsumer.accept(false);
return;
@ -2617,14 +2618,14 @@ public class Plot {
final Consumer<Location> locationConsumer = location -> {
if (Settings.Teleport.DELAY == 0 || Permissions
.hasPermission(player, "plots.teleport.delay.bypass")) {
player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot"));
player.sendMessage(TranslatableCaption.miniMessage("teleport.teleported_to_plot"));
player.teleport(location, cause);
resultConsumer.accept(true);
return;
}
player.sendMessage(
TranslatableCaption.of("teleport.teleport_in_seconds"),
Template.of("amount", String.valueOf(Settings.Teleport.DELAY))
TranslatableCaption.miniMessage("teleport.teleport_in_seconds"),
Placeholder.miniMessage("amount", String.valueOf(Settings.Teleport.DELAY))
);
final String name = player.getName();
TaskManager.addToTeleportQueue(name);
@ -2633,7 +2634,7 @@ public class Plot {
return;
}
try {
player.sendMessage(TranslatableCaption.of("teleport.teleported_to_plot"));
player.sendMessage(TranslatableCaption.miniMessage("teleport.teleported_to_plot"));
player.teleport(location, cause);
} catch (final Exception ignored) {
}
@ -2800,7 +2801,7 @@ public class Plot {
public CompletableFuture<Caption> format(final Caption iInfo, PlotPlayer<?> player, final boolean full) {
final CompletableFuture<Caption> future = new CompletableFuture<>();
int num = this.getConnectedPlots().size();
String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player);
String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.miniMessage("info.none").getComponent(player);
Location bot = this.getCorners()[0];
PlotSquared.platform().worldUtil().getBiome(
Objects.requireNonNull(this.getWorldName()),
@ -2813,28 +2814,28 @@ public class Plot {
String seen;
if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) {
if (this.isOnline()) {
seen = TranslatableCaption.of("info.now").getComponent(player);
seen = TranslatableCaption.miniMessage("info.now").getComponent(player);
} else {
int time = (int) (ExpireManager.IMP.getAge(this) / 1000);
if (time != 0) {
seen = TimeUtil.secToTime(time);
} else {
seen = TranslatableCaption.of("info.known").getComponent(player);
seen = TranslatableCaption.miniMessage("info.known").getComponent(player);
}
}
} else {
seen = TranslatableCaption.of("info.never").getComponent(player);
seen = TranslatableCaption.miniMessage("info.never").getComponent(player);
}
String description = this.getFlag(DescriptionFlag.class);
if (description.isEmpty()) {
description = TranslatableCaption.of("info.plot_no_description").getComponent(player);
description = TranslatableCaption.miniMessage("info.plot_no_description").getComponent(player);
}
Component flags;
Collection<PlotFlag<?, ?>> flagCollection = this.getApplicableFlags(true);
if (flagCollection.isEmpty()) {
flags = MINI_MESSAGE.parse(TranslatableCaption.of("info.none").getComponent(player));
flags = MINI_MESSAGE.parse(TranslatableCaption.miniMessage("info.none").getComponent(player));
} else {
TextComponent.Builder flagBuilder = Component.text();
String prefix = " ";
@ -2845,13 +2846,15 @@ 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)
TranslatableCaption.miniMessage("info.plot_flag_list").getComponent(player)
),
Template.of("flag", flag.getName()),
Template.of("value", CaptionUtility.formatRaw(player, value.toString()))
PlaceholderResolver.placeholders(
Placeholder.miniMessage("flag", flag.getName()),
Placeholder.miniMessage("value", CaptionUtility.formatRaw(player, value.toString()))
)
);
flagBuilder.append(snip);
prefix = ", ";
@ -2864,56 +2867,56 @@ public class Plot {
owner = Component.text("unowned");
} else if (this.getOwner().equals(DBFunc.SERVER)) {
owner = Component.text(MINI_MESSAGE.stripTokens(TranslatableCaption
.of("info.server")
.miniMessage("info.server")
.getComponent(player)));
} else {
owner = PlayerManager.getPlayerList(this.getOwners(), player);
}
Template headerTemplate = Template.of(
Placeholder<?> headerTemplate = Placeholder.miniMessage(
"header",
TranslatableCaption.of("info.plot_info_header").getComponent(player)
TranslatableCaption.miniMessage("info.plot_info_header").getComponent(player)
);
Template footerTemplate = Template.of(
Placeholder<?> footerTemplate = Placeholder.miniMessage(
"footer",
TranslatableCaption.of("info.plot_info_footer").getComponent(player)
TranslatableCaption.miniMessage("info.plot_info_footer").getComponent(player)
);
Template areaTemplate;
Placeholder<?> areaTemplate;
if (this.getArea() != null) {
areaTemplate =
Template.of(
Placeholder.miniMessage(
"area",
this.getArea().getWorldName() + (this.getArea().getId() == null
? ""
: "(" + this.getArea().getId() + ")")
);
} else {
areaTemplate = Template.of("area", TranslatableCaption.of("info.none").getComponent(player));
areaTemplate = Placeholder.miniMessage("area", TranslatableCaption.miniMessage("info.none").getComponent(player));
}
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));
Placeholder<?> idTemplate = Placeholder.miniMessage("id", this.getId().toString());
Placeholder<?> aliasTemplate = Placeholder.miniMessage("alias", alias);
Placeholder<?> numTemplate = Placeholder.miniMessage("num", String.valueOf(num));
Placeholder<?> descTemplate = Placeholder.miniMessage("desc", description);
Placeholder<?> biomeTemplate = Placeholder.miniMessage("biome", biome.toString().toLowerCase());
Placeholder<?> ownerTemplate = Placeholder.miniMessage("owner", owner.toString());
Placeholder<?> membersTemplate =Placeholder.miniMessage("members", members.toString());
Placeholder<?> playerTemplate = Placeholder.miniMessage("player", player.getName());
Placeholder<?> trustedTemplate = Placeholder.miniMessage("trusted", trusted.toString());
Placeholder<?> helpersTemplate = Placeholder.miniMessage("helpers", members.toString());
Placeholder<?> deniedTemplate = Placeholder.miniMessage("denied", denied.toString());
Placeholder<?> seenTemplate = Placeholder.miniMessage("seen", seen);
Placeholder<?> flagsTemplate = Placeholder.miniMessage("flags", flags.toString());
Placeholder<?> creationTemplate = Placeholder.miniMessage("creationdate", newDate);
Placeholder<?> buildTemplate = Placeholder.miniMessage("build", String.valueOf(build));
if (iInfo.getComponent(player).contains("<rating>")) {
TaskManager.runTaskAsync(() -> {
Template ratingTemplate;
Placeholder<?> ratingTemplate;
if (Settings.Ratings.USE_LIKES) {
ratingTemplate = Template.of(
ratingTemplate = Placeholder.miniMessage(
"rating",
String.format("%.0f%%", Like.getLikesPercentage(this) * 100D)
);
@ -2931,22 +2934,23 @@ public class Plot {
.append(String.format("%.1f", ratings[i]));
prefix = ",";
}
ratingTemplate = Template.of("rating", rating.toString());
ratingTemplate = Placeholder.miniMessage("rating", rating.toString());
} else {
double rating = this.getAverageRating();
if (Double.isFinite(rating)) {
ratingTemplate = Template.of("rating", String.format("%.1f", rating) + '/' + max);
ratingTemplate = Placeholder.miniMessage("rating", String.format("%.1f", rating) + '/' + max);
} else {
ratingTemplate = Template.of(
ratingTemplate = Placeholder.miniMessage(
"rating",
TranslatableCaption.of("info.none").getComponent(player)
TranslatableCaption.miniMessage("info.none").getComponent(player)
);
}
}
}
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(
.deserialize(
iInfo.getComponent(player),
PlaceholderResolver.placeholders(
headerTemplate,
areaTemplate,
idTemplate,
@ -2966,13 +2970,14 @@ public class Plot {
ratingTemplate,
creationTemplate,
footerTemplate
))));
)))));
});
return;
}
future.complete(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
.parse(
.deserialize(
iInfo.getComponent(player),
PlaceholderResolver.placeholders(
headerTemplate,
areaTemplate,
idTemplate,
@ -2990,7 +2995,7 @@ public class Plot {
flagsTemplate,
buildTemplate,
footerTemplate
))));
)))));
}
);
return future;

View File

@ -70,7 +70,8 @@ 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.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.minimessage.placeholder.Placeholder;
import net.kyori.adventure.text.minimessage.placeholder.PlaceholderResolver;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -410,8 +411,8 @@ public abstract class PlotArea {
}
this.getFlagContainer().addAll(parseFlags(flags));
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.area_flags"),
Template.of("flags", flags.toString())
TranslatableCaption.miniMessage("flags.area_flags"),
Placeholder.miniMessage("flags", flags.toString())
);
this.spawnEggs = config.getBoolean("event.spawn.egg");
@ -431,8 +432,8 @@ public abstract class PlotArea {
}
this.getRoadFlagContainer().addAll(parseFlags(roadflags));
ConsolePlayer.getConsole().sendMessage(
TranslatableCaption.of("flags.road_flags"),
Template.of("flags", roadflags.toString())
TranslatableCaption.miniMessage("flags.road_flags"),
Placeholder.miniMessage("flags", roadflags.toString())
);
loadConfiguration(config);
@ -440,7 +441,7 @@ public abstract class PlotArea {
private Component getFlagsComponent(Component flagsComponent, Collection<PlotFlag<?, ?>> flagCollection) {
if (flagCollection.isEmpty()) {
flagsComponent = MINI_MESSAGE.parse(TranslatableCaption.of("flag.no_flags").getComponent(LocaleHolder.console()));
flagsComponent = MINI_MESSAGE.parse(TranslatableCaption.miniMessage("flag.no_flags").getComponent(LocaleHolder.console()));
} else {
String prefix = " ";
for (final PlotFlag<?, ?> flag : flagCollection) {
@ -450,14 +451,16 @@ public abstract class PlotArea {
} else {
value = flag.toString();
}
Component snip = MINI_MESSAGE.parse(
Component snip = MINI_MESSAGE.deserialize(
prefix + CaptionUtility
.format(
ConsolePlayer.getConsole(),
TranslatableCaption.of("info.plot_flag_list").getComponent(LocaleHolder.console())
TranslatableCaption.miniMessage("info.plot_flag_list").getComponent(LocaleHolder.console())
),
Template.of("flag", flag.getName()),
Template.of("value", CaptionUtility.formatRaw(ConsolePlayer.getConsole(), value.toString()))
PlaceholderResolver.placeholders(
Placeholder.miniMessage("flag", flag.getName()),
Placeholder.miniMessage("value", CaptionUtility.formatRaw(ConsolePlayer.getConsole(), value.toString()))
)
);
if (flagsComponent != null) {
flagsComponent.append(snip);

View File

@ -36,9 +36,9 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
public enum PlotAreaType {
NORMAL(TranslatableCaption.of("plotareatype.plot_area_type_normal")),
AUGMENTED(TranslatableCaption.of("plotareatype.plot_area_type_augmented")),
PARTIAL(TranslatableCaption.of("plotareatype.plot_area_type_partial"));
NORMAL(TranslatableCaption.miniMessage("plotareatype.plot_area_type_normal")),
AUGMENTED(TranslatableCaption.miniMessage("plotareatype.plot_area_type_augmented")),
PARTIAL(TranslatableCaption.miniMessage("plotareatype.plot_area_type_partial"));
private static final Map<String, PlotAreaType> types = Stream.of(values())
.collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));

View File

@ -51,7 +51,7 @@ 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.minimessage.placeholder.Placeholder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -384,10 +384,10 @@ public final class PlotModificationManager {
if (this.plot.getArea().allowSigns()) {
Location location = manager.getSignLoc(this.plot);
String id = this.plot.getId().toString();
Caption[] lines = new Caption[]{TranslatableCaption.of("signs.owner_sign_line_1"), TranslatableCaption.of(
Caption[] lines = new Caption[]{TranslatableCaption.miniMessage("signs.owner_sign_line_1"), TranslatableCaption.miniMessage(
"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));
TranslatableCaption.miniMessage("signs.owner_sign_line_3"), TranslatableCaption.miniMessage("signs.owner_sign_line_4")};
PlotSquared.platform().worldUtil().setSign(location, lines, Placeholder.miniMessage("id", id), Placeholder.miniMessage("owner", name));
}
}
@ -496,8 +496,8 @@ public final class PlotModificationManager {
if (event.getEventResult() == Result.DENY) {
if (player != null) {
player.sendMessage(
TranslatableCaption.of("events.event_denied"),
Template.of("value", "Auto merge on claim")
TranslatableCaption.miniMessage("events.event_denied"),
Placeholder.miniMessage("value", "Auto merge on claim")
);
}
return;

Some files were not shown because too many files have changed in this diff Show More