diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 3837a4c3b..1715f3b95 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -34,6 +34,7 @@ import com.plotsquared.bukkit.util.UpdateUtility; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.listener.PlayerBlockEventType; import com.plotsquared.core.listener.PlotListener; @@ -99,7 +100,6 @@ import com.plotsquared.core.plot.flag.implementations.VehicleUseFlag; import com.plotsquared.core.plot.flag.implementations.VillagerInteractFlag; import com.plotsquared.core.plot.flag.implementations.VineGrowFlag; import com.plotsquared.core.plot.flag.types.BlockTypeWrapper; -import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.EntityUtil; import com.plotsquared.core.util.EventDispatcher; @@ -115,6 +115,7 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BlockType; import io.papermc.lib.PaperLib; +import net.kyori.adventure.text.minimessage.Template; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.FluidCollisionMode; @@ -653,7 +654,7 @@ import java.util.regex.Pattern; perm = "plots.admin.command.blocked-cmds.road"; } if (!Permissions.hasPermission(plotPlayer, perm)) { - MainUtil.sendMessage(plotPlayer, Captions.COMMAND_BLOCKED); + plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked")); event.setCancelled(true); } return; @@ -753,8 +754,10 @@ import java.util.regex.Pattern; // this is acceptable, because otherwise it wouldn't make sense to have both flags set if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous() .equals(BukkitUtil.adaptComplete(to)))) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_ENTRY_DENIED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.entry.denied") + ); event.setCancelled(true); } } @@ -842,7 +845,7 @@ import java.util.regex.Pattern; BukkitPlayer pp = BukkitUtil.adapt(player); // Cancel teleport if (TaskManager.removeFromTeleportQueue(pp.getName())) { - MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED); + pp.sendMessage(TranslatableCaption.of("teleport.teleport_failed")); } // Set last location Location location = BukkitUtil.adapt(to); @@ -857,8 +860,10 @@ import java.util.regex.Pattern; if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !pp .getMeta("kick", false)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_EXIT_DENIED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.exit.denied") + ); this.tmpTeleport = false; if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) { player.teleport(from); @@ -872,8 +877,10 @@ import java.util.regex.Pattern; } else if (now.equals(lastPlot)) { ForceFieldListener.handleForcefield(player, pp, now); } else if (!plotEntry(pp, now) && this.tmpTeleport) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_ENTRY_DENIED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.entry.denied") + ); this.tmpTeleport = false; to.setX(from.getBlockX()); to.setY(from.getBlockY()); @@ -888,14 +895,14 @@ import java.util.regex.Pattern; this.tmpTeleport = false; player.teleport(event.getTo()); this.tmpTeleport = true; - MainUtil.sendMessage(pp, Captions.BORDER); + pp.sendMessage(TranslatableCaption.of("border.border")); } if (x2 < -border && this.tmpTeleport) { to.setX(-border + 1); this.tmpTeleport = false; player.teleport(event.getTo()); this.tmpTeleport = true; - MainUtil.sendMessage(pp, Captions.BORDER); + pp.sendMessage(TranslatableCaption.of("border.border")); } } int z2; @@ -904,7 +911,7 @@ import java.util.regex.Pattern; BukkitPlayer pp = BukkitUtil.adapt(player); // Cancel teleport if (TaskManager.removeFromTeleportQueue(pp.getName())) { - MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED); + pp.sendMessage(TranslatableCaption.of("teleport.teleport_failed")); } // Set last location Location location = BukkitUtil.adapt(to); @@ -919,8 +926,10 @@ import java.util.regex.Pattern; if (now == null) { if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport && !pp .getMeta("kick", false)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_EXIT_DENIED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.exit.denied") + ); this.tmpTeleport = false; if (lastPlot.equals(BukkitUtil.adapt(from).getPlot())) { player.teleport(from); @@ -934,8 +943,10 @@ import java.util.regex.Pattern; } else if (now.equals(lastPlot)) { ForceFieldListener.handleForcefield(player, pp, now); } else if (!plotEntry(pp, now) && this.tmpTeleport) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_ENTRY_DENIED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.entry.denied") + ); this.tmpTeleport = false; player.teleport(from); to.setX(from.getBlockX()); @@ -951,13 +962,13 @@ import java.util.regex.Pattern; this.tmpTeleport = false; player.teleport(event.getTo()); this.tmpTeleport = true; - MainUtil.sendMessage(pp, Captions.BORDER); + pp.sendMessage(TranslatableCaption.of("border.border")); } else if (z2 < -border && this.tmpTeleport) { to.setZ(-border + 1); this.tmpTeleport = false; player.teleport(event.getTo()); this.tmpTeleport = true; - MainUtil.sendMessage(pp, Captions.BORDER); + pp.sendMessage(TranslatableCaption.of("border.border")); } } } @@ -1037,8 +1048,10 @@ import java.util.regex.Pattern; if (event.getBlock().getY() == 0) { if (!Permissions .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.groundlevel") + ); event.setCancelled(true); return; } @@ -1046,8 +1059,10 @@ import java.util.regex.Pattern; .getMinBuildHeight()) && !Permissions .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { event.setCancelled(true); - MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated() - .replace("{limit}", String.valueOf(area.getMaxBuildHeight()))); + plotPlayer.sendMessage( + TranslatableCaption.of("height.height_limit"), + Template.of("limit", String.valueOf(area.getMaxBuildHeight())) + ); } if (!plot.hasOwner()) { if (!Permissions @@ -1069,13 +1084,17 @@ import java.util.regex.Pattern; .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { return; } - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_OTHER); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.other") + ); event.setCancelled(true); } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); return; } @@ -1092,8 +1111,10 @@ import java.util.regex.Pattern; return; } } - MainUtil - .sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.road") + ); event.setCancelled(true); } @@ -1839,21 +1860,28 @@ import java.util.regex.Pattern; boolean cancelled = false; if (plot == null) { if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.road") + ); cancelled = true; } } else if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { - MainUtil - .sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.unowned"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.unowned") + ); cancelled = true; } } else { UUID uuid = pp.getUUID(); if (!plot.isAdded(uuid)) { if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - "plots.admin.interact.other"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.other") + ); cancelled = true; } } @@ -1900,22 +1928,29 @@ import java.util.regex.Pattern; if (plot == null) { if (!area.isRoadFlags() && !area.getRoadFlag(MiscInteractFlag.class) && !Permissions .hasPermission(pp, "plots.admin.interact.road")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.road"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.road") + ); e.setCancelled(true); } } else { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); e.setCancelled(true); return; } } if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - "plots.admin.interact.unowned"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.unowned") + ); e.setCancelled(true); } } else { @@ -1927,11 +1962,13 @@ import java.util.regex.Pattern; return; } if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - "plots.admin.interact.other"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.other") + ); e.setCancelled(true); plot.debug(pp.getName() + " could not interact with " + entity.getType() - + " bcause misc-interact = false"); + + " because misc-interact = false"); } } } @@ -2292,20 +2329,26 @@ import java.util.regex.Pattern; BukkitPlayer pp = BukkitUtil.adapt(player); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.road") + ); event.setCancelled(true); } } else if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_UNOWNED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.unowned") + ); event.setCancelled(true); } } else if (!plot.isAdded(pp.getUUID())) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } } else if (!plot.getFlag(BlockIgnitionFlag.class)) { @@ -2372,15 +2415,19 @@ import java.util.regex.Pattern; if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { return; } - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.road") + ); event.setCancelled(true); } else if (!plot.hasOwner()) { if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) { return; } - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_UNOWNED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.unowned") + ); event.setCancelled(true); } else if (!plot.isAdded(pp.getUUID())) { List use = plot.getFlag(UseFlag.class); @@ -2393,13 +2440,17 @@ import java.util.regex.Pattern; if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { return; } - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } } @@ -2437,15 +2488,19 @@ import java.util.regex.Pattern; if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { return; } - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_ROAD); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.road") + ); event.setCancelled(true); } else if (!plot.hasOwner()) { if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) { return; } - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_UNOWNED); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.unowned") + ); event.setCancelled(true); } else if (!plot.isAdded(plotPlayer.getUUID())) { List use = plot.getFlag(UseFlag.class); @@ -2459,13 +2514,17 @@ import java.util.regex.Pattern; if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { return; } - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } } @@ -2507,15 +2566,19 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.road") + ); event.setCancelled(true); } } else { if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_UNOWNED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.unwoned") + ); event.setCancelled(true); } return; @@ -2523,8 +2586,10 @@ import java.util.regex.Pattern; if (!plot.isAdded(pp.getUUID())) { if (!plot.getFlag(HangingPlaceFlag.class)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } return; @@ -2551,14 +2616,18 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.road") + ); event.setCancelled(true); } } else if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_UNOWNED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.unowned") + ); event.setCancelled(true); } } else if (!plot.isAdded(pp.getUUID())) { @@ -2566,8 +2635,10 @@ import java.util.regex.Pattern; return; } if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.other") + ); event.setCancelled(true); plot.debug(p.getName() + " could not break hanging entity because hanging-break = false"); @@ -2588,16 +2659,20 @@ import java.util.regex.Pattern; if (!plot.hasOwner()) { if (!Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_UNOWNED); + player.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.unowned") + ); event.setCancelled(true); } } else if (!plot.isAdded(player.getUUID())) { if (!plot.getFlag(HangingBreakFlag.class)) { if (!Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_DESTROY_OTHER); + player.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy.other") + ); event.setCancelled(true); plot.debug(player.getName() + " could not break hanging entity because hanging-break = false"); @@ -2623,14 +2698,18 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot == null && !area.isRoadFlags()) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_ROAD)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_INTERACT_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.road") + ); event.setCancelled(true); } } else if (plot != null && !plot.hasOwner()) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_UNOWNED)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_INTERACT_UNOWNED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.unowned") + ); event.setCancelled(true); } } else if ((plot != null && !plot.isAdded(pp.getUUID())) || (plot == null && area @@ -2685,8 +2764,10 @@ import java.util.regex.Pattern; } if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_INTERACT_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.interact.other") + ); event.setCancelled(true); } } @@ -2706,15 +2787,19 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - "plots.admin.vehicle.break.road"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.vehicle.break.road") + ); event.setCancelled(true); } } else { if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - "plots.admin.vehicle.break.unowned"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.vehicle.break.unowned") + ); event.setCancelled(true); return; } @@ -2725,8 +2810,10 @@ import java.util.regex.Pattern; return; } if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - "plots.admin.vehicle.break.other"); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.vehicle.break.other") + ); event.setCancelled(true); plot.debug(pp.getName() + " could not break vehicle because vehicle-break = false"); @@ -2908,16 +2995,20 @@ import java.util.regex.Pattern; if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); return false; } } return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.destroy." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy." + stub) + ); return false; } } else if (victim.getType() == EntityType.ARMOR_STAND) { @@ -2926,8 +3017,10 @@ import java.util.regex.Pattern; return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.destroy." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.destroy." + stub) + ); if (plot != null) { plot.debug(player.getName() + " could not break armor stand because misc-break = false"); @@ -2945,8 +3038,10 @@ import java.util.regex.Pattern; return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.pve." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.pve." + stub) + ); if (plot != null) { plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR hostile-attack = false"); @@ -2964,11 +3059,13 @@ import java.util.regex.Pattern; return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.pve." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.pve." + stub) + ); if (plot != null) { plot.debug(player.getName() + " could not attack " + entityType - + " because pve = false OR tamned-attack = false"); + + " because pve = false OR tamed-attack = false"); } return false; } @@ -2976,8 +3073,10 @@ import java.util.regex.Pattern; if (isPlot) { if (!plot.getFlag(PvpFlag.class) && !Permissions .hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.pvp." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.pvp." + stub) + ); plot.debug(player.getName() + " could not attack " + entityType + " because pve = false"); return false; @@ -2988,8 +3087,10 @@ import java.util.regex.Pattern; return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.pvp." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.pvp." + stub) + ); return false; } } else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal @@ -3003,8 +3104,10 @@ import java.util.regex.Pattern; } else if (roadFlags && (area.getRoadFlag(AnimalAttackFlag.class) || area .getFlag(PveFlag.class))) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.pve." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.pve." + stub) + ); return false; } } @@ -3020,8 +3123,10 @@ import java.util.regex.Pattern; return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.pve." + stub); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.pve." + stub) + ); if (plot != null) { plot.debug(player.getName() + " could not attack " + entityType + " because pve = false"); @@ -3060,20 +3165,26 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot == null) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.projectile.road"); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.projectile.road") + ); event.setHatching(false); } } else if (!plot.hasOwner()) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.projectile.unowned"); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.projective.unowned") + ); event.setHatching(false); } } else if (!plot.isAdded(plotPlayer.getUUID())) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) { - MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, - "plots.admin.projectile.other"); + plotPlayer.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.projectile.other") + ); event.setHatching(false); } } @@ -3094,13 +3205,17 @@ import java.util.regex.Pattern; .getMinBuildHeight()) && !Permissions .hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { event.setCancelled(true); - MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated() - .replace("{limit}", String.valueOf(area.getMaxBuildHeight()))); + pp.sendMessage( + TranslatableCaption.of("height.height_limit"), + Template.of("limit", String.valueOf(area.getMaxBuildHeight())) + ); } if (!plot.hasOwner()) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_UNOWNED); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); return; } @@ -3114,8 +3229,10 @@ import java.util.regex.Pattern; } } if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); plot.debug(player.getName() + " could not place " + event.getBlock().getType() + " because of the place flag"); @@ -3123,8 +3240,10 @@ import java.util.regex.Pattern; } } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_OTHER); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); return; } @@ -3138,8 +3257,10 @@ import java.util.regex.Pattern; } } } else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) { - MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, - Captions.PERMISSION_ADMIN_BUILD_ROAD); + pp.sendMessage( + TranslatableCaption.of("permission.no_permission_event"), + Template.of("node", "plots.admin.build.other") + ); event.setCancelled(true); } } 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 cb81cfd6f..86c3cad2d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Alias.java +++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java @@ -45,7 +45,7 @@ import java.util.concurrent.TimeoutException; @CommandDeclaration(command = "alias", permission = "plots.alias", description = "Set the plot name", - usage = "/plot alias ", + usage = "/plot alias ", aliases = {"setalias", "sa", "name", "rename", "setname", "seta", "nameplot"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) @@ -96,7 +96,7 @@ public class Alias extends SubCommand { return true; } else { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ALIAS_SET.getTranslated())); + Template.of("node", "plots.alias.set")); } break; @@ -111,7 +111,7 @@ public class Alias extends SubCommand { result = removeAlias(player, plot); } else { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ALIAS_REMOVE.getTranslated())); + Template.of("node", "plots.alias.remove")); } break; default: @@ -168,7 +168,7 @@ public class Alias extends SubCommand { private boolean removeAlias(PlotPlayer player, Plot plot) { plot.setAlias(null); player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ALIAS_REMOVE.getTranslated())); + Template.of("node", "plots.alias.remove")); return true; } 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 995ddba32..6c7e4369c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Area.java +++ b/Core/src/main/java/com/plotsquared/core/command/Area.java @@ -58,7 +58,6 @@ import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.RunnableVal; -import com.plotsquared.core.util.task.RunnableVal3; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.WorldEdit; @@ -72,7 +71,6 @@ import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; -import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -91,7 +89,7 @@ import java.util.Set; requiredType = RequiredType.NONE, description = "Create a new PlotArea", aliases = "world", - usage = "/plot area ", + usage = "/plot area ", confirmation = true) public class Area extends SubCommand { @@ -130,9 +128,9 @@ public class Area extends SubCommand { player.sendMessage(RequiredType.CONSOLE.getErrorMessage()); return false; } - if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_CREATE)) { + if (!Permissions.hasPermission(player, "plots.area.create")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_CREATE.getTranslated())); + Template.of("node", "plots.area.create")); return false; } if (args.length < 2) { @@ -245,8 +243,10 @@ public class Area extends SubCommand { PlotSquared.get().loadWorld(world, null); player.sendMessage(TranslatableCaption.of("single.single_area_created")); } else { - player.sendMessage(TranslatableCaption.of("errors.error_create"), - Template.of("world", hybridPlotWorld.getWorldName())); + player.sendMessage( + TranslatableCaption.of("errors.error_create"), + Template.of("world", hybridPlotWorld.getWorldName()) + ); } }; singleRun.run(); @@ -254,9 +254,9 @@ public class Area extends SubCommand { case "c": case "setup": case "create": - if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_CREATE)) { + if (!Permissions.hasPermission(player, "plots.area.create")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_CREATE.getTranslated())); + Template.of("node", "plots.area.create")); return false; } switch (args.length) { @@ -498,8 +498,7 @@ public class Area extends SubCommand { if (pa.getId() == null) { player.sendMessage( TranslatableCaption.of("commandconfig.command_syntax"), - Template.of("value", getCommandString + ) - ); + Template.of("value", getUsage())); player.sendMessage( TranslatableCaption.of("commandconfig.command_syntax_extended"), Template.of("value1", getCommandString()), @@ -529,9 +528,9 @@ public class Area extends SubCommand { return true; case "i": case "info": { - if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_INFO)) { + if (!Permissions.hasPermission(player, "plots.area.info")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_INFO.getTranslated())); + Template.of("node", "plots.area.info")); return false; } PlotArea area; @@ -589,9 +588,9 @@ public class Area extends SubCommand { } case "l": case "list": - if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_LIST)) { + if (!Permissions.hasPermission(player, "plots.area.list")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_LIST.getTranslated())); + Template.of("node", "plots.area.list")); return false; } int page; @@ -658,9 +657,9 @@ public class Area extends SubCommand { case "clear": case "reset": case "regenerate": { - if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_REGEN)) { + if (!Permissions.hasPermission(player, "plots.area.regen")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_REGEN.getTranslated())); + Template.of("node", "plots.area.regen")); return false; } final PlotArea area = player.getApplicablePlotArea(); @@ -684,8 +683,7 @@ public class Area extends SubCommand { .generate(null, area.getWorldName(), value.getX(), value.getZ(), null); } - }, () -> player.sendMessage( - TranslatableCaption.of("single.regeneration_complete")) + }, () -> player.sendMessage(TranslatableCaption.of("single.regeneration_complete")) ); return true; } @@ -694,9 +692,9 @@ public class Area extends SubCommand { case "teleport": case "visit": case "tp": - if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_TP)) { + if (!Permissions.hasPermission(player, "plots.area.tp")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_TP.getTranslated())); + Template.of("node", "plots.area.tp")); return false; } if (args.length != 2) { @@ -728,9 +726,7 @@ public class Area extends SubCommand { return true; case "delete": case "remove": - player.sendMessage( - TranslatableCaption.of("single.worldcreation_location") - ); + player.sendMessage(TranslatableCaption.of("single.worldcreation_location")); return true; } sendUsage(player); 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 e822b90c9..f9dd3ab2c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -29,7 +29,6 @@ import com.google.common.collect.Lists; import com.google.common.primitives.Ints; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.CaptionUtility; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; @@ -221,9 +220,7 @@ public class Auto extends SubCommand { return true; } if (size_x < 1 || size_z < 1) { - player.sendMessage( - TranslatableCaption.of("error.plot_size") - ); + player.sendMessage(TranslatableCaption.of("error.plot_size")); } if (args.length > 1) { schematic = args[1]; @@ -250,9 +247,9 @@ public class Auto extends SubCommand { size_x = event.getSize_x(); size_z = event.getSize_z(); schematic = event.getSchematic(); - if (!force && mega && !Permissions.hasPermission(player, Captions.PERMISSION_AUTO_MEGA)) { + if (!force && mega && !Permissions.hasPermission(player, "plots.auto.mega")) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AUTO_MEGA.getTranslated())); + Template.of("node", "plots.auto.mega")); } if (!force && size_x * size_z > Settings.Claim.MAX_AUTO_AREA) { player.sendMessage(TranslatableCaption.of("permission.cant_claim_more_plots_num"), @@ -277,10 +274,10 @@ public class Auto extends SubCommand { if (!force && !Permissions.hasPermission(player, CaptionUtility .format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { + .hasPermission(player, "plots.admin.command.schematic")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated()) + Template.of("node", "plots.claim.%s0") ); return true; } @@ -336,8 +333,9 @@ public class Auto extends SubCommand { .callAutoMerge(plotarea.getPlotAbs(pos1), plotIds); if (!force && mergeEvent.getEventResult() == Result.DENY) { player.sendMessage( - TranslatableCaption.of("events.event_denied"), - Template.of("value", "Auto merge")); + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Auto merge") + ); return false; } if (!plotarea.mergePlots(mergeEvent.getPlots(), true)) { 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 634eb0579..ec65364b8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -57,7 +57,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; @CommandDeclaration(command = "backup", - usage = "/plot backup ", + usage = "/plot backup ", description = "Manage plot backups", category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER, @@ -72,7 +72,10 @@ public final class Backup extends Command { } private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) { - message.send(player, args); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot backup ") + ); return true; } @@ -142,10 +145,10 @@ public final class Backup extends Command { Template.of("plot", "generic.generic_merged") ); } else if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) { + .hasPermission(player, "plots.admin.backup.other")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ADMIN_BACKUP_OTHER.getTranslated()) + Template.of("node", "plots.admin.backup.other") ); } else { final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot)); @@ -157,7 +160,10 @@ public final class Backup extends Command { } else { backupProfile.createBackup().whenComplete((backup, throwable) -> { if (throwable != null) { - sendMessage(player, Captions.BACKUP_SAVE_FAILED, throwable.getMessage()); + player.sendMessage( + TranslatableCaption.of("backups.backup_save_failed"), + Template.of("reason", throwable.getMessage()) + ); throwable.printStackTrace(); } else { player.sendMessage(TranslatableCaption.of("backups.backup_save_success")); @@ -190,10 +196,10 @@ public final class Backup extends Command { Template.of("plot", "generic.generic_merged") ); } else if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) { + .hasPermission(player, "plots.admin.backup.other")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ADMIN_BACKUP_OTHER.getTranslated()) + Template.of("node", "plots.admin.backup.other") ); } else { final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot)); @@ -261,10 +267,10 @@ public final class Backup extends Command { Template.of("plot", "generic.generic_merged") ); } else if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) { + .hasPermission(player, "plots.admin.backup.other")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ADMIN_BACKUP_OTHER.getTranslated()) + Template.of("node", "plots.admin.backup.other") ); } else if (args.length == 0) { player.sendMessage( 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 3b191e291..6d0f1b055 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Biome.java +++ b/Core/src/main/java/com/plotsquared/core/command/Biome.java @@ -72,7 +72,8 @@ public class Biome extends SetCommand { plot.removeRunning(); player.sendMessage( TranslatableCaption.of("biome.biome_set_to"), - Template.of("value", value.toLowerCase())); + Template.of("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 bdc5cff70..612f9f499 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Buy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java @@ -96,7 +96,8 @@ public class Buy extends Command { confirm.run(this, () -> { player.sendMessage( TranslatableCaption.of("economy.removed_balance"), - Template.of("money", String.valueOf(price))); + Template.of("money", String.valueOf(price)) + ); this.econHandler.depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price); 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 e90f19917..8ca91b89d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Caps.java +++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java @@ -59,10 +59,10 @@ public class Caps extends SubCommand { return false; } if (!plot.isAdded(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_CAPS_OTHER)) { + .hasPermission(player, "plots.admin.caps.other")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_ADMIN_CAPS_OTHER.getTranslated())); + Template.of("node", "plots.admin.caps.other")); return false; } player.sendMessage(TranslatableCaption.of("info.plot_caps_header")); @@ -82,7 +82,8 @@ public class Caps extends SubCommand { final int current = countedEntities[type]; final int max = plot.getFlag(capFlag); final String percentage = String.format("%.1f", 100 * ((float) current / max)); - player.sendMessage(TranslatableCaption.of("info.plot_caps_format"), + player.sendMessage( + TranslatableCaption.of("info.plot_caps_format"), Template.of("cap", name), Template.of("current", String.valueOf(current)), Template.of("limit", String.valueOf(max)), 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 d5b1c3501..dece94348 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -52,7 +52,13 @@ import org.slf4j.LoggerFactory; import javax.annotation.Nonnull; import javax.annotation.Nullable; -@CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER, permission = "plots.claim", usage = "/plot claim") +@CommandDeclaration( + command = "claim", + aliases = "c", + description = "Claim the current plot you're standing on", + category = CommandCategory.CLAIMING, + requiredType = RequiredType.PLAYER, permission = "plots.claim", + usage = "/plot claim") public class Claim extends SubCommand { private static final Logger logger = @@ -118,7 +124,7 @@ public class Claim extends SubCommand { if (!Permissions.hasPermission(player, CaptionUtility .format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC) && !force) { + .hasPermission(player, "plots.admin.command.schematic") && !force) { player.sendMessage( TranslatableCaption.of("permission.no_schematic_permission"), Template.of("value", schematic) @@ -174,8 +180,9 @@ public class Claim extends SubCommand { .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.of("events.event_denied"), + Template.of("value", "Auto merge on claim") + ); } else { plot.autoMerge(mergeEvent.getDir(), mergeEvent.getMax(), player.getUUID(), 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 ba5e2d598..57f03b452 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -85,11 +85,11 @@ public class Clear extends Command { } boolean force = eventResult == Result.FORCE; checkTrue(force || plot.isOwner(player.getUUID()) || Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR), + .hasPermission(player, "plots.admin.command.clear"), Captions.NO_PLOT_PERMS); checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER); checkTrue(force || !Settings.Done.RESTRICT_BUILDING || !DoneFlag.isDone(plot) || Permissions - .hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE); + .hasPermission(player, "plots.continue"), Captions.DONE_ALREADY_DONE); confirm.run(this, () -> { BackupManager.backup(player, plot, () -> { final long start = System.currentTimeMillis(); 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 0663d1b29..8add7dc08 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Cluster.java +++ b/Core/src/main/java/com/plotsquared/core/command/Cluster.java @@ -28,6 +28,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.events.TeleportCause; @@ -40,7 +41,6 @@ import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.query.PlotQuery; -import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.minimessage.Template; import java.util.HashSet; @@ -68,10 +68,10 @@ public class Cluster extends SubCommand { switch (sub) { case "l": case "list": { - if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_LIST)) { + if (!Permissions.hasPermission(player, "plots.cluster.list")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_LIST.getTranslated()) + Template.of("node", "plots.cluster.list") ); return false; } @@ -121,10 +121,10 @@ public class Cluster extends SubCommand { } case "c": case "create": { - if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_CREATE)) { + if (!Permissions.hasPermission(player, "plots.cluster.create")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_CREATE.getTranslated()) + Template.of("node", "plots.cluster.create") ); return false; } @@ -180,20 +180,20 @@ public class Cluster extends SubCommand { if (!area.contains(pos1) || !area.contains(pos2)) { player.sendMessage( TranslatableCaption.of("cluster.cluster_outside"), - Template.of("area", area) + Template.of("area", String.valueOf(area)) ); return false; } Set plots = area.getPlotSelectionOwned(pos1, pos2); if (!plots.isEmpty()) { if (!Permissions - .hasPermission(player, Captions.PERMISSION_CLUSTER_CREATE_OTHER)) { + .hasPermission(player, "plots.cluster.create.other")) { UUID uuid = player.getUUID(); for (Plot plot : plots) { if (!plot.isOwner(uuid)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_CREATE_OTHER.getTranslated()) + Template.of("node", "plots.cluster.create.other") ); return false; } @@ -214,7 +214,7 @@ public class Cluster extends SubCommand { if (current + cluster.getArea() > allowed) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_SIZE.getTranslated() + "." + (current + cluster.getArea())) + Template.of("node", "plots.cluster.size" + "." + (current + cluster.getArea())) ); return false; } @@ -240,7 +240,7 @@ public class Cluster extends SubCommand { if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_DELETE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_DELETE.getTranslated()) + Template.of("node", "plots.cluster.delete") ); return false; } @@ -278,7 +278,7 @@ public class Cluster extends SubCommand { .hasPermission(player, Captions.PERMISSION_CLUSTER_DELETE_OTHER)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_DELETE_OTHER.getTranslated())); + Template.of("node", "plots.cluster.delete.other")); return false; } } @@ -291,7 +291,7 @@ public class Cluster extends SubCommand { if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE.getTranslated())); + Template.of("node", "plots.cluster.resize")); return false; } if (args.length != 3) { @@ -323,15 +323,15 @@ public class Cluster extends SubCommand { } PlotCluster cluster = area.getCluster(player.getLocation()); if (cluster == null) { - player.sendMessage(TranslatableCaption.of("errors.not_in_pcluster")); + player.sendMessage(TranslatableCaption.of("errors.not_in_cluster")); return false; } if (!cluster.hasHelperRights(player.getUUID())) { if (!Permissions .hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_OTHER)) { player.sendMessage( - TranslatableCaption.of("permission.no_permission") - Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE_OTHER.getTranslated())); + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.cluster.resize.other")); return false; } } @@ -356,7 +356,7 @@ public class Cluster extends SubCommand { .hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_SHRINK)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE_SHRINK.getTranslated()) + Template.of("node", "plots.cluster.resize.shrink") ); return false; } @@ -367,7 +367,7 @@ public class Cluster extends SubCommand { .hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_EXPAND)) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE_EXPAND.getTranslated()) + Template.of("node", "plots.cluster.resize.expand") ); return false; } @@ -385,23 +385,22 @@ public class Cluster extends SubCommand { if (current + cluster.getArea() > allowed) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER.getTranslated() + "." + (current + cluster - .getArea())) + Template.of("node", "plots.cluster" + "." + (current + cluster.getArea())) ); return false; } // resize cluster DBFunc.resizeCluster(cluster, pos1, pos2); - player.sendMessage(TranslatableCaption.of("cluster.clister_resized")); + player.sendMessage(TranslatableCaption.of("cluster.cluster_resized")); return true; } case "add": case "inv": case "invite": { - if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_INVITE)) { + if (!Permissions.hasPermission(player, "plots.cluster.invite")) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_CLUSTER_INVITE.getTranslated()) + Template.of("node", "plots.cluster.invite") ); return false; } @@ -766,7 +765,7 @@ public class Cluster extends SubCommand { message = message.replaceAll("%name%", name); message = message.replaceAll("%size%", size); message = message.replaceAll("%rights%", rights); - MainUtil.sendMessage(player, message); + player.sendMessage(StaticCaption.of(message)); } }); return true; 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 d608b19d7..825fb7714 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Command.java +++ b/Core/src/main/java/com/plotsquared/core/command/Command.java @@ -240,7 +240,7 @@ public abstract class Command { // Send the header header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "") .replaceAll("%amount%", c.size() + "").replaceAll("%word%", "all"); - MainUtil.sendMessage(player, header); + player.sendMessage(StaticCaption.of(header)); // Send the page content List subList = c.subList(page * size, max); int i = page * size; 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 5df126945..f55736c30 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java +++ b/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java @@ -28,6 +28,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.LocaleHolder; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import javax.annotation.Nonnull; @@ -39,42 +40,42 @@ public enum CommandCategory implements Caption { * Claiming CommandConfig. * Such as: /plot claim */ - CLAIMING(Captions.COMMAND_CATEGORY_CLAIMING), + CLAIMING(TranslatableCaption.of("category.command_category_claiming")), /** * Teleportation CommandConfig. * Such as: /plot visit */ - TELEPORT(Captions.COMMAND_CATEGORY_TELEPORT), + TELEPORT(TranslatableCaption.of("category.command_category_teleport")), /** * Protection. */ - SETTINGS(Captions.COMMAND_CATEGORY_SETTINGS), + SETTINGS(TranslatableCaption.of("category.command_category_settings")), /** * Chat. */ - CHAT(Captions.COMMAND_CATEGORY_CHAT), + CHAT(TranslatableCaption.of("category.command_category_chat")), /** * Web. */ - SCHEMATIC(Captions.COMMAND_CATEGORY_SCHEMATIC), + SCHEMATIC(TranslatableCaption.of("category.command_category_schematic")), /** * Cosmetic. */ - APPEARANCE(Captions.COMMAND_CATEGORY_APPEARANCE), + APPEARANCE(TranslatableCaption.of("category.command_category_appearance")), /** * Information CommandConfig. * Such as: /plot info */ - INFO(Captions.COMMAND_CATEGORY_INFO), + INFO(TranslatableCaption.of("category.command_category_info")), /** * Debug CommandConfig. * Such as: /plot debug */ - DEBUG(Captions.COMMAND_CATEGORY_DEBUG), + DEBUG(TranslatableCaption.of("category.command_category_debug")), /** * Administration commands. */ - ADMINISTRATION(Captions.COMMAND_CATEGORY_ADMINISTRATION); + ADMINISTRATION(TranslatableCaption.of("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 96522a624..457483d7c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Comment.java +++ b/Core/src/main/java/com/plotsquared/core/command/Comment.java @@ -26,13 +26,15 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.StaticCaption; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; 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 java.util.Arrays; import java.util.Locale; @@ -47,8 +49,10 @@ public class Comment extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String[] args) { if (args.length < 2) { - sendMessage(player, Captions.COMMENT_SYNTAX, - StringMan.join(CommentManager.inboxes.keySet(), "|")); + player.sendMessage( + TranslatableCaption.of("comment.comment_syntax"), + Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) + ); return false; } @@ -64,8 +68,10 @@ public class Comment extends SubCommand { plot = player.getLocation().getPlotAbs(); } else { if (args.length < 3) { - sendMessage(player, Captions.COMMENT_SYNTAX, - StringMan.join(CommentManager.inboxes.keySet(), "|")); + player.sendMessage( + TranslatableCaption.of("comment.comment_syntax"), + Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) + ); return false; } index = 2; @@ -73,13 +79,15 @@ public class Comment extends SubCommand { CommentInbox inbox = CommentManager.inboxes.get(args[index - 1].toLowerCase()); if (inbox == null) { - sendMessage(player, Captions.COMMENT_SYNTAX, - StringMan.join(CommentManager.inboxes.keySet(), "|")); + player.sendMessage( + TranslatableCaption.of("comment.comment_syntax"), + Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) + ); return false; } if (!inbox.canWrite(plot, player)) { - sendMessage(player, Captions.NO_PERM_INBOX, ""); + player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox")); return false; } @@ -89,19 +97,21 @@ public class Comment extends SubCommand { player.getName(), inbox.toString(), System.currentTimeMillis()); boolean result = inbox.addComment(plot, comment); if (!result) { - sendMessage(player, Captions.NO_PLOT_INBOX, ""); - sendMessage(player, Captions.COMMENT_SYNTAX, - StringMan.join(CommentManager.inboxes.keySet(), "|")); + player.sendMessage(TranslatableCaption.of("comment.no_plot_inbox")); + player.sendMessage( + TranslatableCaption.of("comment.comment_syntax"), + Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), "|")) + ); return false; } for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) { if (pp.getAttribute("chatspy")) { - MainUtil.sendMessage(pp, "/plot comment " + StringMan.join(args, " ")); + pp.sendMessage(StaticCaption.of("/plot comment " + StringMan.join(args, " "))); } } - sendMessage(player, Captions.COMMENT_ADDED); + player.sendMessage(TranslatableCaption.of("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 f76469376..fa1144f40 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -266,7 +266,7 @@ public class Condense extends SubCommand { } player.sendMessage( TranslatableCaption.of("commandconfig.command_syntax"), - Template.of("value","/plot condense " + area.getWorldName() + " [radius]") + Template.of("value", "/plot condense " + area.getWorldName() + " [radius]") ); return false; } 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 0ab4d5a18..c78ccf630 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java +++ b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java @@ -26,7 +26,6 @@ package com.plotsquared.core.command; import com.google.inject.Inject; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.generator.HybridPlotWorld; import com.plotsquared.core.generator.HybridUtils; 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 d96ed84c6..731329db6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -65,7 +65,7 @@ import java.util.Map.Entry; permission = "plots.database", description = "Convert/Backup Storage", requiredType = RequiredType.CONSOLE, - usage = "/plot database [area] ") + usage = "/plot database [area] ") public class DatabaseCommand extends SubCommand { private final PlotAreaManager plotAreaManager; 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 3587a6a46..1c3d9a51d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -28,6 +28,8 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.StaticCaption; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.RegionManager; @@ -38,6 +40,7 @@ import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.uuid.UUIDMapping; import com.sk89q.worldedit.world.entity.EntityType; +import net.kyori.adventure.text.minimessage.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,29 +71,33 @@ public class Debug extends SubCommand { if (args.length > 0) { if ("player".equalsIgnoreCase(args[0])) { for (Map.Entry meta : player.getMeta().entrySet()) { - MainUtil.sendMessage(player, - "Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , "); + player.sendMessage(StaticCaption.of("Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , ")); } } } if (args.length > 0 && "loadedchunks".equalsIgnoreCase(args[0])) { final long start = System.currentTimeMillis(); - MainUtil.sendMessage(player, "Fetching loaded chunks..."); - TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player, - "Loaded chunks: " + this.regionManager.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + ( - System.currentTimeMillis() - start) + "ms) using thread: " + Thread - .currentThread().getName())); + player.sendMessage(TranslatableCaption.of("debug.fetching_loaded_chunks")); + TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption.of("Loaded chunks: " + this.regionManager.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + ( + System.currentTimeMillis() - start) + "ms) using thread: " + Thread + .currentThread().getName()))); return true; } if (args.length > 0 && "uuids".equalsIgnoreCase(args[0])) { final Collection mappings = PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately(); - MainUtil.sendMessage(player, String.format("There are %d cached UUIDs", mappings.size())); + player.sendMessage( + TranslatableCaption.of("debug.cached_uuids"), + Template.of("value", String.valueOf(mappings.size())) + ); return true; } if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) { - MainUtil.sendMessage(player, "Player in debug mode: " ); + player.sendMessage(TranslatableCaption.of("debug.player_in_debugmode")); for (final PlotPlayer pp : PlotPlayer.getDebugModePlayers()) { - MainUtil.sendMessage(player, "- " + pp.getName()); + player.sendMessage( + TranslatableCaption.of("debug.player_in_debugmode_list"), + Template.of("value", pp.getName()) + ); } return true; } @@ -103,14 +110,14 @@ public class Debug extends SubCommand { } if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) { EntityCategories.init(); - player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: "); + player.sendMessage(TranslatableCaption.of("debug.entity_categories")); EntityCategory.REGISTRY.forEach(category -> { final StringBuilder builder = new StringBuilder("§7- §6").append(category.getId()).append("§7: §6"); for (final EntityType entityType : category.getAll()) { builder.append(entityType.getId()).append(" "); } - player.sendMessage(Captions.PREFIX.getTranslated() + builder.toString()); + player.sendMessage(StaticCaption.of("core.prefix" + builder.toString())); }); EntityType.REGISTRY.values().stream().sorted(Comparator.comparing(EntityType::getId)) .forEach(entityType -> { @@ -119,9 +126,8 @@ public class Debug extends SubCommand { if (categoryCount > 0) { return; } - player.sendMessage( - Captions.PREFIX.getTranslated() + entityType.getName() + " is in " - + categoryCount + " categories"); + player.sendMessage(StaticCaption.of("core.prefix" + entityType.getName() + " is in " + + categoryCount + " categories")); }); return true; } @@ -130,7 +136,7 @@ public class Debug extends SubCommand { for (Captions caption : Captions.values()) { msg.append(caption.getTranslated()).append("\n"); } - MainUtil.sendMessage(player, msg.toString()); + player.sendMessage(StaticCaption.of(msg.toString())); return true; } StringBuilder information = new StringBuilder(); @@ -145,7 +151,7 @@ public class Debug extends SubCommand { information.append(getSection(section, "Messages")); information.append(getLine(line, "Total Messages", Captions.values().length)); information.append(getLine(line, "View all captions", "/plot debug msg")); - MainUtil.sendMessage(player, information.toString()); + player.sendMessage(StaticCaption.of(information.toString())); 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 28c9f1ccc..37bad8d20 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugAllowUnsafe.java @@ -25,7 +25,6 @@ */ package com.plotsquared.core.command; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; 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 7cfdf70c1..8c9fef529 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -65,7 +65,6 @@ import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.TaskManager; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.world.block.BlockState; -import javafx.collections.transformation.TransformationList; import net.kyori.adventure.text.minimessage.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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 5549a3d90..ec12c1bc4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugImportWorlds.java @@ -28,7 +28,6 @@ package com.plotsquared.core.command; import com.google.common.base.Charsets; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.PlotId; 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 c83b4e804..3b16056be 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java @@ -29,7 +29,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption; 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 2ea80304c..2b257047f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugRoadRegen.java @@ -26,7 +26,6 @@ package com.plotsquared.core.command; import com.google.inject.Inject; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.generator.HybridPlotManager; import com.plotsquared.core.generator.HybridUtils; 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 1847d6871..ed25b6730 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Desc.java +++ b/Core/src/main/java/com/plotsquared/core/command/Desc.java @@ -26,7 +26,6 @@ package com.plotsquared.core.command; import com.google.inject.Inject; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent; 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 bde2689ea..423d9ec52 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.java @@ -135,7 +135,7 @@ public class Download extends SubCommand { player.sendMessage(TranslatableCaption.of("web.generating_link_failed")); return; } - player.sendMessage(StaticCaption.of(url.toString()) + player.sendMessage(StaticCaption.of(url.toString())); } }); } else { 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 2ad38ec2d..55d7f0887 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -49,6 +49,7 @@ import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.helpmenu.HelpMenu; import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal3; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -67,7 +68,7 @@ import java.util.stream.Stream; @CommandDeclaration(command = "flag", aliases = {"f", "flag"}, - usage = "/plot flag ", + usage = "/plot flag ", description = "Manage plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, @@ -80,7 +81,10 @@ public final class FlagCommand extends Command { } private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) { - message.send(player, args); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot flag ") + ); return true; } @@ -126,10 +130,12 @@ public final class FlagCommand extends Command { } } } catch (final FlagParseException e) { - MainUtil.sendMessage(player, - Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", flag.getName()) - .replace("%flag_value%", e.getValue()) - .replace("%error%", e.getErrorMessage())); + 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()) + ); return false; } catch (final Exception e) { return false; @@ -163,8 +169,10 @@ public final class FlagCommand extends Command { } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_SET_FLAG_OTHER)) { - MainUtil - .sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG_OTHER); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.set.flag.other") + ); return false; } return true; @@ -190,12 +198,15 @@ public final class FlagCommand extends Command { GlobalFlagContainer.getInstance().getFlagMap().values()); final String best = stringComparison.getBestMatch(); if (best != null) { - MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG_SUGGESTED, best); + player.sendMessage( + TranslatableCaption.of("flag.not_valid_flag_suggested"), + Template.of("value", best) + ); suggested = true; } } catch (final Exception ignored) { /* Happens sometimes because of mean code */ } if (!suggested) { - MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG); + player.sendMessage(TranslatableCaption.of("flag.not_valid_flag")); } return null; } @@ -289,7 +300,10 @@ public final class FlagCommand extends Command { return; } if (args.length < 2) { - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag set "); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot flag set ") + ); return; } final PlotFlag plotFlag = getFlag(player, args[0]); @@ -313,13 +327,19 @@ public final class FlagCommand extends Command { try { parsed = plotFlag.parse(value); } catch (final FlagParseException e) { - MainUtil.sendMessage(player, - Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", plotFlag.getName()) - .replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage())); + player.sendMessage( + TranslatableCaption.of("") + ); + 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()) + ); return; } plot.setFlag(parsed); - MainUtil.sendMessage(player, Captions.FLAG_ADDED); + player.sendMessage(TranslatableCaption.of("flag.flag_added")); } @CommandDeclaration(command = "add", @@ -336,7 +356,10 @@ public final class FlagCommand extends Command { return; } if (args.length < 2) { - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag add "); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot flag add ") + ); return; } final PlotFlag plotFlag = getFlag(player, args[0]); @@ -366,18 +389,21 @@ public final class FlagCommand extends Command { try { parsed = event.getFlag().parse(value); } catch (FlagParseException e) { - MainUtil.sendMessage(player, - Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", plotFlag.getName()) - .replace("%flag_value%", e.getValue()).replace("%error%", e.getErrorMessage())); + 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()) + ); return; } boolean result = player.getLocation().getPlotAbs().setFlag(localFlag.merge(parsed.getValue())); if (!result) { - MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); + player.sendMessage(TranslatableCaption.of("flag.flag_not_added")); return; } - MainUtil.sendMessage(player, Captions.FLAG_ADDED); + player.sendMessage(TranslatableCaption.of("flag.flag_added")); } @CommandDeclaration(command = "remove", @@ -394,8 +420,10 @@ public final class FlagCommand extends Command { return; } if (args.length != 1 && args.length != 2) { - MainUtil - .sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove [values]"); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot flag remove [values]") + ); return; } PlotFlag flag = getFlag(player, args[0]); @@ -431,23 +459,25 @@ public final class FlagCommand extends Command { try { parsedFlag = listFlag.parse(value); } catch (final FlagParseException e) { - MainUtil.sendMessage(player, - Captions.FLAG_PARSE_ERROR.getTranslated().replace("%flag_name%", flag.getName()) - .replace("%flag_value%", e.getValue()) - .replace("%error%", e.getErrorMessage())); + 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()) + ); return; } if (((List) parsedFlag.getValue()).isEmpty()) { - MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); return; } if (list.removeAll((List) parsedFlag.getValue())) { if (list.isEmpty()) { if (plot.removeFlag(flag)) { - MainUtil.sendMessage(player, Captions.FLAG_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_removed")); return; } else { - MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); return; } } else { @@ -455,30 +485,32 @@ public final class FlagCommand extends Command { PlotFlag plotFlag = parsedFlag.createFlagInstance(list); PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot); if (addEvent.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, - "Re-addition of " + plotFlag.getName()); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Re-addition of " + plotFlag.getName()) + ); return; } if (plot.setFlag(addEvent.getFlag())) { - MainUtil.sendMessage(player, Captions.FLAG_PARTIALLY_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_partially_removed")); return; } else { - MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); return; } } } else { - MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); return; } } else { boolean result = plot.removeFlag(flag); if (!result) { - MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); return; } } - MainUtil.sendMessage(player, Captions.FLAG_REMOVED); + player.sendMessage(TranslatableCaption.of("flag.flag_removed")); } @CommandDeclaration(command = "list", @@ -540,12 +572,15 @@ public final class FlagCommand extends Command { return; } if (args.length < 1) { - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag info "); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot flag info ") + ); return; } final PlotFlag plotFlag = getFlag(player, args[0]); if (plotFlag != null) { - Captions.FLAG_INFO_HEADER.send(player); + player.sendMessage(TranslatableCaption.of("flag.flag_info_header")); // Flag name new PlotMessage(Captions.FLAG_INFO_NAME.getTranslated()) .color(Captions.FLAG_INFO_COLOR_KEY.getTranslated()).text(plotFlag.getName()) @@ -574,7 +609,7 @@ public final class FlagCommand extends Command { .color(Captions.FLAG_INFO_COLOR_KEY.getTranslated()).text(defaultValue) .color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).send(player); // Footer. Done this way to prevent the duplicate-message-thingy from catching it - MainUtil.sendMessage(player, "&r" + Captions.FLAG_INFO_FOOTER.getTranslated()); + player.sendMessage(TranslatableCaption.of("flag.flag_info_footer")); } } 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 850aff388..e50b3d01b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Help.java +++ b/Core/src/main/java/com/plotsquared/core/command/Help.java @@ -26,6 +26,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.StringMan; @@ -114,7 +115,7 @@ public class Help extends Command { Captions.HELP_INFO_ITEM.getTranslated().replaceAll("%category%", "all") .replaceAll("%category_desc%", "Display all commands")); builder.append("\n").append(Captions.HELP_FOOTER.getTranslated()); - MainUtil.sendMessage(player, builder.toString(), false); + player.sendMessage(StaticCaption.of(builder.toString())); return true; } new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages() 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 2898ddea0..6bff90f9c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -52,7 +52,7 @@ import java.util.concurrent.CompletableFuture; @CommandDeclaration(command = "home", description = "Teleport to your plot(s)", permission = "plots.home", - usage = "/plot home [||| | ]", + usage = "/plot home [ | | | | ]", aliases = {"h"}, requiredType = RequiredType.PLAYER, category = CommandCategory.TELEPORT) 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 9ec22f008..ff533f102 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java +++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java @@ -121,9 +121,10 @@ public class Inbox extends SubCommand { } else { color = ""; } - sendMessage(player, Captions.INBOX_ITEM, - color + inbox.toString() + " (" + total + '/' + unread - + ')'); + player.sendMessage( + TranslatableCaption.of("comment.inbox_item"), + Template.of("value", color + inbox.toString() + " (" + total + '/' + unread + ')') + ); return; } } @@ -144,8 +145,10 @@ public class Inbox extends SubCommand { } final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase()); if (inbox == null) { - sendMessage(player, Captions.INVALID_INBOX, - StringMan.join(CommentManager.inboxes.keySet(), ", ")); + player.sendMessage( + TranslatableCaption.of("comment.invalid_inbox"), + Template.of("list", StringMan.join(CommentManager.inboxes.keySet(), ", ")) + ); return false; } player.setMeta("inbox:" + inbox.toString(), System.currentTimeMillis()); 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 b8f80b934..3b921fd2c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Info.java +++ b/Core/src/main/java/com/plotsquared/core/command/Info.java @@ -27,6 +27,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.player.PlotPlayer; @@ -100,7 +101,7 @@ public class Info extends SubCommand { .hasPermission(Captions.PERMISSION_AREA_INFO_FORCE.getTranslated())) { player.sendMessage( TranslatableCaption.of("permission.no_permission"), - Template.of("node", Captions.PERMISSION_AREA_INFO_FORCE.getTranslated()) + Template.of("node", "plots.area.info.force") ); return true; } @@ -132,13 +133,11 @@ public class Info extends SubCommand { info = getCaption(arg); if (info == null) { if (Settings.Ratings.USE_LIKES) { - MainUtil.sendMessage(player, - "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " - + "&aowner&7, " + " &alikes"); + player.sendMessage(StaticCaption.of("&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " + + "&aowner&7, " + " &alikes")); } else { - MainUtil.sendMessage(player, - "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " - + "&aowner&7, " + " &arating"); + player.sendMessage(StaticCaption.of("&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " + + "&aowner&7, " + " &arating")); } return false; } 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 11a862d9c..660571202 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Kick.java +++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java @@ -38,6 +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 javax.annotation.Nonnull; import java.util.Collection; @@ -51,7 +52,7 @@ import java.util.concurrent.TimeoutException; aliases = "k", description = "Kick a player from your plot", permission = "plots.kick", - usage = "/plot kick ", + usage = "/plot kick ", category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER) public class Kick extends SubCommand { @@ -75,15 +76,18 @@ public class Kick extends SubCommand { } if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_KICK)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_permission")); return false; } PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> { if (throwable instanceof TimeoutException) { - MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT); + player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); } else if (throwable != null || uuids.isEmpty()) { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", args[0]) + ); } else { Set> players = new HashSet<>(); for (UUID uuid : uuids) { @@ -104,20 +108,29 @@ public class Kick extends SubCommand { } players.remove(player); // Don't ever kick the calling player if (players.isEmpty()) { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", args[0]) + ); return; } for (PlotPlayer player2 : players) { if (!plot.equals(player2.getCurrentPlot())) { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", args[0]) + ); return; } if (Permissions.hasPermission(player2, Captions.PERMISSION_ADMIN_ENTRY_DENIED)) { - Captions.CANNOT_KICK_PLAYER.send(player, player2.getName()); + player.sendMessage( + TranslatableCaption.of("cluster.cannot_kick_player"), + Template.of("name", player2.getName()) + ); return; } Location spawn = this.worldUtil.getSpawn(location.getWorldName()); - Captions.YOU_GOT_KICKED.send(player2); + player.sendMessage(TranslatableCaption.of("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 0b220aa95..c2aa48394 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Leave.java +++ b/Core/src/main/java/com/plotsquared/core/command/Leave.java @@ -27,11 +27,13 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; 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 javax.annotation.Nonnull; import java.util.UUID; @@ -72,9 +74,15 @@ public class Leave extends Command { if (plot.removeMember(uuid)) { this.eventDispatcher.callMember(player, plot, uuid, false); } - MainUtil.sendMessage(player, Captions.PLOT_LEFT, player.getName()); + player.sendMessage( + TranslatableCaption.of("member.plot_left"), + Template.of("player", player.getName()) + ); } else { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, 1); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", String.valueOf(1)) + ); } } return CompletableFuture.completedFuture(true); 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 17c117e77..48d8dd3a8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -40,6 +40,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.TaskManager; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; import java.util.ArrayList; @@ -51,7 +52,7 @@ import java.util.UUID; @CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot", - usage = "/plot like [next|purge]", + usage = "/plot like [next | purge]", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) public class Like extends SubCommand { @@ -82,11 +83,11 @@ public class Like extends SubCommand { .isBasePlot() && (!plot.getLikes().containsKey(uuid))) { plot.teleportPlayer(player, TeleportCause.COMMAND, result -> { }); - MainUtil.sendMessage(player, Captions.RATE_THIS); + player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); return true; } } - MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS); + player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); return true; } case "purge": { @@ -100,7 +101,7 @@ public class Like extends SubCommand { return false; } plot.clearRatings(); - Captions.RATINGS_PURGED.send(player); + player.sendMessage(TranslatableCaption.of("ratings.ratings_purged")); return true; } } @@ -111,21 +112,24 @@ public class Like extends SubCommand { return false; } if (!plot.hasOwner()) { - sendMessage(player, Captions.RATING_NOT_OWNED); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_owned")); return false; } if (plot.isOwner(player.getUUID())) { - sendMessage(player, Captions.RATING_NOT_YOUR_OWN); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_your_own")); return false; } if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) { - sendMessage(player, Captions.RATING_NOT_DONE); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_done")); return false; } final Runnable run = () -> { final Boolean oldRating = plot.getLikes().get(uuid); if (oldRating != null) { - sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_already_exists"), + Template.of("value", plot.getId().toString()) + ); return; } final int rating; @@ -140,9 +144,15 @@ public class Like extends SubCommand { if (event.getRating() != null) { plot.addRating(uuid, event.getRating()); if (like) { - sendMessage(player, Captions.RATING_LIKED, plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_liked"), + Template.of("plot", plot.getId().toString()) + ); } else { - sendMessage(player, Captions.RATING_DISLIKED, plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_disliked"), + Template.of("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 84993c71d..592ca5c65 100644 --- a/Core/src/main/java/com/plotsquared/core/command/ListCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/ListCmd.java @@ -48,6 +48,7 @@ import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.SortingStrategy; import com.plotsquared.core.uuid.UUIDMapping; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -70,7 +71,7 @@ import java.util.stream.Collectors; description = "List plots", permission = "plots.list", category = CommandCategory.INFO, - usage = "/plot list > [#]") + usage = "/plot list > [#]") public class ListCmd extends SubCommand { private final PlotAreaManager plotAreaManager; @@ -158,9 +159,11 @@ public class ListCmd extends SubCommand { final Consumer plotConsumer = query -> { if (query == null) { - sendMessage(player, Captions.DID_YOU_MEAN, - new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"}) - .getBestMatch()); + player.sendMessage( + TranslatableCaption.of("commandconfig.did_you_mean"), + Template.of("value", new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"}) + .getBestMatch()) + ); return; } 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 d0135549b..c86cbe244 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Load.java +++ b/Core/src/main/java/com/plotsquared/core/command/Load.java @@ -28,6 +28,7 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -39,6 +40,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 javax.annotation.Nonnull; import java.net.MalformedURLException; @@ -74,16 +76,16 @@ public class Load extends SubCommand { return false; } if (!plot.hasOwner()) { - MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_LOAD)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } if (plot.getRunning() > 0) { - MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); + player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); return false; } @@ -92,7 +94,7 @@ public class Load extends SubCommand { List schematics = player.getMeta("plot_schematics"); if (schematics == null) { // No schematics found: - MainUtil.sendMessage(player, Captions.LOAD_NULL); + player.sendMessage(TranslatableCaption.of("web.load_null")); return false; } String schematic; @@ -100,8 +102,10 @@ public class Load extends SubCommand { schematic = schematics.get(Integer.parseInt(args[0]) - 1); } catch (Exception ignored) { // use /plot load - MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, - "(1, " + schematics.size() + ')'); + player.sendMessage( + TranslatableCaption.of("invalid.not_valid_number"), + Template.of("value", "(1, " + schematics.size() + ')') + ); return false; } final URL url; @@ -109,17 +113,19 @@ public class Load extends SubCommand { url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic); } catch (MalformedURLException e) { e.printStackTrace(); - MainUtil.sendMessage(player, Captions.LOAD_FAILED); + player.sendMessage(TranslatableCaption.of("web.load_failed")); return false; } plot.addRunning(); - MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT); + player.sendMessage(TranslatableCaption.of("working.generating_component")); TaskManager.runTaskAsync(() -> { Schematic taskSchematic = this.schematicHandler.getSchematic(url); if (taskSchematic == null) { plot.removeRunning(); - sendMessage(player, Captions.SCHEMATIC_INVALID, - "non-existent or not in gzip format"); + player.sendMessage( + TranslatableCaption.of("schematics.schematic_invalid"), + Template.of("reason", "non-existent or not in gzip format") + ); return; } PlotArea area = plot.getArea(); @@ -128,9 +134,9 @@ public class Load extends SubCommand { @Override public void run(Boolean value) { plot.removeRunning(); if (value) { - sendMessage(player, Captions.SCHEMATIC_PASTE_SUCCESS); + player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success")); } else { - sendMessage(player, Captions.SCHEMATIC_PASTE_FAILED); + player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed")); } } }); @@ -138,7 +144,10 @@ public class Load extends SubCommand { return true; } plot.removeRunning(); - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot load "); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot load ") + ); return false; } @@ -151,7 +160,7 @@ public class Load extends SubCommand { List schematics1 = this.schematicHandler.getSaves(player.getUUID()); plot.removeRunning(); if ((schematics1 == null) || schematics1.isEmpty()) { - MainUtil.sendMessage(player, Captions.LOAD_FAILED); + player.sendMessage(TranslatableCaption.of("web.load_failed")); return; } player.setMeta("plot_schematics", schematics1); @@ -177,15 +186,14 @@ public class Load extends SubCommand { String world = split[1]; PlotId id = PlotId.fromString(split[2] + ';' + split[3]); String size = split[4]; - String color = "$4"; - MainUtil.sendMessage(player, - "$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id - + "$3 | " + color + size + 'x' + size); + String color = ""; + player.sendMessage(StaticCaption.of("[" + (i + 1) + "] " + color + time + " | " + color + world + ';' + id + + " | " + color + size + 'x' + size)); } catch (Exception e) { e.printStackTrace(); } } - MainUtil.sendMessage(player, Captions.LOAD_LIST); + player.sendMessage(TranslatableCaption.of("web.load_list")); } public String secToTime(long time) { 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 3e31a86d2..4b034e9a4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -52,7 +52,7 @@ import java.util.UUID; aliases = "m", description = "Merge the plot you are standing on with another plot", permission = "plots.merge", - usage = "/plot merge [removeroads]", + usage = "/plot merge [removeroads]", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, confirmation = true) @@ -100,7 +100,7 @@ public class Merge extends SubCommand { return false; } if (!plot.hasOwner()) { - MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } Direction direction = null; @@ -132,10 +132,14 @@ public class Merge extends SubCommand { } } if (direction == null) { - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, - "/plot merge <" + StringMan.join(values, "|") + "> [removeroads]"); - MainUtil.sendMessage(player, Captions.DIRECTION.getTranslated() - .replaceAll("%dir%", direction(location.getYaw()))); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]") + ); + player.sendMessage( + TranslatableCaption.of("help.direction"), + Template.of("dir", direction(location.getYaw())) + ); return false; } final int size = plot.getConnectedPlots().size(); @@ -153,7 +157,10 @@ public class Merge extends SubCommand { final int maxSize = event.getMax(); if (!force && size - 1 > maxSize) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, "plots.merge." + (size + 1)); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.merge." + (size + 1)) + ); return false; } final PlotArea plotArea = plot.getArea(); @@ -168,24 +175,29 @@ public class Merge extends SubCommand { } if (!force && !terrain && !Permissions .hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated()); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.merge.keeproad") + ); return true; } if (plot.autoMerge(Direction.ALL, maxSize, uuid, terrain)) { if (this.econHandler != null && plotArea.useEconomy() && price > 0d) { this.econHandler.withdrawMoney(player, price); - sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); + player.sendMessage( + TranslatableCaption.of("economy.removed_balance"), + Template.of("money", String.valueOf(price)) + ); } - MainUtil.sendMessage(player, Captions.SUCCESS_MERGE); + player.sendMessage(TranslatableCaption.of("merge.success_merge")); return true; } - MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE); + player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); return false; } if (!force && !plot.isOwner(uuid)) { if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_MERGE)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } else { uuid = plot.getOwnerAbs(); @@ -193,7 +205,10 @@ public class Merge extends SubCommand { } if (!force && this.econHandler != null && plotArea.useEconomy() && price > 0d && this.econHandler.getMoney(player) < price) { - sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price)); + player.sendMessage( + TranslatableCaption.of("economy.cannot_afford_merge"), + Template.of("money", String.valueOf(price)) + ); return false; } final boolean terrain; @@ -204,26 +219,34 @@ public class Merge extends SubCommand { } if (!force && !terrain && !Permissions .hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_MERGE_KEEP_ROAD.getTranslated()); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.merge.keeproad") + ); return true; } if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) { if (this.econHandler != null && plotArea.useEconomy() && price > 0d) { this.econHandler.withdrawMoney(player, price); - sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); + player.sendMessage( + TranslatableCaption.of("economy.removed_balance"), + Template.of("money", String.valueOf(price)) + ); } - MainUtil.sendMessage(player, Captions.SUCCESS_MERGE); + player.sendMessage(TranslatableCaption.of("success_merge")); return true; } Plot adjacent = plot.getRelative(direction); if (adjacent == null || !adjacent.hasOwner() || adjacent .getMerged((direction.getIndex() + 2) % 4) || (!force && adjacent.isOwner(uuid))) { - MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE); + player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); return false; } if (!force && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_OTHER)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_MERGE_OTHER); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.merge.other") + ); return false; } java.util.Set uuids = adjacent.getOwners(); @@ -236,22 +259,28 @@ public class Merge extends SubCommand { isOnline = true; final Direction dir = direction; Runnable run = () -> { - MainUtil.sendMessage(accepter, Captions.MERGE_ACCEPTED); + accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted")); plot.autoMerge(dir, maxSize - size, owner, terrain); PlotPlayer plotPlayer = PlotSquared.platform().getPlayerManager().getPlayerIfExists(player.getUUID()); if (plotPlayer == null) { - sendMessage(accepter, Captions.MERGE_NOT_VALID); + accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid")); return; } if (this.econHandler != null && plotArea.useEconomy() && price > 0d) { if (!force && this.econHandler.getMoney(player) < price) { - sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price)); + player.sendMessage( + TranslatableCaption.of("economy.cannot_afford_merge"), + Template.of("money", String.valueOf(price)) + ); return; } this.econHandler.withdrawMoney(player, price); - sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); + player.sendMessage( + TranslatableCaption.of("economy.removed_balance"), + Template.of("money", String.valueOf(price)) + ); } - MainUtil.sendMessage(player, Captions.SUCCESS_MERGE); + player.sendMessage(TranslatableCaption.of("merge.success_merge")); }; if (!force && hasConfirmation(player)) { CmdConfirm.addPending(accepter, Captions.MERGE_REQUEST_CONFIRM.getTranslated() @@ -261,10 +290,10 @@ public class Merge extends SubCommand { } } if (!force && !isOnline) { - MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE); + player.sendMessage(TranslatableCaption.of("merge.no_available_automerge")); return false; } - MainUtil.sendMessage(player, Captions.MERGE_REQUESTED); + player.sendMessage(TranslatableCaption.of("merge.merge_requested")); 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 df0a9bef7..16d19520a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -36,6 +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 javax.annotation.Nonnull; import java.util.concurrent.CompletableFuture; @@ -66,7 +67,7 @@ public class Move extends SubCommand { } if (!plot1.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return CompletableFuture.completedFuture(false); } boolean override = false; @@ -89,27 +90,30 @@ public class Move extends SubCommand { plot2 = area.getPlotAbs(plot1.getId()); } if (plot1.equals(plot2)) { - MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID); - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot copy "); + player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id")); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot copy ") + ); return CompletableFuture.completedFuture(false); } if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated()))) { - Captions.PLOTWORLD_INCOMPATIBLE.send(player); + player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible")); return CompletableFuture.completedFuture(false); } if (plot1.isMerged() || plot2.isMerged()) { - Captions.MOVE_MERGED.send(player); + player.sendMessage(TranslatableCaption.of("move.move_merged")); return CompletableFuture.completedFuture(false); } return plot1.move(plot2, () -> { }, false).thenApply(result -> { if (result) { - MainUtil.sendMessage(player, Captions.MOVE_SUCCESS); + player.sendMessage(TranslatableCaption.of("move.move_success")); return true; } else { - MainUtil.sendMessage(player, Captions.REQUIRES_UNOWNED); + player.sendMessage(TranslatableCaption.of("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 078fbf429..f9c0ce8d9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -26,7 +26,6 @@ package com.plotsquared.core.command; import com.google.inject.Inject; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent; @@ -74,7 +73,7 @@ public class Music extends SubCommand { return false; } if (!plot.isAdded(player.getUUID())) { - sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return true; } PlotInventory inv = new PlotInventory(this.inventoryUtil, player, 2, "Plot Jukebox") { @@ -94,7 +93,7 @@ public class Music extends SubCommand { return true; } plot.removeFlag(event.getFlag()); - Captions.FLAG_REMOVED.send(player); + player.sendMessage(TranslatableCaption.of("flag.flag_removed")); } else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) { PlotFlag plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class) .createFlagInstance(item.getType()); @@ -106,9 +105,9 @@ public class Music extends SubCommand { return true; } plot.setFlag(event.getFlag()); - Captions.FLAG_ADDED.send(player); + player.sendMessage(TranslatableCaption.of("flag.flag_added")); } else { - Captions.FLAG_NOT_ADDED.send(player); + player.sendMessage(TranslatableCaption.of("flag.flag_not_added")); } return false; } 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 20780613a..44dce1449 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Near.java +++ b/Core/src/main/java/com/plotsquared/core/command/Near.java @@ -26,11 +26,13 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; 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 java.util.concurrent.CompletableFuture; @@ -50,7 +52,10 @@ public class Near extends Command { RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); - Captions.PLOT_NEAR.send(player, StringMan.join(plot.getPlayersInPlot(), ", ")); + player.sendMessage( + TranslatableCaption.of("near.plot_near"), + Template.of("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 c26027e72..7d5b69fa4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -65,7 +65,11 @@ public class Owner extends SetCommand { @Override public boolean set(final PlotPlayer player, final Plot plot, String value) { if (value == null || value.isEmpty()) { - Captions.SET_OWNER_MISSING_PLAYER.send(player); + player.sendMessage(TranslatableCaption.of("owner.set_owner_missing_player")); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot setowner ") + ); return false; } Set plots = plot.getConnectedPlots(); @@ -73,7 +77,10 @@ public class Owner extends SetCommand { final Consumer uuidConsumer = uuid -> { if (uuid == null && !value.equalsIgnoreCase("none") && !value.equalsIgnoreCase("null") && !value.equalsIgnoreCase("-")) { - Captions.INVALID_PLAYER.send(player, value); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", value) + ); return; } PlotChangeOwnerEvent event = this.eventDispatcher.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid, @@ -105,18 +112,24 @@ public class Owner extends SetCommand { current.unclaim(); current.removeSign(); } - MainUtil.sendMessage(player, Captions.SET_OWNER); + player.sendMessage(TranslatableCaption.of("owner.set_owner")); return; } final PlotPlayer other = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid); if (plot.isOwner(uuid)) { - Captions.ALREADY_OWNER.send(player, PlayerManager.getName(uuid)); + player.sendMessage( + TranslatableCaption.of("member.already_owner"), + Template.of("player", PlayerManager.getName(uuid)) + ); return; } if (!force && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) { if (other == null) { - Captions.INVALID_PLAYER_OFFLINE.send(player, value); + player.sendMessage( + TranslatableCaption.of("invalid_player_offline"), + Template.of("player", PlayerManager.getName(uuid)) + ); return; } int size = plots.size(); @@ -124,7 +137,7 @@ public class Owner extends SetCommand { other.getPlotCount() : other.getPlotCount(plot.getWorldName())) + size; if (currentPlots > other.getAllowedPlots()) { - sendMessage(player, Captions.CANT_TRANSFER_MORE_PLOTS); + player.sendMessage(TranslatableCaption.of("permission.cant_transfer_more_plots")); return; } } @@ -136,13 +149,15 @@ public class Owner extends SetCommand { if (removeDenied) plot.removeDenied(finalUUID); plot.setSign(finalName); - MainUtil.sendMessage(player, Captions.SET_OWNER); + player.sendMessage(TranslatableCaption.of("owner.set_owner")); if (other != null) { - MainUtil.sendMessage(other, Captions.NOW_OWNER, - plot.getArea() + ";" + plot.getId()); + other.sendMessage( + TranslatableCaption.of("owner.now_owner"), + Template.of("plot", plot.getArea() + ";" + plot.getId()) + ); } } else { - MainUtil.sendMessage(player, Captions.SET_OWNER_CANCELLED); + player.sendMessage(TranslatableCaption.of("owner.set_owner_cancelled")); } }; if (hasConfirmation(player)) { @@ -161,9 +176,12 @@ public class Owner extends SetCommand { } else { PlotSquared.get().getImpromptuUUIDPipeline().getSingle(value, (uuid, throwable) -> { if (throwable instanceof TimeoutException) { - MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT); + player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); } else if (throwable != null) { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, value); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", value) + ); } else { uuidConsumer.accept(uuid); } 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 0ddb854c2..cc8ab09af 100644 --- a/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/PluginCmd.java @@ -26,9 +26,11 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; +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; @CommandDeclaration(command = "plugin", permission = "plots.use", @@ -40,15 +42,16 @@ public class PluginCmd extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { TaskManager.getPlatformImplementation().taskAsync(() -> { - MainUtil.sendMessage(player, String.format( - "$2>> $1&l" + PlotSquared.platform().getPluginName() + " $2($1Version$2: $1%s$2)", - PlotSquared.get().getVersion())); - MainUtil.sendMessage(player, - "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21 $2& $1NotMyFault $2& $1SirYwell"); - MainUtil.sendMessage(player, - "$2>> $1&lWiki$2: $1https://wiki.intellectualsites.com/plotsquared/home"); - MainUtil - .sendMessage(player, "$2>> $1&lPremium$2: $1" + PremiumVerification.isPremium()); + player.sendMessage( + StaticCaption.of(">> " + PlotSquared.platform().getPluginName() + " (Version: )"), + Template.of("version", String.valueOf(PlotSquared.get().getVersion())) + ); + player.sendMessage(StaticCaption.of(" >> Authors: Citymonstret & Empire92 & MattBDev & dordsor21 & NotMyFault & SirYwell")); + player.sendMessage(StaticCaption.of(" >> Wiki: https://wiki.intellectualsites.com/plotsquared/home")); + player.sendMessage( + StaticCaption.of(" >> Premium: "), + Template.of("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 578f4397b..136b1e163 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -27,8 +27,8 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.player.PlotPlayer; @@ -38,6 +38,7 @@ import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.TaskManager; +import net.kyori.adventure.text.minimessage.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,7 +97,10 @@ public class Purge extends SubCommand { case "a": area = this.plotAreaManager.getPlotAreaByString(split[1]); if (area == null) { - Captions.NOT_VALID_PLOT_WORLD.send(player, split[1]); + player.sendMessage( + TranslatableCaption.of("errors.not_valid_plot_world"), + Template.of("value", split[1]) + ); return false; } break; @@ -105,7 +109,10 @@ public class Purge extends SubCommand { try { id = PlotId.fromString(split[1]); } catch (IllegalArgumentException ignored) { - Captions.NOT_VALID_PLOT_ID.send(player, split[1]); + player.sendMessage( + TranslatableCaption.of("invalid.not_valid_plot_id"), + Template.of("value", split[1]) + ); return false; } break; @@ -113,7 +120,10 @@ public class Purge extends SubCommand { case "o": owner = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(split[1], Settings.UUID.BLOCKING_TIMEOUT); if (owner == null) { - Captions.INVALID_PLAYER.send(player, split[1]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", split[1]) + ); return false; } break; @@ -121,7 +131,10 @@ public class Purge extends SubCommand { case "s": added = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(split[1], Settings.UUID.BLOCKING_TIMEOUT); if (added == null) { - Captions.INVALID_PLAYER.send(player, split[1]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", split[1]) + ); return false; } break; @@ -179,7 +192,7 @@ public class Purge extends SubCommand { } } if (toDelete.isEmpty()) { - Captions.FOUND_NO_PLOTS.send(player); + player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); return false; } String cmd = @@ -225,7 +238,10 @@ public class Purge extends SubCommand { } else { TaskManager.runTask(() -> { DBFunc.purgeIds(ids); - Captions.PURGE_SUCCESS.send(player, ids.size() + "/" + toDelete.size()); + player.sendMessage( + TranslatableCaption.of("purge.purge_success"), + Template.of("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 7c9b78422..8f69485e7 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -44,6 +44,7 @@ import com.plotsquared.core.util.InventoryUtil; import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.TaskManager; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; import java.util.ArrayList; @@ -54,7 +55,7 @@ import java.util.UUID; @CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", - usage = "/plot rate [#|next|purge]", + usage = "/plot rate [# | next | purge]", aliases = "rt", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) @@ -99,11 +100,11 @@ public class Rate extends SubCommand { .isAdded(uuid)) { p.teleportPlayer(player, TeleportCause.COMMAND, result -> { }); - MainUtil.sendMessage(player, Captions.RATE_THIS); + player.sendMessage(TranslatableCaption.of("tutorial.rate_this")); return true; } } - MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS); + player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); return false; } case "purge": { @@ -117,7 +118,7 @@ public class Rate extends SubCommand { return false; } plot.clearRatings(); - Captions.RATINGS_PURGED.send(player); + player.sendMessage(TranslatableCaption.of("ratings.ratings_purged")); return true; } } @@ -128,23 +129,25 @@ public class Rate extends SubCommand { return false; } if (!plot.hasOwner()) { - sendMessage(player, Captions.RATING_NOT_OWNED); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_owned")); return false; } if (plot.isOwner(player.getUUID())) { - sendMessage(player, Captions.RATING_NOT_YOUR_OWN); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_your_own")); return false; } if (Settings.Done.REQUIRED_FOR_RATINGS && !DoneFlag.isDone(plot)) { - sendMessage(player, Captions.RATING_NOT_DONE); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_done")); return false; } if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) { final Runnable run = new Runnable() { @Override public void run() { if (plot.getRatings().containsKey(player.getUUID())) { - sendMessage(player, Captions.RATING_ALREADY_EXISTS, - plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_already_exists"), + Template.of("plot", plot.getId().toString()) + ); return; } final MutableInt index = new MutableInt(0); @@ -160,15 +163,19 @@ public class Rate extends SubCommand { .callRating(this.player, plot, new Rating(rV)); if (event.getRating() != null) { plot.addRating(this.player.getUUID(), event.getRating()); - sendMessage(this.player, Captions.RATING_APPLIED, - plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_applied"), + Template.of("plot", plot.getId().toString()) + ); if (Permissions .hasPermission(this.player, Captions.PERMISSION_COMMENT)) { Command command = MainCommand.getInstance().getCommand(Comment.class); if (command != null) { - MainUtil.sendMessage(this.player, Captions.COMMENT_THIS, - command.getUsage()); + player.sendMessage( + TranslatableCaption.of("tutorial.comment_this"), + Template.of("plot", "/plot rate") + ); } } } @@ -204,7 +211,7 @@ public class Rate extends SubCommand { return true; } if (args.length < 1) { - sendMessage(player, Captions.RATING_NOT_VALID); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid")); return true; } String arg = args[0]; @@ -212,24 +219,30 @@ public class Rate extends SubCommand { if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) { rating = Integer.parseInt(arg); if (rating > 10 || rating < 1) { - sendMessage(player, Captions.RATING_NOT_VALID); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid")); return false; } } else { - sendMessage(player, Captions.RATING_NOT_VALID); + player.sendMessage(TranslatableCaption.of("ratings.rating_not_valid")); return false; } final UUID uuid = player.getUUID(); final Runnable run = () -> { if (plot.getRatings().containsKey(uuid)) { - sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_already_exists"), + Template.of("value", plot.getId().toString()) + ); return; } PlotRateEvent event = this.eventDispatcher.callRating(player, plot, new Rating(rating)); if (event.getRating() != null) { plot.addRating(uuid, event.getRating()); - sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString()); + player.sendMessage( + TranslatableCaption.of("ratings.rating_applied"), + Template.of("value", plot.getId().toString()) + ); } }; if (plot.getSettings().getRatings() == null) { 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 c006e87af..7a42442f4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java +++ b/Core/src/main/java/com/plotsquared/core/command/RegenAllRoads.java @@ -26,13 +26,14 @@ package com.plotsquared.core.command; import com.google.inject.Inject; -import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.generator.HybridPlotManager; import com.plotsquared.core.generator.HybridUtils; 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 javax.annotation.Nonnull; @@ -60,38 +61,44 @@ public class RegenAllRoads extends SubCommand { try { height = Integer.parseInt(args[1]); } catch (NumberFormatException ignored) { - MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)"); - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, - "/plot regenallroads [height]"); + player.sendMessage( + TranslatableCaption.of("invalid.not_valid_number"), + Template.of("value", "(0, 256)") + ); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot regenallroads [height]") + ); return false; } } else if (args.length != 1) { - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, - "/plot regenallroads [height]"); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot regenallroads [height]") + ); return false; } PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]); if (area == null) { - Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]); + player.sendMessage( + TranslatableCaption.of("errors.not_valid_plot_world"), + Template.of("value", args[0]) + ); return false; } String name = args[0]; PlotManager manager = area.getPlotManager(); if (!(manager instanceof HybridPlotManager)) { - MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD); + player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world")); return false; } //Set chunks = ChunkManager.manager.getChunkChunks(name); - MainUtil - .sendMessage(player, "&cIf no schematic is set, the following will not do anything"); - MainUtil.sendMessage(player, - "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); + player.sendMessage(TranslatableCaption.of("debugroadregen.schematic")); //MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024)); //MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds"); boolean result = this.hybridUtils.scheduleRoadUpdate(area, height); if (!result) { - MainUtil.sendMessage(player, - "&cCannot schedule mass schematic update! (Is one already in progress?)"); + player.sendMessage(TranslatableCaption.of("debugexec.mass_schematic_update_in_progress")); return false; } return true; diff --git a/Core/src/main/java/com/plotsquared/core/command/Relight.java b/Core/src/main/java/com/plotsquared/core/command/Relight.java index 4a2475b5f..0488f1d14 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Relight.java +++ b/Core/src/main/java/com/plotsquared/core/command/Relight.java @@ -25,7 +25,7 @@ */ package com.plotsquared.core.command; -import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.queue.LocalBlockQueue; @@ -52,7 +52,7 @@ public class Relight extends Command { RunnableVal2 whenDone) { final Plot plot = player.getCurrentPlot(); if (plot == null) { - Captions.NOT_IN_PLOT.send(player); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return CompletableFuture.completedFuture(false); } final LocalBlockQueue queue = plot.getArea().getQueue(false); @@ -62,7 +62,7 @@ public class Relight extends Command { } }, () -> { plot.refreshChunks(); - Captions.SET_BLOCK_ACTION_FINISHED.send(player); + player.sendMessage(TranslatableCaption.of("setblock.set_block_action_finished")); }, 5); return CompletableFuture.completedFuture(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 dec8d7175..8945a0808 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Reload.java +++ b/Core/src/main/java/com/plotsquared/core/command/Reload.java @@ -30,6 +30,7 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.MemorySection; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.inject.annotations.WorldFile; @@ -116,10 +117,10 @@ public class Reload extends SubCommand { } }); this.worldConfiguration.save(this.worldFile); - MainUtil.sendMessage(player, Captions.RELOADED_CONFIGS); + player.sendMessage(TranslatableCaption.of("reload.reloaded_configs")); } catch (IOException e) { e.printStackTrace(); - MainUtil.sendMessage(player, Captions.RELOAD_FAILED); + player.sendMessage(TranslatableCaption.of("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 35a074adc..69a3ceec9 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Remove.java +++ b/Core/src/main/java/com/plotsquared/core/command/Remove.java @@ -36,6 +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 javax.annotation.Nonnull; import java.util.Collection; @@ -46,7 +47,7 @@ import java.util.concurrent.TimeoutException; @CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"}, description = "Remove a player from a plot", - usage = "/plot remove ", + usage = "/plot remove ", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.remove") @@ -67,22 +68,25 @@ public class Remove extends SubCommand { return false; } if (!plot.hasOwner()) { - MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_REMOVE)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return true; } PlayerManager.getUUIDsFromString(args[0], (uuids, throwable) -> { int count = 0; if (throwable instanceof TimeoutException) { - MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT); + player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); return; } else if (throwable != null) { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", args[0]) + ); return; } else if (!uuids.isEmpty()) { for (UUID uuid : uuids) { @@ -116,9 +120,15 @@ public class Remove extends SubCommand { } } if (count == 0) { - MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]); + player.sendMessage( + TranslatableCaption.of("errors.invalid_player"), + Template.of("value", args[0]) + ); } else { - MainUtil.sendMessage(player, Captions.REMOVED_PLAYERS, count + ""); + player.sendMessage( + TranslatableCaption.of("member.removed_players"), + Template.of("amount", count + "") + ); } }); return true; 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 00be26484..a898d2570 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -71,16 +71,16 @@ public class Save extends SubCommand { return false; } if (!plot.hasOwner()) { - MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SAVE)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } if (plot.getRunning() > 0) { - MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); + player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); return false; } plot.addRunning(); @@ -101,10 +101,10 @@ public class Save extends SubCommand { @Override public void run(URL url) { plot.removeRunning(); if (url == null) { - MainUtil.sendMessage(player, Captions.SAVE_FAILED); + player.sendMessage(TranslatableCaption.of("backups.backup_save_failed")); return; } - MainUtil.sendMessage(player, Captions.SAVE_SUCCESS); + player.sendMessage(TranslatableCaption.of("web.save_success")); List schematics = player.getMeta("plot_schematics"); if (schematics != null) { schematics.add(file + ".schem"); 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 1d8cee498..8559fa26e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java +++ b/Core/src/main/java/com/plotsquared/core/command/SchematicCmd.java @@ -29,6 +29,7 @@ import com.google.common.collect.Lists; import com.google.inject.Inject; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.StaticCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.ConsolePlayer; @@ -42,8 +43,10 @@ import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.TaskManager; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; +import javax.swing.plaf.basic.BasicSliderUI; import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -54,7 +57,7 @@ import java.util.UUID; description = "Schematic command", aliases = {"sch", "schem"}, category = CommandCategory.SCHEMATIC, - usage = "/plot schematic ") + usage = "/plot schematic ") public class SchematicCmd extends SubCommand { private final PlotAreaManager plotAreaManager; @@ -69,19 +72,27 @@ public class SchematicCmd extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length < 1) { - sendMessage(player, Captions.SCHEMATIC_MISSING_ARG); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "Possible values: save, paste , exportall, list") + ); return true; } String arg = args[0].toLowerCase(); switch (arg) { case "paste": { if (!Permissions.hasPermission(player, Captions.PERMISSION_SCHEMATIC_PASTE)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_SCHEMATIC_PASTE); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.schematic.paste") + ); return false; } if (args.length < 2) { - sendMessage(player, Captions.SCHEMATIC_MISSING_ARG); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "Possible values: save, paste , exportall, list") + ); break; } Location loc = player.getLocation(); @@ -91,20 +102,20 @@ public class SchematicCmd extends SubCommand { return false; } if (!plot.hasOwner()) { - MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC_PASTE)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + .hasPermission(player, "plots.admin.command.schematic.paste")) { + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } if (this.running) { - MainUtil.sendMessage(player, Captions.TASK_IN_PROCESS); + player.sendMessage(TranslatableCaption.of("error.task_in_process")); return false; } if (plot.isMerged()) { - MainUtil.sendMessage(player, Captions.SCHEMATIC_PASTE_MERGED); + player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_merged")); return false; } final String location = args[1]; @@ -119,8 +130,10 @@ public class SchematicCmd extends SubCommand { schematic = this.schematicHandler.getSchematic(url); } catch (Exception e) { e.printStackTrace(); - sendMessage(player, Captions.SCHEMATIC_INVALID, - "non-existent url: " + location); + player.sendMessage( + TranslatableCaption.of("schematics.schematic_invalid"), + Template.of("reason", "non-existent url: " + location) + ); SchematicCmd.this.running = false; return; } @@ -133,17 +146,19 @@ public class SchematicCmd extends SubCommand { } if (schematic == null) { SchematicCmd.this.running = false; - sendMessage(player, Captions.SCHEMATIC_INVALID, - "non-existent or not in gzip format"); + player.sendMessage( + TranslatableCaption.of("schematics.schematic_invalid"), + Template.of("reason", "non-existent or not in gzip format") + ); return; } this.schematicHandler.paste(schematic, plot, 0, 1, 0, false, new RunnableVal() { @Override public void run(Boolean value) { SchematicCmd.this.running = false; if (value) { - sendMessage(player, Captions.SCHEMATIC_PASTE_SUCCESS); + player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_success")); } else { - sendMessage(player, Captions.SCHEMATIC_PASTE_FAILED); + player.sendMessage(TranslatableCaption.of("schematics.schematic_paste_failed")); } } }); @@ -153,44 +168,59 @@ public class SchematicCmd extends SubCommand { case "saveall": case "exportall": { if (!(player instanceof ConsolePlayer)) { - MainUtil.sendMessage(player, Captions.NOT_CONSOLE); + player.sendMessage(TranslatableCaption.of("console.not_console")); return false; } if (args.length != 2) { - MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD_ARGS); + player.sendMessage(TranslatableCaption.of("schematic_exportall_world_args")); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "Use /plot sch exportall area") + ); return false; } PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]); if (area == null) { - Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]); + player.sendMessage( + TranslatableCaption.of("errors.not_valid_plot_world"), + Template.of("value", args[1]) + ); return false; } Collection plots = area.getPlots(); if (plots.isEmpty()) { - MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD); + player.sendMessage(TranslatableCaption.of("schematic.schematic_exportall_world")); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "Use /plot sch exportall ") + ); return false; } boolean result = this.schematicHandler.exportAll(plots, null, null, - () -> MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_FINISHED)); + () -> player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_finished"))); if (!result) { - MainUtil.sendMessage(player, Captions.TASK_IN_PROCESS); + player.sendMessage(TranslatableCaption.of("error.task_in_process")); return false; } else { - MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_STARTED); - MainUtil.sendMessage(player, - "&3Plot&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots..."); + player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started")); + player.sendMessage( + TranslatableCaption.of("schematics.plot_to_schem"), + Template.of("amount", String.valueOf(plots.size())) + ); } break; } case "export": case "save": if (!Permissions.hasPermission(player, Captions.PERMISSION_SCHEMATIC_SAVE)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_SCHEMATIC_SAVE); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.schematic.save") + ); return false; } if (this.running) { - MainUtil.sendMessage(player, Captions.TASK_IN_PROCESS); + player.sendMessage(TranslatableCaption.of("error.task_in_process")); return false; } Location location = player.getLocation(); @@ -200,38 +230,46 @@ public class SchematicCmd extends SubCommand { return false; } if (!plot.hasOwner()) { - MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); return false; } if (!plot.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC_SAVE)) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + .hasPermission(player, "plots.admin.command.schematic.save")) { + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return false; } ArrayList plots = Lists.newArrayList(plot); boolean result = this.schematicHandler.exportAll(plots, null, null, () -> { - MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_SINGLE_FINISHED); + player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_single_finished")); SchematicCmd.this.running = false; }); if (!result) { - MainUtil.sendMessage(player, Captions.TASK_IN_PROCESS); + player.sendMessage(TranslatableCaption.of("error.task_in_process")); return false; } else { - MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_STARTED); + player.sendMessage(TranslatableCaption.of("schematics.schematic_exportall_started")); } break; case "list": { if (!Permissions.hasPermission(player, Captions.PERMISSION_SCHEMATIC_LIST)) { - MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_SCHEMATIC_LIST); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", "plots.schematic.list") + ); return false; } final String string = StringMan.join(this.schematicHandler.getSchematicNames(), "$2, $1"); - Captions.SCHEMATIC_LIST.send(player, string); + player.sendMessage( + TranslatableCaption.of("schematics.schematic_list"), + Template.of("list", string) + ); } break; default: - sendMessage(player, Captions.SCHEMATIC_MISSING_ARG); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "Possible values: save, paste , exportall, list") + ); break; } 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 27e6d5e19..36847c800 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -45,6 +45,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 javax.annotation.Nonnull; import java.util.ArrayList; @@ -59,7 +60,7 @@ import java.util.stream.Stream; @CommandDeclaration(command = "set", description = "Set a plot value", aliases = {"s"}, - usage = "/plot set ", + usage = "/plot set ", permission = "plots.set", category = CommandCategory.APPEARANCE, requiredType = RequiredType.NONE) @@ -127,7 +128,10 @@ public class Set extends SubCommand { } else if (!blockType.contains(forbiddenType)) { continue; } - Captions.COMPONENT_ILLEGAL_BLOCK.send(player, forbiddenType); + player.sendMessage( + TranslatableCaption.of("invalid.component_illegal_block"), + Template.of("value", forbiddenType) + ); return true; } } @@ -144,14 +148,14 @@ public class Set extends SubCommand { return false; } if (args.length < 2) { - MainUtil.sendMessage(player, Captions.NEED_BLOCK); + player.sendMessage(TranslatableCaption.of("need.need_block")); return true; } Pattern pattern = PatternUtil.parse(player, material, false); if (plot.getRunning() > 0) { - MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); + player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); return false; } @@ -160,7 +164,7 @@ public class Set extends SubCommand { for (Plot current : plot.getConnectedPlots()) { current.setComponent(component, pattern); } - MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT); + player.sendMessage(TranslatableCaption.of("working.generating_component")); blockQueue.addEmptyTask(plot::removeRunning); }); return true; 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 4ab128da7..54c3f8844 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java @@ -49,7 +49,7 @@ public abstract class SetCommand extends SubCommand { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility .format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId())); - MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED); + player.sendMessage(TranslatableCaption.of("working.plot_not_claimed")); return false; } } @@ -59,7 +59,7 @@ public abstract class SetCommand extends SubCommand { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility .format(player, Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId())); - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("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 c883d5933..e0a7497fc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetHome.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetHome.java @@ -25,11 +25,12 @@ */ package com.plotsquared.core.command; -import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; 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; @CommandDeclaration(command = "sethome", permission = "plots.set.home", @@ -48,7 +49,7 @@ public class SetHome extends SetCommand { case "none": { Plot base = plot.getBasePlot(false); base.setHome(null); - return MainUtil.sendMessage(player, Captions.POSITION_UNSET); + player.sendMessage(TranslatableCaption.of("position.position_unset")); } case "": Plot base = plot.getBasePlot(false); @@ -57,9 +58,12 @@ public class SetHome extends SetCommand { BlockLoc rel = new BlockLoc(location.getX() - bottom.getX(), location.getY(), location.getZ() - bottom.getZ(), location.getYaw(), location.getPitch()); base.setHome(rel); - return MainUtil.sendMessage(player, Captions.POSITION_SET); + player.sendMessage(TranslatableCaption.of("position.position_set")); default: - MainUtil.sendMessage(player, Captions.HOME_ARGUMENT); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("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 7d450d15d..68c9be4a1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Setup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Setup.java @@ -28,11 +28,14 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.StaticCaption; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.generator.GeneratorWrapper; 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 javax.annotation.Nonnull; import java.util.ArrayList; @@ -67,14 +70,18 @@ public class Setup extends SubCommand { message.append("\n&8 - &7").append(entry.getKey()).append(" (Unknown structure)"); } } - MainUtil.sendMessage(player, message.toString()); + player.sendMessage(StaticCaption.of(message.toString())); } @Override public boolean onCommand(PlotPlayer player, String[] args) { SetupProcess process = player.getMeta("setup"); if (process == null) { if (args.length > 0) { - MainUtil.sendMessage(player, Captions.SETUP_NOT_STARTED); + player.sendMessage(TranslatableCaption.of("setup.setup_not_started")); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "Use /plot setup to start a setup process.") + ); return true; } process = new SetupProcess(); @@ -91,7 +98,7 @@ public class Setup extends SubCommand { process.getCurrentStep().announce(player); } else if ("cancel".equalsIgnoreCase(args[0])) { player.deleteMeta("setup"); - MainUtil.sendMessage(player, Captions.SETUP_CANCELLED); + player.sendMessage(TranslatableCaption.of("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 95b524b1b..0288406fa 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Swap.java +++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java @@ -26,12 +26,14 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; 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 java.util.concurrent.CompletableFuture; @@ -55,7 +57,7 @@ public class Swap extends SubCommand { } if (!plot1.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) { - MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); + player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return CompletableFuture.completedFuture(false); } if (args.length != 1) { @@ -67,26 +69,29 @@ public class Swap extends SubCommand { return CompletableFuture.completedFuture(false); } if (plot1.equals(plot2)) { - MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID); - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot copy "); + player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id")); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot copy ") + ); return CompletableFuture.completedFuture(false); } if (!plot1.getArea().isCompatible(plot2.getArea())) { - Captions.PLOTWORLD_INCOMPATIBLE.send(player); + player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible")); return CompletableFuture.completedFuture(false); } if (plot1.isMerged() || plot2.isMerged()) { - Captions.SWAP_MERGED.send(player); + player.sendMessage(TranslatableCaption.of("swap.swap_merged")); return CompletableFuture.completedFuture(false); } return plot1.move(plot2, () -> { }, true).thenApply(result -> { if (result) { - MainUtil.sendMessage(player, Captions.SWAP_SUCCESS); + player.sendMessage(TranslatableCaption.of("swap.swap_success")); return true; } else { - MainUtil.sendMessage(player, Captions.SWAP_OVERLAP); + player.sendMessage(TranslatableCaption.of("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 27f6ee602..321e8bfd4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Target.java +++ b/Core/src/main/java/com/plotsquared/core/command/Target.java @@ -25,15 +25,16 @@ */ package com.plotsquared.core.command; -import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.location.Location; 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; @CommandDeclaration(command = "target", - usage = "/plot target <|nearest>", + usage = "/plot target < | nearest>", description = "Target a plot with your compass", permission = "plots.target", requiredType = RequiredType.PLAYER, @@ -47,11 +48,14 @@ public class Target extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String[] args) { Location location = player.getLocation(); if (!location.isPlotArea()) { - MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); return false; } if (args.length == 0) { - MainUtil.sendMessage(player, this.getUsage()); + player.sendMessage( + TranslatableCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot target < | nearest>") + ); return false; } Plot target = null; @@ -65,14 +69,14 @@ public class Target extends SubCommand { } } if (target == null) { - MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS); + player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); return false; } } else if ((target = Plot.getPlotFromString(player, args[0], true)) == null) { return false; } target.getCenter(player::setCompassTarget); - MainUtil.sendMessage(player, Captions.COMPASS_TARGET); + player.sendMessage(TranslatableCaption.of("compass.compass_target")); 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 a3b6e0890..5cf788f9a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -28,17 +28,15 @@ package com.plotsquared.core.command; import com.google.inject.Inject; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.ConfigurationUtil; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.inject.annotations.WorldFile; -import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.InvalidConfigurationException; import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.events.TeleportCause; -import com.plotsquared.core.inject.annotations.WorldConfig; -import com.plotsquared.core.inject.annotations.WorldFile; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotManager; @@ -48,7 +46,6 @@ import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.setup.SettingsNodesWrapper; import com.plotsquared.core.util.FileBytes; import com.plotsquared.core.util.FileUtils; -import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.task.TaskManager; @@ -66,7 +63,7 @@ import java.util.zip.ZipOutputStream; @CommandDeclaration(command = "template", permission = "plots.admin", description = "Create or use a world template", - usage = "/plot template [import|export]