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 398beccf8..811898034 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Auto.java +++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java @@ -239,7 +239,9 @@ public class Auto extends SubCommand { PlayerAutoPlotEvent event = this.eventDispatcher .callAuto(player, plotarea, schematic, size_x, size_z); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Auto claim"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Auto claim")); return true; } boolean force = event.getEventResult() == Result.FORCE; @@ -320,7 +322,9 @@ public class Auto extends SubCommand { final PlotAutoMergeEvent mergeEvent = this.eventDispatcher .callAutoMerge(plotarea.getPlotAbs(pos1), plotIds); if (!force && mergeEvent.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Auto merge"); + player.sendMessage( + 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 d6b8ae94d..ec758a2e4 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Backup.java +++ b/Core/src/main/java/com/plotsquared/core/command/Backup.java @@ -31,6 +31,7 @@ import com.plotsquared.core.backup.BackupProfile; import com.plotsquared.core.backup.NullBackupProfile; import com.plotsquared.core.backup.PlayerBackupProfile; 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.Permissions; @@ -128,7 +129,7 @@ public final class Backup extends Command { final RunnableVal2 whenDone) { final Plot plot = player.getCurrentPlot(); if (plot == null) { - sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); } else if (!plot.hasOwner()) { sendMessage(player, Captions.BACKUP_IMPOSSIBLE, Captions.GENERIC_UNOWNED.getTranslated()); @@ -167,7 +168,7 @@ public final class Backup extends Command { final RunnableVal2 whenDone) { final Plot plot = player.getCurrentPlot(); if (plot == null) { - sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); } else if (!plot.hasOwner()) { sendMessage(player, Captions.BACKUP_IMPOSSIBLE, Captions.GENERIC_UNOWNED.getTranslated()); @@ -218,7 +219,7 @@ public final class Backup extends Command { final RunnableVal2 whenDone) { final Plot plot = player.getCurrentPlot(); if (plot == null) { - sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); } else if (!plot.hasOwner()) { sendMessage(player, Captions.BACKUP_IMPOSSIBLE, Captions.GENERIC_UNOWNED.getTranslated()); 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 c8fde1659..3b191e291 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Biome.java +++ b/Core/src/main/java/com/plotsquared/core/command/Biome.java @@ -26,13 +26,14 @@ 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.MainUtil; import com.plotsquared.core.util.StringMan; import com.sk89q.worldedit.command.util.SuggestionHelper; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeTypes; +import net.kyori.adventure.text.minimessage.Template; import java.util.Collection; import java.util.Locale; @@ -56,20 +57,22 @@ public class Biome extends SetCommand { if (biome == null) { String biomes = StringMan .join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated()); - Captions.NEED_BIOME.send(player); - MainUtil.sendMessage(player, - Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + biomes); + player.sendMessage(TranslatableCaption.of("biome.need_biome")); + player.sendMessage( + TranslatableCaption.of("commandconfig.subcommand_set_options_header"), + Template.of("values", biomes)); 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(); plot.setBiome(biome, () -> { plot.removeRunning(); - MainUtil - .sendMessage(player, Captions.BIOME_SET_TO.getTranslated() + value.toLowerCase()); + player.sendMessage( + TranslatableCaption.of("biome.biome_set_to"), + 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 cc73ef003..d5c6450ff 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Buy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java @@ -28,6 +28,7 @@ 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.TranslatableCaption; import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.player.PlotPlayer; @@ -39,6 +40,7 @@ import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MainUtil; 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; @@ -71,7 +73,10 @@ public class Buy extends Command { check(this.econHandler, Captions.ECON_DISABLED); final Plot plot; if (args.length != 0) { - checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); + if (args.length != 1) { + sendUsage(player); + return CompletableFuture.completedFuture(false); + } plot = check(MainUtil.getPlotFromString(player, args[0], true), null); } else { plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); @@ -90,13 +95,20 @@ public class Buy extends Command { // Failure // Success confirm.run(this, () -> { - Captions.REMOVED_BALANCE.send(player, price); + player.sendMessage( + TranslatableCaption.of("economy.removed_balance"), + Template.of("money", String.valueOf(price))); this.econHandler.depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price); PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()); if (owner != null) { - Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price); + owner.sendMessage( + TranslatableCaption.of("economy.plot_sold"), + Template.of("plot", plot.getId().toString()), + Template.of("player", player.getName()), + Template.of("price", String.valueOf(price)) + ); } PlotFlag plotFlag = plot.getFlagContainer().getFlag(PriceFlag.class); PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plotFlag, plot); @@ -104,7 +116,7 @@ public class Buy extends Command { plot.removeFlag(event.getFlag()); } plot.setOwner(player.getUUID()); - Captions.CLAIMED.send(player); + player.sendMessage(TranslatableCaption.of("working.claimed")); whenDone.run(Buy.this, CommandResult.SUCCESS); }, () -> { player.deposit(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 55efd2519..e90f19917 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Caps.java +++ b/Core/src/main/java/com/plotsquared/core/command/Caps.java @@ -26,6 +26,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.plot.flag.PlotFlag; @@ -36,6 +37,7 @@ import com.plotsquared.core.plot.flag.implementations.MiscCapFlag; import com.plotsquared.core.plot.flag.implementations.MobCapFlag; import com.plotsquared.core.plot.flag.implementations.VehicleCapFlag; import com.plotsquared.core.util.Permissions; +import net.kyori.adventure.text.minimessage.Template; import static com.plotsquared.core.util.entity.EntityCategories.CAP_ANIMAL; import static com.plotsquared.core.util.entity.EntityCategories.CAP_ENTITY; @@ -53,13 +55,17 @@ public class Caps extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, final String[] args) { final Plot plot = player.getCurrentPlot(); if (plot == null) { - return Captions.NOT_IN_PLOT.send(player); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.isAdded(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_CAPS_OTHER)) { - return Captions.NO_PERMISSION.send(player, Captions.PERMISSION_ADMIN_CAPS_OTHER); + player.sendMessage( + TranslatableCaption.of("permission.no_permission"), + Template.of("node", Captions.PERMISSION_ADMIN_CAPS_OTHER.getTranslated())); + return false; } - Captions.PLOT_CAPS_HEADER.send(player); + player.sendMessage(TranslatableCaption.of("info.plot_caps_header")); final int[] countedEntities = plot.countEntities(); sendFormatted(plot, player, MobCapFlag.class, countedEntities, "mobs", CAP_MOB); sendFormatted(plot, player, HostileCapFlag.class, countedEntities, "hostile", CAP_MONSTER); @@ -76,8 +82,10 @@ 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(Captions.PLOT_CAPS_FORMAT.getTranslated().replace("%cap%", name) - .replace("%current%", Integer.toString(current)) - .replace("%limit%", Integer.toString(max)).replace("%percentage%", percentage)); + player.sendMessage(TranslatableCaption.of("info.plot_caps_format"), + Template.of("cap", name), + Template.of("current", String.valueOf(current)), + Template.of("limit", String.valueOf(max)), + Template.of("percentage", percentage)); } } 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 c4b19d018..43686fd3c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Claim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Claim.java @@ -30,6 +30,7 @@ import com.google.inject.Inject; import com.plotsquared.core.configuration.CaptionUtility; 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.events.PlayerClaimPlotEvent; import com.plotsquared.core.events.PlotMergeEvent; @@ -44,8 +45,7 @@ import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.Expression; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.TaskManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import net.kyori.adventure.text.minimessage.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,12 +75,15 @@ public class Claim extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { - return sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } final PlayerClaimPlotEvent event = this.eventDispatcher.callClaim(player, plot, schematic); schematic = event.getSchematic(); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Claim"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Claim")); return true; } boolean force = event.getEventResult() == Result.FORCE; @@ -154,7 +157,9 @@ public class Claim extends SubCommand { PlotMergeEvent mergeEvent = Claim.this.eventDispatcher .callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player); if (mergeEvent.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim"); + player.sendMessage( + 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 6d58d64ae..ba5e2d598 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Clear.java +++ b/Core/src/main/java/com/plotsquared/core/command/Clear.java @@ -29,6 +29,7 @@ import com.google.inject.Inject; import com.plotsquared.core.backup.BackupManager; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.player.PlotPlayer; @@ -38,16 +39,14 @@ import com.plotsquared.core.plot.flag.implementations.AnalysisFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.util.EventDispatcher; -import com.plotsquared.core.util.MainUtil; 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; -import static com.plotsquared.core.command.SubCommand.sendMessage; - @CommandDeclaration(command = "clear", description = "Clear the plot you stand on", requiredType = RequiredType.NONE, @@ -72,11 +71,16 @@ public class Clear extends Command { public CompletableFuture execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { - checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage()); + if (args.length != 0) { + sendUsage(player); + return CompletableFuture.completedFuture(false); + } final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); Result eventResult = this.eventDispatcher.callClear(plot).getEventResult(); if (eventResult == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Clear"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Clear")); return CompletableFuture.completedFuture(true); } boolean force = eventResult == Result.FORCE; @@ -112,12 +116,14 @@ public class Clear extends Command { plot.removeFlag(event.getFlag()); } } - MainUtil.sendMessage(player, Captions.CLEARING_DONE, - "" + (System.currentTimeMillis() - start)); + player.sendMessage( + TranslatableCaption.of("working.clearing_done"), + Template.of("amount", String.valueOf(System.currentTimeMillis() - start)) + ); }); }); if (!result) { - MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER); + player.sendMessage(TranslatableCaption.of("errors.wait_for_timer")); } else { plot.addRunning(); } diff --git a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java index c8aee497c..61cbe1d4b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java +++ b/Core/src/main/java/com/plotsquared/core/command/CmdConfirm.java @@ -25,11 +25,11 @@ */ 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.util.MainUtil; import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskTime; +import net.kyori.adventure.text.minimessage.Template; public class CmdConfirm { @@ -45,7 +45,10 @@ public class CmdConfirm { final Runnable runnable) { removePending(player); if (commandStr != null) { - MainUtil.sendMessage(player, Captions.REQUIRES_CONFIRM, commandStr); + player.sendMessage( + TranslatableCaption.of("confirm.requires_confirm"), + Template.of("command", commandStr) + ); } TaskManager.runTaskLater(() -> { CmdInstance cmd = new CmdInstance(runnable); 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 12337c98c..cc89d5788 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java +++ b/Core/src/main/java/com/plotsquared/core/command/CommandCategory.java @@ -25,12 +25,16 @@ */ package com.plotsquared.core.command; +import com.plotsquared.core.configuration.Caption; import com.plotsquared.core.configuration.Captions; +import com.plotsquared.core.configuration.caption.LocaleHolder; + +import javax.annotation.Nonnull; /** * CommandCategory. */ -public enum CommandCategory { +public enum CommandCategory implements Caption { /** * Claiming CommandConfig. * Such as: /plot claim @@ -74,13 +78,20 @@ public enum CommandCategory { /** * The category name (Readable). */ - private final Captions caption; + private final Caption caption; - CommandCategory(final Captions caption) { + CommandCategory(final Caption caption) { this.caption = caption; } - @Override public String toString() { - return this.caption.getTranslated(); + // TODO this method shouldn't be invoked + @Deprecated @Override public String toString() { + return this.caption.getComponent(LocaleHolder.console()); + } + + @Nonnull + @Override + public String getComponent(@Nonnull LocaleHolder localeHolder) { + return this.caption.getComponent(localeHolder); } } 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 19f70fcd4..14d332890 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Condense.java +++ b/Core/src/main/java/com/plotsquared/core/command/Condense.java @@ -68,7 +68,7 @@ public class Condense extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length != 2 && args.length != 3) { - MainUtil.sendMessage(player, getUsage()); + sendUsage(player); return false; } PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]); diff --git a/Core/src/main/java/com/plotsquared/core/command/Continue.java b/Core/src/main/java/com/plotsquared/core/command/Continue.java index 16cfd3622..08311922b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Continue.java +++ b/Core/src/main/java/com/plotsquared/core/command/Continue.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.TranslatableCaption; import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.player.PlotPlayer; @@ -37,6 +38,7 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.Permissions; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -56,7 +58,8 @@ public class Continue extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String[] args) { Plot plot = player.getCurrentPlot(); if ((plot == null) || !plot.hasOwner()) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CONTINUE)) { @@ -82,7 +85,9 @@ public class Continue extends SubCommand { PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plotFlag, plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Done flag removal"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Done flag removal")); return true; } plot.removeFlag(event.getFlag()); diff --git a/Core/src/main/java/com/plotsquared/core/command/Copy.java b/Core/src/main/java/com/plotsquared/core/command/Copy.java index 6743074ff..a43604cd6 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Copy.java +++ b/Core/src/main/java/com/plotsquared/core/command/Copy.java @@ -26,6 +26,7 @@ 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; @@ -45,7 +46,8 @@ public class Copy extends SubCommand { Location location = player.getLocation(); Plot plot1 = location.getPlotAbs(); if (plot1 == null) { - return !MainUtil.sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot1.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) { @@ -53,7 +55,7 @@ public class Copy extends SubCommand { return false; } if (args.length != 1) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } Plot plot2 = MainUtil.getPlotFromString(player, args[0], true); @@ -62,7 +64,7 @@ public class Copy extends SubCommand { } if (plot1.equals(plot2)) { MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID); - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } if (!plot1.getArea().isCompatible(plot2.getArea())) { 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 d43d6f823..68b06cf37 100644 --- a/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java +++ b/Core/src/main/java/com/plotsquared/core/command/CreateRoadSchematic.java @@ -27,6 +27,7 @@ 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; import com.plotsquared.core.location.Location; @@ -55,7 +56,8 @@ public class CreateRoadSchematic extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { - return sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!(location.getPlotArea() instanceof HybridPlotWorld)) { return sendMessage(player, Captions.NOT_IN_PLOT_WORLD); 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 fc6bee9d8..c2bcc479d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -99,7 +99,7 @@ public class DatabaseCommand extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length < 1) { - MainUtil.sendMessage(player, getUsage()); + sendUsage(player); return false; } List plots; @@ -111,7 +111,7 @@ public class DatabaseCommand extends SubCommand { plots = PlotSquared.get().sortPlotsByTemp(PlotQuery.newQuery().allPlots().asList()); } if (args.length < 1) { - MainUtil.sendMessage(player, getUsage()); + sendUsage(player); MainUtil.sendMessage(player, "[arg] indicates an optional argument"); return false; } 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 0a5c6c4ed..b118c9c3b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -30,6 +30,7 @@ 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.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.Result; @@ -213,7 +214,7 @@ public class DebugExec extends SubCommand { case "analyze": { Plot plot = player.getCurrentPlot(); if (plot == null) { - MainUtil.sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } PlotAnalysis analysis = plot.getComplexity(null); diff --git a/Core/src/main/java/com/plotsquared/core/command/Delete.java b/Core/src/main/java/com/plotsquared/core/command/Delete.java index 1dc054085..cf2afbff8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Delete.java +++ b/Core/src/main/java/com/plotsquared/core/command/Delete.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.TranslatableCaption; import com.plotsquared.core.events.Result; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -39,6 +40,7 @@ import com.plotsquared.core.util.Expression; import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nullable; @@ -67,14 +69,18 @@ public class Delete extends SubCommand { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { - return !sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); + return false; } Result eventResult = this.eventDispatcher.callDelete(plot).getEventResult(); if (eventResult == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Delete"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Delete")); return true; } boolean force = eventResult == Result.FORCE; diff --git a/Core/src/main/java/com/plotsquared/core/command/Deny.java b/Core/src/main/java/com/plotsquared/core/command/Deny.java index 827d19134..10ba558c3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Deny.java +++ b/Core/src/main/java/com/plotsquared/core/command/Deny.java @@ -28,6 +28,7 @@ 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.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -72,7 +73,8 @@ public class Deny extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); 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 84f3c24e2..2bf99eafc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Desc.java +++ b/Core/src/main/java/com/plotsquared/core/command/Desc.java @@ -27,6 +27,7 @@ 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; import com.plotsquared.core.events.Result; @@ -35,6 +36,7 @@ import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.implementations.DescriptionFlag; import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MainUtil; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -57,7 +59,9 @@ public class Desc extends SetCommand { if (desc.isEmpty()) { PlotFlagRemoveEvent event = this.eventDispatcher.callFlagRemove(plot.getFlagContainer().getFlag(DescriptionFlag.class), plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Description removal"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Description removal")); return false; } plot.removeFlag(event.getFlag()); @@ -66,7 +70,9 @@ public class Desc extends SetCommand { } PlotFlagAddEvent event = this.eventDispatcher.callFlagAdd(plot.getFlagContainer().getFlag(DescriptionFlag.class).createFlagInstance(desc), plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Description set"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Description set")); return false; } boolean result = plot.setFlag(event.getFlag()); diff --git a/Core/src/main/java/com/plotsquared/core/command/Done.java b/Core/src/main/java/com/plotsquared/core/command/Done.java index 492c2c7c0..92ef0331e 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Done.java +++ b/Core/src/main/java/com/plotsquared/core/command/Done.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.TranslatableCaption; import com.plotsquared.core.events.PlotDoneEvent; import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.Result; @@ -43,6 +44,7 @@ import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.task.RunnableVal; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -67,11 +69,14 @@ public class Done extends SubCommand { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if ((plot == null) || !plot.hasOwner()) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } PlotDoneEvent event = this.eventDispatcher.callDone(plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Done"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Done")); return true; } boolean force = event.getEventResult() == Result.FORCE; 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 26908b78a..98fab0d99 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Download.java +++ b/Core/src/main/java/com/plotsquared/core/command/Download.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.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.flag.implementations.DoneFlag; @@ -71,7 +72,8 @@ public class Download extends SubCommand { } final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); @@ -132,7 +134,7 @@ public class Download extends SubCommand { } }); } else { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } MainUtil.sendMessage(player, Captions.GENERATING_LINK); 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 3dbea33dd..17c3ca605 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -29,6 +29,7 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.Result; @@ -154,7 +155,7 @@ public final class FlagCommand extends Command { final Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { - MainUtil.sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } if (!plot.hasOwner()) { @@ -299,7 +300,9 @@ public final class FlagCommand extends Command { Plot plot = player.getLocation().getPlotAbs(); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Flag set"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Flag set")); return; } boolean force = event.getEventResult() == Result.FORCE; @@ -344,7 +347,9 @@ public final class FlagCommand extends Command { Plot plot = player.getLocation().getPlotAbs(); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Flag add"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Flag add")); return; } boolean force = event.getEventResult() == Result.FORCE; @@ -401,7 +406,9 @@ public final class FlagCommand extends Command { final Plot plot = player.getLocation().getPlotAbs(); PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Flag remove"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Flag remove")); return; } boolean force = event.getEventResult() == Result.FORCE; diff --git a/Core/src/main/java/com/plotsquared/core/command/Grant.java b/Core/src/main/java/com/plotsquared/core/command/Grant.java index 59c1453a8..1dbf722bd 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Grant.java +++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java @@ -112,7 +112,7 @@ public class Grant extends Command { }); return CompletableFuture.completedFuture(true); } - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return CompletableFuture.completedFuture(true); } } 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 ef4b5a753..1967e47af 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Help.java +++ b/Core/src/main/java/com/plotsquared/core/command/Help.java @@ -78,7 +78,7 @@ public class Help extends Command { } return CompletableFuture.completedFuture(false); default: - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); } return CompletableFuture.completedFuture(true); } diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java index 4dfe67e73..cd551e21c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -106,7 +106,7 @@ public class HomeCommand extends Command { return CompletableFuture.completedFuture(false); } if (args.length > 2) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return CompletableFuture.completedFuture(false); } PlotQuery query = query(player); 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 a042e72cb..f654481a8 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Inbox.java +++ b/Core/src/main/java/com/plotsquared/core/command/Inbox.java @@ -26,6 +26,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.plot.comment.CommentInbox; @@ -89,7 +90,7 @@ public class Inbox extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { final Plot plot = player.getCurrentPlot(); if (plot == null) { - sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } if (!plot.hasOwner()) { @@ -97,7 +98,7 @@ public class Inbox extends SubCommand { return false; } if (args.length == 0) { - sendMessage(player, Captions.COMMAND_SYNTAX, getUsage()); + sendUsage(player); for (final CommentInbox inbox : CommentManager.inboxes.values()) { if (inbox.canRead(plot, player)) { if (!inbox.getComments(plot, new RunnableVal>() { @@ -185,7 +186,7 @@ public class Inbox extends SubCommand { } } })) { - sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } return true; @@ -204,7 +205,7 @@ public class Inbox extends SubCommand { try { page = Integer.parseInt(args[1]); } catch (NumberFormatException ignored) { - sendMessage(player, Captions.COMMAND_SYNTAX, getUsage()); + sendUsage(player); 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 2cb0d686f..b1140eea1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Kick.java +++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java @@ -28,6 +28,7 @@ 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.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -69,7 +70,8 @@ public class Kick extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_KICK)) { 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 a504451e5..aa2946d57 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Like.java +++ b/Core/src/main/java/com/plotsquared/core/command/Like.java @@ -29,6 +29,7 @@ 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.events.PlotRateEvent; import com.plotsquared.core.events.TeleportCause; @@ -92,7 +93,8 @@ public class Like extends SubCommand { case "purge": { final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_RATE, true)) { @@ -106,7 +108,8 @@ public class Like extends SubCommand { } final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { sendMessage(player, Captions.RATING_NOT_OWNED); 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 77327d662..81f3866f7 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.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; @@ -70,7 +71,8 @@ public class Load extends SubCommand { } final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); 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 4650fc277..e926e66f2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Merge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Merge.java @@ -29,6 +29,7 @@ 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.events.PlotMergeEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.location.Direction; @@ -42,6 +43,7 @@ import com.plotsquared.core.util.Expression; import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringMan; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -95,7 +97,8 @@ public class Merge extends SubCommand { Location location = player.getLocationFull(); final Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); @@ -141,7 +144,9 @@ public class Merge extends SubCommand { PlotMergeEvent event = this.eventDispatcher.callMerge(plot, direction, max, player); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Merge"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Merge")); return false; } boolean force = event.getEventResult() == Result.FORCE; diff --git a/Core/src/main/java/com/plotsquared/core/command/Middle.java b/Core/src/main/java/com/plotsquared/core/command/Middle.java index 14c760eef..5ea239c3d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Middle.java +++ b/Core/src/main/java/com/plotsquared/core/command/Middle.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.events.TeleportCause; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -46,7 +46,8 @@ public class Middle extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlot(); if (plot == null) { - return sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND)); 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 0cd328f05..5cdb817c2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -27,6 +27,7 @@ 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.location.Location; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -61,8 +62,8 @@ public class Move extends SubCommand { Location location = player.getLocation(); Plot plot1 = location.getPlotAbs(); if (plot1 == null) { - return CompletableFuture - .completedFuture(!MainUtil.sendMessage(player, Captions.NOT_IN_PLOT)); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return CompletableFuture.completedFuture(false); } if (!plot1.isOwner(player.getUUID()) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) { @@ -75,7 +76,7 @@ public class Move extends SubCommand { override = true; } if (args.length != 1) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return CompletableFuture.completedFuture(false); } PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]); 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 6892231db..078fbf429 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -27,6 +27,7 @@ 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; import com.plotsquared.core.events.Result; @@ -39,6 +40,7 @@ import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.implementations.MusicFlag; import com.plotsquared.core.util.InventoryUtil; import com.sk89q.worldedit.world.item.ItemTypes; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nullable; import java.util.Arrays; @@ -68,7 +70,8 @@ public class Music extends SubCommand { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.isAdded(player.getUUID())) { sendMessage(player, Captions.NO_PLOT_PERMS); @@ -85,7 +88,9 @@ public class Music extends SubCommand { .createFlagInstance(item.getType()); PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(plotFlag, plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Music removal"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Music removal")); return true; } plot.removeFlag(event.getFlag()); @@ -95,7 +100,9 @@ public class Music extends SubCommand { .createFlagInstance(item.getType()); PlotFlagAddEvent event = new PlotFlagAddEvent(plotFlag, plot); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Music addition"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Music addition")); return true; } plot.setFlag(event.getFlag()); 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 a15f1de80..0a523ffd2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -29,6 +29,7 @@ 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.events.PlotChangeOwnerEvent; import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.Result; @@ -38,6 +39,7 @@ import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.MainUtil; 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.Set; @@ -77,7 +79,9 @@ public class Owner extends SetCommand { PlotChangeOwnerEvent event = this.eventDispatcher.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid, plot.hasOwner()); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Owner change"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Owner change")); return; } uuid = event.getNewOwner(); @@ -90,7 +94,9 @@ public class Owner extends SetCommand { } PlotUnlinkEvent unlinkEvent = this.eventDispatcher.callUnlink(plot.getArea(), plot, false, false, PlotUnlinkEvent.REASON.NEW_OWNER); if (unlinkEvent.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Unlink on owner change"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Unlink on owner change")); return; } plot.unlinkPlot(unlinkEvent.isCreateRoad(), unlinkEvent.isCreateRoad()); 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 398713849..578f4397b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Purge.java +++ b/Core/src/main/java/com/plotsquared/core/command/Purge.java @@ -71,7 +71,7 @@ public class Purge extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 0) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } @@ -84,7 +84,7 @@ public class Purge extends SubCommand { for (String arg : args) { String[] split = arg.split(":"); if (split.length != 2) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } switch (split[0].toLowerCase()) { @@ -133,7 +133,7 @@ public class Purge extends SubCommand { clear = Boolean.parseBoolean(split[1]); break; default: - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } } 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 dedfdccd4..0b8bbf66f 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Rate.java +++ b/Core/src/main/java/com/plotsquared/core/command/Rate.java @@ -29,6 +29,7 @@ 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.events.PlotRateEvent; import com.plotsquared.core.events.TeleportCause; @@ -109,7 +110,8 @@ public class Rate extends SubCommand { case "purge": { final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_RATE, true)) { @@ -123,7 +125,8 @@ public class Rate extends SubCommand { } final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { sendMessage(player, Captions.RATING_NOT_OWNED); 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 500a53212..b35c1fb99 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Remove.java +++ b/Core/src/main/java/com/plotsquared/core/command/Remove.java @@ -27,6 +27,7 @@ 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.database.DBFunc; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; @@ -62,7 +63,8 @@ public class Remove extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); 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 760c9e38c..866800830 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -27,6 +27,7 @@ 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.location.Location; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -67,7 +68,8 @@ public class Save extends SubCommand { } final Plot plot = player.getCurrentPlot(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); 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 927998d1d..8ae2ca434 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.TranslatableCaption; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.PlotPlayer; @@ -87,7 +88,8 @@ public class SchematicCmd extends SubCommand { Location loc = player.getLocation(); final Plot plot = loc.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); @@ -195,7 +197,8 @@ public class SchematicCmd extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); 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 35f11b822..d88506453 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Set.java +++ b/Core/src/main/java/com/plotsquared/core/command/Set.java @@ -30,6 +30,7 @@ import com.plotsquared.core.backup.BackupManager; import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.PlotArea; @@ -204,7 +205,7 @@ public class Set extends SubCommand { // Additional checks Plot plot = player.getCurrentPlot(); if (plot == null) { - MainUtil.sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); return false; } // components diff --git a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java index aede7e779..181f58cf2 100644 --- a/Core/src/main/java/com/plotsquared/core/command/SetCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/SetCommand.java @@ -27,6 +27,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.CaptionUtility; 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; @@ -40,7 +41,8 @@ public abstract class SetCommand extends SubCommand { Location location = player.getLocation(); Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { if (!Permissions.hasPermission(player, CaptionUtility 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 9e7ce5208..43f95684d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Swap.java +++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java @@ -60,7 +60,7 @@ public class Swap extends SubCommand { return CompletableFuture.completedFuture(false); } if (args.length != 1) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return CompletableFuture.completedFuture(false); } Plot plot2 = MainUtil.getPlotFromString(player, args[0], 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 7794b81d8..fe8e491f0 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Template.java +++ b/Core/src/main/java/com/plotsquared/core/command/Template.java @@ -173,7 +173,7 @@ public class Template extends SubCommand { return true; } } - MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, getUsage()); + sendUsage(player); return true; } final String world = args[1]; @@ -246,7 +246,7 @@ public class Template extends SubCommand { }); return true; default: - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); } return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Trim.java b/Core/src/main/java/com/plotsquared/core/command/Trim.java index c52d2b996..9b608ca80 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trim.java @@ -127,7 +127,7 @@ public class Trim extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, String[] args) { if (args.length == 0) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } final String world = args[0]; diff --git a/Core/src/main/java/com/plotsquared/core/command/Unlink.java b/Core/src/main/java/com/plotsquared/core/command/Unlink.java index 27f05b618..0075ecb7b 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java +++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java @@ -27,6 +27,7 @@ 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.PlotUnlinkEvent; import com.plotsquared.core.events.Result; import com.plotsquared.core.location.Location; @@ -37,6 +38,7 @@ import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.task.TaskManager; +import net.kyori.adventure.text.minimessage.Template; import javax.annotation.Nonnull; @@ -59,7 +61,8 @@ public class Unlink extends SubCommand { Location location = player.getLocation(); final Plot plot = location.getPlotAbs(); if (plot == null) { - return !sendMessage(player, Captions.NOT_IN_PLOT); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot")); + return false; } if (!plot.hasOwner()) { return !sendMessage(player, Captions.PLOT_UNOWNED); @@ -70,7 +73,7 @@ public class Unlink extends SubCommand { final boolean createRoad; if (args.length != 0) { if (args.length != 1 || !StringMan.isEqualIgnoreCaseToAny(args[0], "true", "false")) { - Captions.COMMAND_SYNTAX.send(player, getUsage()); + sendUsage(player); return false; } createRoad = Boolean.parseBoolean(args[0]); @@ -82,7 +85,9 @@ public class Unlink extends SubCommand { .callUnlink(plot.getArea(), plot, createRoad, createRoad, PlotUnlinkEvent.REASON.PLAYER_COMMAND); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Unlink"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Unlink")); return true; } boolean force = event.getEventResult() == Result.FORCE; diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index c8527b530..d6bd6c26d 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -32,6 +32,7 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.events.PlotComponentSetEvent; import com.plotsquared.core.events.PlotMergeEvent; @@ -75,6 +76,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockTypes; +import net.kyori.adventure.text.minimessage.Template; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1828,7 +1830,9 @@ public class Plot { PlotMergeEvent event = this.eventDispatcher .callMerge(this, Direction.ALL, Integer.MAX_VALUE, player); if (event.getEventResult() == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Auto merge on claim"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Auto merge on claim")); return; } Plot.this.autoMerge(event.getDir(), event.getMax(), uuid, true); @@ -2978,7 +2982,9 @@ public class Plot { this.eventDispatcher.callTeleport(player, player.getLocation(), plot) .getEventResult(); if (result == Result.DENY) { - sendMessage(player, Captions.EVENT_DENIED, "Teleport"); + player.sendMessage( + TranslatableCaption.of("events.event_denied"), + Template.of("value", "Teleport")); resultConsumer.accept(false); return; } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 9d8fcb2c4..f8c6adc80 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -256,7 +256,7 @@ "blocklist.block_list_separator": ", ", "biome.need_biome": "You need to specify a valid biome.", - "biome.biome_set_to": "Plot biome set to ", + "biome.biome_set_to": "Plot biome set to ", "teleport.teleported_to_plot": "You have been teleported.", "teleport.teleported_to_road": "You got teleported to the road.", @@ -300,8 +300,7 @@ "info.plot_no_description": "No description set.", "info.info_syntax_console": "/plot info X;Z", "info.plot_caps_header": "--------- CAPS ---------", - - "infoplot_caps_format": "- Cap Type: | Status: / (%)", + "info.plot_caps_format": "- Cap Type: | Status: / (%)", "working.generating_component": "Started generating component from your settings.", "working.clearing_done": "Clear completed! Took ms.",