From fda01502b232cf2ef3a404d6b11c1a83aaa646a0 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Wed, 15 Dec 2021 01:20:26 +0100 Subject: [PATCH] refactor!: Update minimessage implementation --- .../bukkit/listener/BlockEventListener.java | 54 +-- .../bukkit/listener/PaperListener.java | 6 +- .../bukkit/listener/PaperListener113.java | 6 +- .../bukkit/listener/PlayerEventListener.java | 218 +++++------ .../bukkit/listener/ServerListener.java | 2 +- .../bukkit/placeholder/MVdWPlaceholders.java | 2 +- .../bukkit/util/BukkitEntityUtil.java | 36 +- .../plotsquared/bukkit/util/BukkitUtil.java | 8 +- .../java/com/plotsquared/core/PlotAPI.java | 8 +- .../core/backup/PlayerBackupProfile.java | 2 +- .../core/backup/SimpleBackupManager.java | 13 +- .../com/plotsquared/core/command/Add.java | 40 +- .../com/plotsquared/core/command/Alias.java | 44 +-- .../com/plotsquared/core/command/Area.java | 220 +++++------ .../com/plotsquared/core/command/Auto.java | 68 ++-- .../com/plotsquared/core/command/Backup.java | 116 +++--- .../com/plotsquared/core/command/Biome.java | 18 +- .../com/plotsquared/core/command/Buy.java | 42 +- .../com/plotsquared/core/command/Caps.java | 24 +- .../com/plotsquared/core/command/Chat.java | 10 +- .../com/plotsquared/core/command/Claim.java | 58 +-- .../com/plotsquared/core/command/Clear.java | 25 +- .../com/plotsquared/core/command/Cluster.java | 362 +++++++++--------- .../plotsquared/core/command/CmdConfirm.java | 10 +- .../com/plotsquared/core/command/Command.java | 55 +-- .../core/command/CommandCaller.java | 4 +- .../core/command/CommandCategory.java | 18 +- .../com/plotsquared/core/command/Comment.java | 32 +- .../plotsquared/core/command/Condense.java | 78 ++-- .../com/plotsquared/core/command/Confirm.java | 4 +- .../plotsquared/core/command/Continue.java | 22 +- .../com/plotsquared/core/command/Copy.java | 20 +- .../core/command/CreateRoadSchematic.java | 12 +- .../core/command/DatabaseCommand.java | 52 +-- .../com/plotsquared/core/command/Debug.java | 51 +-- .../core/command/DebugAllowUnsafe.java | 4 +- .../plotsquared/core/command/DebugExec.java | 58 +-- .../core/command/DebugImportWorlds.java | 8 +- .../plotsquared/core/command/DebugPaste.java | 32 +- .../core/command/DebugRoadRegen.java | 54 +-- .../core/command/DebugSaveTest.java | 4 +- .../com/plotsquared/core/command/Delete.java | 28 +- .../com/plotsquared/core/command/Deny.java | 32 +- .../com/plotsquared/core/command/Desc.java | 16 +- .../com/plotsquared/core/command/Done.java | 24 +- .../plotsquared/core/command/Download.java | 46 +-- .../plotsquared/core/command/FlagCommand.java | 167 ++++---- .../com/plotsquared/core/command/Grant.java | 28 +- .../com/plotsquared/core/command/Help.java | 31 +- .../plotsquared/core/command/HomeCommand.java | 22 +- .../com/plotsquared/core/command/Inbox.java | 116 +++--- .../com/plotsquared/core/command/Info.java | 42 +- .../com/plotsquared/core/command/Kick.java | 26 +- .../com/plotsquared/core/command/Leave.java | 14 +- .../com/plotsquared/core/command/Like.java | 30 +- .../com/plotsquared/core/command/ListCmd.java | 152 ++++---- .../com/plotsquared/core/command/Load.java | 42 +- .../plotsquared/core/command/MainCommand.java | 11 +- .../com/plotsquared/core/command/Merge.java | 89 ++--- .../com/plotsquared/core/command/Middle.java | 4 +- .../com/plotsquared/core/command/Move.java | 20 +- .../com/plotsquared/core/command/Music.java | 36 +- .../com/plotsquared/core/command/Near.java | 8 +- .../com/plotsquared/core/command/Owner.java | 38 +- .../plotsquared/core/command/PluginCmd.java | 6 +- .../com/plotsquared/core/command/Purge.java | 24 +- .../com/plotsquared/core/command/Rate.java | 58 +-- .../core/command/RegenAllRoads.java | 28 +- .../com/plotsquared/core/command/Reload.java | 4 +- .../com/plotsquared/core/command/Remove.java | 22 +- .../core/command/RequiredType.java | 4 +- .../com/plotsquared/core/command/Save.java | 22 +- .../core/command/SchematicCmd.java | 96 ++--- .../com/plotsquared/core/command/Set.java | 28 +- .../plotsquared/core/command/SetCommand.java | 16 +- .../com/plotsquared/core/command/SetHome.java | 12 +- .../com/plotsquared/core/command/Setup.java | 12 +- .../com/plotsquared/core/command/Swap.java | 18 +- .../com/plotsquared/core/command/Target.java | 14 +- .../plotsquared/core/command/Template.java | 37 +- .../com/plotsquared/core/command/Toggle.java | 58 +-- .../com/plotsquared/core/command/Trim.java | 10 +- .../com/plotsquared/core/command/Trust.java | 42 +- .../com/plotsquared/core/command/Unlink.java | 20 +- .../com/plotsquared/core/command/Visit.java | 70 ++-- .../components/ComponentPresetManager.java | 41 +- .../configuration/caption/CaptionHolder.java | 64 ++-- .../configuration/caption/CaptionUtility.java | 57 +-- .../{Templates.java => Placeholders.java} | 47 ++- .../caption/TranslatableCaption.java | 47 +++ .../caption/load/CaptionLoader.java | 2 +- .../core/generator/ClassicPlotWorld.java | 26 +- .../core/listener/PlotListener.java | 88 ++--- .../core/listener/WESubscriber.java | 6 +- .../core/player/ConsolePlayer.java | 12 +- .../plotsquared/core/player/PlotPlayer.java | 37 +- .../java/com/plotsquared/core/plot/Plot.java | 121 +++--- .../com/plotsquared/core/plot/PlotArea.java | 23 +- .../plotsquared/core/plot/PlotAreaType.java | 6 +- .../core/plot/PlotModificationManager.java | 12 +- .../core/plot/comment/CommentManager.java | 8 +- .../core/plot/expiration/ExpireManager.java | 30 +- .../core/plot/flag/FlagParseException.java | 18 +- .../flag/implementations/AnalysisFlag.java | 2 +- .../implementations/AnimalAttackFlag.java | 2 +- .../flag/implementations/AnimalCapFlag.java | 2 +- .../implementations/AnimalInteractFlag.java | 2 +- .../flag/implementations/BlockBurnFlag.java | 2 +- .../implementations/BlockIgnitionFlag.java | 2 +- .../flag/implementations/BlockedCmdsFlag.java | 4 +- .../plot/flag/implementations/BreakFlag.java | 2 +- .../plot/flag/implementations/ChatFlag.java | 2 +- .../flag/implementations/CopperOxideFlag.java | 2 +- .../flag/implementations/CoralDryFlag.java | 2 +- .../flag/implementations/CropGrowFlag.java | 2 +- .../flag/implementations/DenyExitFlag.java | 2 +- .../implementations/DenyPortalTravelFlag.java | 2 +- .../flag/implementations/DenyPortalsFlag.java | 2 +- .../implementations/DenyTeleportFlag.java | 10 +- .../flag/implementations/DescriptionFlag.java | 4 +- .../implementations/DeviceInteractFlag.java | 2 +- .../implementations/DisablePhysicsFlag.java | 2 +- .../plot/flag/implementations/DoneFlag.java | 2 +- .../implementations/DropProtectionFlag.java | 2 +- .../flag/implementations/EntityCapFlag.java | 2 +- .../EntityChangeBlockFlag.java | 2 +- .../flag/implementations/ExplosionFlag.java | 2 +- .../flag/implementations/FarewellFlag.java | 4 +- .../plot/flag/implementations/FeedFlag.java | 12 +- .../plot/flag/implementations/FlyFlag.java | 4 +- .../flag/implementations/ForcefieldFlag.java | 2 +- .../flag/implementations/GamemodeFlag.java | 4 +- .../flag/implementations/GrassGrowFlag.java | 2 +- .../flag/implementations/GreetingFlag.java | 4 +- .../implementations/GuestGamemodeFlag.java | 4 +- .../implementations/HangingBreakFlag.java | 2 +- .../implementations/HangingPlaceFlag.java | 2 +- .../plot/flag/implementations/HealFlag.java | 12 +- .../flag/implementations/HideInfoFlag.java | 2 +- .../implementations/HostileAttackFlag.java | 2 +- .../flag/implementations/HostileCapFlag.java | 2 +- .../implementations/HostileInteractFlag.java | 2 +- .../flag/implementations/IceFormFlag.java | 2 +- .../flag/implementations/IceMeltFlag.java | 2 +- .../flag/implementations/InstabreakFlag.java | 2 +- .../flag/implementations/InvincibleFlag.java | 2 +- .../flag/implementations/ItemDropFlag.java | 2 +- .../plot/flag/implementations/KeepFlag.java | 4 +- .../implementations/KeepInventoryFlag.java | 2 +- .../flag/implementations/KelpGrowFlag.java | 2 +- .../flag/implementations/LeafDecayFlag.java | 2 +- .../implementations/LecternReadBookFlag.java | 2 +- .../flag/implementations/LiquidFlowFlag.java | 4 +- .../flag/implementations/MiscBreakFlag.java | 2 +- .../flag/implementations/MiscCapFlag.java | 2 +- .../implementations/MiscInteractFlag.java | 2 +- .../flag/implementations/MiscPlaceFlag.java | 2 +- .../flag/implementations/MobBreakFlag.java | 2 +- .../plot/flag/implementations/MobCapFlag.java | 2 +- .../flag/implementations/MobPlaceFlag.java | 2 +- .../plot/flag/implementations/MusicFlag.java | 4 +- .../flag/implementations/MycelGrowFlag.java | 2 +- .../flag/implementations/NoWorldeditFlag.java | 2 +- .../flag/implementations/NotifyEnterFlag.java | 2 +- .../flag/implementations/NotifyLeaveFlag.java | 2 +- .../plot/flag/implementations/PlaceFlag.java | 2 +- .../implementations/PlayerInteractFlag.java | 2 +- .../flag/implementations/PlotTitleFlag.java | 6 +- .../PreventCreativeCopyFlag.java | 2 +- .../plot/flag/implementations/PriceFlag.java | 2 +- .../plot/flag/implementations/PveFlag.java | 2 +- .../plot/flag/implementations/PvpFlag.java | 2 +- .../flag/implementations/RedstoneFlag.java | 2 +- .../flag/implementations/ServerPlotFlag.java | 2 +- .../flag/implementations/SnowFormFlag.java | 2 +- .../flag/implementations/SnowMeltFlag.java | 2 +- .../flag/implementations/SoilDryFlag.java | 2 +- .../flag/implementations/TamedAttackFlag.java | 2 +- .../implementations/TamedInteractFlag.java | 2 +- .../plot/flag/implementations/TimeFlag.java | 2 +- .../plot/flag/implementations/TitlesFlag.java | 8 +- .../implementations/UntrustedVisitFlag.java | 2 +- .../plot/flag/implementations/UseFlag.java | 2 +- .../implementations/VehicleBreakFlag.java | 2 +- .../flag/implementations/VehicleCapFlag.java | 2 +- .../implementations/VehiclePlaceFlag.java | 2 +- .../flag/implementations/VehicleUseFlag.java | 2 +- .../implementations/VillagerInteractFlag.java | 2 +- .../flag/implementations/VineGrowFlag.java | 2 +- .../flag/implementations/WeatherFlag.java | 4 +- .../plot/flag/types/BlockTypeListFlag.java | 6 +- .../core/plot/flag/types/BooleanFlag.java | 4 +- .../core/plot/flag/types/DoubleFlag.java | 4 +- .../core/plot/flag/types/IntegerFlag.java | 4 +- .../core/plot/flag/types/LongFlag.java | 4 +- .../core/plot/flag/types/NumberFlag.java | 2 +- .../core/plot/flag/types/TimedFlag.java | 6 +- .../core/plot/world/SinglePlotArea.java | 2 +- .../subscriber/DefaultProgressSubscriber.java | 8 +- .../core/setup/CommonSetupSteps.java | 46 +-- .../core/setup/SettingsNodeStep.java | 12 +- .../core/util/EventDispatcher.java | 20 +- .../core/util/LegacyConverter.java | 14 +- .../plotsquared/core/util/PatternUtil.java | 6 +- .../plotsquared/core/util/Permissions.java | 6 +- .../plotsquared/core/util/PlayerManager.java | 29 +- .../plotsquared/core/util/RegionManager.java | 12 +- .../core/util/SchematicHandler.java | 2 +- .../com/plotsquared/core/util/WorldUtil.java | 4 +- .../core/util/helpmenu/HelpObject.java | 21 +- .../core/util/helpmenu/HelpPage.java | 39 +- .../placeholders/PlaceholderRegistry.java | 39 +- .../core/util/task/AutoClaimFinishTask.java | 8 +- .../plotsquared/core/uuid/UUIDPipeline.java | 2 +- gradle/libs.versions.toml | 5 +- 215 files changed, 2401 insertions(+), 2306 deletions(-) rename Core/src/main/java/com/plotsquared/core/configuration/caption/{Templates.java => Placeholders.java} (60%) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index 2a87b383e..f1592e73b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -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); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index c53c25b80..3a3c56d6e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -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); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java index 1e66d77c8..87f523dd8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java @@ -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); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index ee9a6d56d..d0d47e51c 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -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 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); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java index f10a2fc2e..72acc685a 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/ServerListener.java @@ -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")); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java index d46b73a48..2f7921304 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/placeholder/MVdWPlaceholders.java @@ -51,7 +51,7 @@ public class MVdWPlaceholders { ) { this.plugin = plugin; this.registry = registry; - for (final Placeholder placeholder : registry.getPlaceholders()) { + for (final Placeholder placeholder : registry.allPlaceholders()) { this.addPlaceholder(placeholder); } PlotSquared.get().getEventDispatcher().registerListener(this); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java index 32efe985e..43b15f8c2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java @@ -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 diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index 9b292b54c..db0acd8ce 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -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); } diff --git a/Core/src/main/java/com/plotsquared/core/PlotAPI.java b/Core/src/main/java/com/plotsquared/core/PlotAPI.java index 64400d7b3..9f79ca360 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotAPI.java +++ b/Core/src/main/java/com/plotsquared/core/PlotAPI.java @@ -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); } diff --git a/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java b/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java index c4a2d710c..fb1dc7f9e 100644 --- a/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java +++ b/Core/src/main/java/com/plotsquared/core/backup/PlayerBackupProfile.java @@ -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())))); } } diff --git a/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java b/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java index c78643c13..6e1d42f07 100644 --- a/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java +++ b/Core/src/main/java/com/plotsquared/core/backup/SimpleBackupManager.java @@ -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); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Add.java b/Core/src/main/java/com/plotsquared/core/command/Add.java index a87bb4206..36a6b8959 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Add.java +++ b/Core/src/main/java/com/plotsquared/core/command/Add.java @@ -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 confirm, RunnableVal2 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 ") + checkTrue(args.length == 1, TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot add ") ); final CompletableFuture 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 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) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Alias.java b/Core/src/main/java/com/plotsquared/core/command/Alias.java index 68efb0cff..0b3fcd5ff 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Alias.java +++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java @@ -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); diff --git a/Core/src/main/java/com/plotsquared/core/command/Area.java b/Core/src/main/java/com/plotsquared/core/command/Area.java index 9afe56ae3..3f2fb958d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -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 ") + TranslatableCaption.miniMessage("single.single_area_needs_name"), + Placeholder.miniMessage("command", "/plot area single ") ); 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]] [=]...") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholders.miniMessage("value", "/plot area create [world[:id]] [=]...") ); 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]] [=]...") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholders.miniMessage("value", "/plot area create [world[:id]] [=]...") ); 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]] [=]...") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholders.miniMessage("value", "/plot area create [world[:id]] [=]...") ); return false; } @@ -373,8 +374,8 @@ public class Area extends SubCommand { final Set 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]] [=]...") + TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"), + Placeholder.miniMessage("value1,", getCommandString()), + Placeholder.miniMessage("value2", " create [world[:id]] [=]...") ); 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]] [=]...") + TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"), + Placeholder.miniMessage("value1", getCommandString()), + Placeholder.miniMessage("value2", " create [world[:id]] [=]...") ); 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]] [=]...") + TranslatableCaption.miniMessage("commandconfig.command_syntax_extended"), + Placeholder.miniMessage("value1", getCommandString()), + Placeholder.miniMessage("value2", " create [world[:id]] [=]...") ); 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; } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java index 7d234a3bd..8a37095ba 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Backup.java b/Core/src/main/java/com/plotsquared/core/command/Backup.java index 88717dd8e..2c53e6426 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot backup ") ); 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")); } }) ); diff --git a/Core/src/main/java/com/plotsquared/core/command/Biome.java b/Core/src/main/java/com/plotsquared/core/command/Biome.java index 4f9baf096..6bfe01635 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Biome.java +++ b/Core/src/main/java/com/plotsquared/core/command/Biome.java @@ -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; diff --git a/Core/src/main/java/com/plotsquared/core/command/Buy.java b/Core/src/main/java/com/plotsquared/core/command/Buy.java index dae0ea42f..cca7bc9b0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Buy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java @@ -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 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); }, () -> { diff --git a/Core/src/main/java/com/plotsquared/core/command/Caps.java b/Core/src/main/java/com/plotsquared/core/command/Caps.java index b9b8487b9..f83a1356d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Caps.java +++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java @@ -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) ); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Chat.java b/Core/src/main/java/com/plotsquared/core/command/Chat.java index 0b5cc37bf..083ffa23b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Chat.java +++ b/Core/src/main/java/com/plotsquared/core/command/Chat.java @@ -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); diff --git a/Core/src/main/java/com/plotsquared/core/command/Claim.java b/Core/src/main/java/com/plotsquared/core/command/Claim.java index 4833a7ad7..20e2e9140 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -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; diff --git a/Core/src/main/java/com/plotsquared/core/command/Clear.java b/Core/src/main/java/com/plotsquared/core/command/Clear.java index 20abe1beb..7f6022051 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -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(); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Cluster.java b/Core/src/main/java/com/plotsquared/core/command/Cluster.java index 7c6d9474e..53432b825 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -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", "list, create, delete, resize, invite, kick, leave, members, info, tp, sethome" ) @@ -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 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot cluster create ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot cluster invite ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot cluster kick ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot cluster members ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot cluster members ") ); } } }); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot cluster tp ") ); 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", "list, create, delete, resize, invite, kick, leave, members, info, tp, sethome" ) diff --git a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java index 0f06fe4a1..da3d1a5ed 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java +++ b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java @@ -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(() -> { diff --git a/Core/src/main/java/com/plotsquared/core/command/Command.java b/Core/src/main/java/com/plotsquared/core/command/Command.java index d1d3b3505..9cad84528 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -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 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 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 check(T object, Caption message, Template... args) { + public 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); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java b/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java index 4249bbde6..10a6e64c5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java +++ b/Core/src/main/java/com/plotsquared/core/command/CommandCaller.java @@ -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. Will be cached if permission caching is enabled. diff --git a/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java b/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java index d3cde4d75..2aa358056 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java +++ b/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java @@ -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). */ diff --git a/Core/src/main/java/com/plotsquared/core/command/Comment.java b/Core/src/main/java/com/plotsquared/core/command/Comment.java index 63505b283..77e091d38 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Comment.java +++ b/Core/src/main/java/com/plotsquared/core/command/Comment.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Condense.java b/Core/src/main/java/com/plotsquared/core/command/Condense.java index 7bbcf6a26..304e2d4fc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -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 [radius]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot condense [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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot condense" + area + " start ") ); 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 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot condense " + area + " info ") ); 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() + " [radius]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot condense " + area.getWorldName() + " [radius]") ); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Confirm.java b/Core/src/main/java/com/plotsquared/core/command/Confirm.java index d5f91860b..b21e9b9d4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Confirm.java +++ b/Core/src/main/java/com/plotsquared/core/command/Confirm.java @@ -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); diff --git a/Core/src/main/java/com/plotsquared/core/command/Continue.java b/Core/src/main/java/com/plotsquared/core/command/Continue.java index 31cd22e2d..6ab4c53e1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Continue.java +++ b/Core/src/main/java/com/plotsquared/core/command/Continue.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Copy.java b/Core/src/main/java/com/plotsquared/core/command/Copy.java index 7fe3245c9..4ebac8918 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Copy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Copy.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot copy ") ); 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")); } }); diff --git a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java index da67d1e76..21f2ebdb1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java +++ b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java index 2554e2e87..7cc419e45 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -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 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] ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot database [area] ") ); 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] ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot database [area] ") ); - 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 [prefix]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot database import [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; } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 015386bfe..d49f3baf5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot debug ") ); } 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 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; diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java index 2525f3460..4ad4c49f8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 79cacd479..f4fc87f34 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot debugexec analyze ") ); - 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot debugexec remove-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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "Invalid syntax: /plot debugexec start-rgar ") ); 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; } } diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java index 2334c0461..e972325db 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java @@ -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); } diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java index b856c7ec5..4f4fd731f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java @@ -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) { diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java index 1745588f1..413b4dfc7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java @@ -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; diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java b/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java index 9bc8a03a8..526b46e42 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugSaveTest.java @@ -43,10 +43,10 @@ public class DebugSaveTest extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { final List 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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Delete.java b/Core/src/main/java/com/plotsquared/core/command/Delete.java index 5ff603023..5bff75e32 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.java @@ -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)) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Deny.java b/Core/src/main/java/com/plotsquared/core/command/Deny.java index 0c25a3109..ea13a8ed0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Deny.java +++ b/Core/src/main/java/com/plotsquared/core/command/Deny.java @@ -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())) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Desc.java b/Core/src/main/java/com/plotsquared/core/command/Desc.java index b42f68e5a..2374634b5 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Desc.java +++ b/Core/src/main/java/com/plotsquared/core/command/Desc.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Done.java b/Core/src/main/java/com/plotsquared/core/command/Done.java index e78ff12ad..aeb65a2f4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Done.java +++ b/Core/src/main/java/com/plotsquared/core/command/Done.java @@ -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")); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Download.java b/Core/src/main/java/com/plotsquared/core/command/Download.java index 40c6c7497..17f3cd1e1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.java @@ -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()) ); } }); diff --git a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java index 38c51b387..51bc22782 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot flag ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot flag set ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot flag add ") ); 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 [values]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot flag remove [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> 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 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot flag info ") ); 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")); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Grant.java b/Core/src/main/java/com/plotsquared/core/command/Grant.java index 3ef4ab006..c8832d074 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Grant.java +++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java @@ -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 [player]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot grant [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)) ); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Help.java b/Core/src/main/java/com/plotsquared/core/command/Help.java index 8888a3662..bff088ca2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Help.java +++ b/Core/src/main/java/com/plotsquared/core/command/Help.java @@ -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; diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java index dc10b60d1..7fd886db8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -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 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); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Inbox.java b/Core/src/main/java/com/plotsquared/core/command/Inbox.java index 682162c2f..2db25f403 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java +++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java @@ -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 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot inbox " + inbox + " delete ") ); 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot inbox " + inbox + " delete ") ); return false; } @@ -224,8 +230,8 @@ public class Inbox extends SubCommand { public void run(List 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 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; diff --git a/Core/src/main/java/com/plotsquared/core/command/Info.java b/Core/src/main/java/com/plotsquared/core/command/Info.java index 1b7196d14..44d62e443 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Info.java +++ b/Core/src/main/java/com/plotsquared/core/command/Info.java @@ -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; }; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Kick.java b/Core/src/main/java/com/plotsquared/core/command/Kick.java index e51363166..34577141e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Kick.java +++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java @@ -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> 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())) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Leave.java b/Core/src/main/java/com/plotsquared/core/command/Leave.java index 50846792d..50294571b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Leave.java +++ b/Core/src/main/java/com/plotsquared/core/command/Leave.java @@ -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 confirm, RunnableVal2 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") ); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Like.java b/Core/src/main/java/com/plotsquared/core/command/Like.java index e35c7c1ff..f70d9cdb7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -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()) ); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java index 8b9f3c5b3..1e85570a9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -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 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 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 [#]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholders.miniMessage("value", "/plot list fuzzy [#]") ); 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 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 diff --git a/Core/src/main/java/com/plotsquared/core/command/Load.java b/Core/src/main/java/com/plotsquared/core/command/Load.java index c078f5460..4ba50fda9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Load.java +++ b/Core/src/main/java/com/plotsquared/core/command/Load.java @@ -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 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot load ") ); return false; } @@ -181,7 +181,7 @@ public class Load extends SubCommand { List 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 #") ); } } diff --git a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java index 065c2fe89..16db03d4a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/MainCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/MainCommand.java @@ -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 // diff --git a/Core/src/main/java/com/plotsquared/core/command/Merge.java b/Core/src/main/java/com/plotsquared/core/command/Merge.java index 485aba3ca..8f2b7bd27 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Middle.java b/Core/src/main/java/com/plotsquared/core/command/Middle.java index 6acb04254..1fa486cf6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Middle.java +++ b/Core/src/main/java/com/plotsquared/core/command/Middle.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Move.java b/Core/src/main/java/com/plotsquared/core/command/Move.java index 85dd26fb3..62d352cfd 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -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; } }); diff --git a/Core/src/main/java/com/plotsquared/core/command/Music.java b/Core/src/main/java/com/plotsquared/core/command/Music.java index 641baeb45..6793b8b26 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -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("%s", 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)); // } diff --git a/Core/src/main/java/com/plotsquared/core/command/Near.java b/Core/src/main/java/com/plotsquared/core/command/Near.java index 7d02485ee..2581b00a3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Near.java +++ b/Core/src/main/java/com/plotsquared/core/command/Near.java @@ -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 confirm, RunnableVal2 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); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Owner.java b/Core/src/main/java/com/plotsquared/core/command/Owner.java index 668bd4e8a..af8871141 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot setowner ") ); 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)) { diff --git a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java index b062e24b3..11fd7c5f8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java @@ -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(">> " + PlotSquared .platform() .pluginName() + " (Version: )"), - Template.of("version", String.valueOf(PlotSquared.get().getVersion())) + Placeholder.miniMessage("version", String.valueOf(PlotSquared.get().getVersion())) ); player.sendMessage(StaticCaption.of( ">> Authors: Citymonstret & Empire92 & MattBDev & dordsor21 & NotMyFault & SirYwell")); @@ -56,7 +56,7 @@ public class PluginCmd extends SubCommand { ">> Discord: https://discord.gg/intellectualsites")); player.sendMessage( StaticCaption.of(">> Premium: "), - Template.of("value", String.valueOf(PremiumVerification.isPremium())) + Placeholder.miniMessage("value", String.valueOf(PremiumVerification.isPremium())) ); }); return true; diff --git a/Core/src/main/java/com/plotsquared/core/command/Purge.java b/Core/src/main/java/com/plotsquared/core/command/Purge.java index 6d43cce13..a808efb39 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -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()) ); }); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Rate.java b/Core/src/main/java/com/plotsquared/core/command/Rate.java index 86e14fe71..8eedc3e50 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -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()) ); } }; diff --git a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java index d9b6356f6..ec92707b6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java +++ b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java @@ -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 [height]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot regenallroads [height]") ); return false; } } else if (args.length != 1) { player.sendMessage( - TranslatableCaption.of("commandconfig.command_syntax"), - Template.of("value", "/plot regenallroads [height]") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot regenallroads [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; diff --git a/Core/src/main/java/com/plotsquared/core/command/Reload.java b/Core/src/main/java/com/plotsquared/core/command/Reload.java index d0abf1665..e35d1ef6a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Reload.java +++ b/Core/src/main/java/com/plotsquared/core/command/Reload.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Remove.java b/Core/src/main/java/com/plotsquared/core/command/Remove.java index b671eab06..864de95cc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Remove.java +++ b/Core/src/main/java/com/plotsquared/core/command/Remove.java @@ -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 + "") ); } }); diff --git a/Core/src/main/java/com/plotsquared/core/command/RequiredType.java b/Core/src/main/java/com/plotsquared/core/command/RequiredType.java index ad2057acc..46e359c0d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/RequiredType.java +++ b/Core/src/main/java/com/plotsquared/core/command/RequiredType.java @@ -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; diff --git a/Core/src/main/java/com/plotsquared/core/command/Save.java b/Core/src/main/java/com/plotsquared/core/command/Save.java index 883893f50..f75201c38 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -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> schematicAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) { diff --git a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java index 594ae0ad5..0d8676521 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "Use /plot schematic exportall ") ); 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 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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "Use /plot sch exportall ") ); 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 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; diff --git a/Core/src/main/java/com/plotsquared/core/command/Set.java b/Core/src/main/java/com/plotsquared/core/command/Set.java index 9148b6418..4f67a2fd3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -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 diff --git a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java index 3ea7868ce..81a8fd54e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java @@ -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; } } diff --git a/Core/src/main/java/com/plotsquared/core/command/SetHome.java b/Core/src/main/java/com/plotsquared/core/command/SetHome.java index de6ce5df9..8ea0e50cf 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetHome.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetHome.java @@ -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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Setup.java b/Core/src/main/java/com/plotsquared/core/command/Setup.java index 41267bf2f..4ea23943b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Setup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Setup.java @@ -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> entry : SetupUtils.generators.entrySet()) { if (entry.getKey().equals(PlotSquared.platform().pluginName())) { message.append("\n - ").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) { diff --git a/Core/src/main/java/com/plotsquared/core/command/Swap.java b/Core/src/main/java/com/plotsquared/core/command/Swap.java index 3003226ec..99d93b9d9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Swap.java +++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java @@ -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; } }); diff --git a/Core/src/main/java/com/plotsquared/core/command/Target.java b/Core/src/main/java/com/plotsquared/core/command/Target.java index fc0f7a35a..2d56b3493 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Target.java +++ b/Core/src/main/java/com/plotsquared/core/command/Target.java @@ -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 < | nearest>") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot target < | 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; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Template.java b/Core/src/main/java/com/plotsquared/core/command/Template.java index f4e7a7017..c855b2992 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -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 ") + TranslatableCaption.miniMessage("commandconfig.command_syntax"), + Placeholder.miniMessage("value", "/plot template export ") ); 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