From 3fd3baaa47040da49c5e766be5fc7861f745407a Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Mon, 3 Aug 2020 23:59:16 +0200 Subject: [PATCH] Making progress on messages --- .../java/com/plotsquared/core/command/Leave.java | 13 ++++++++----- .../java/com/plotsquared/core/command/Load.java | 3 ++- .../java/com/plotsquared/core/command/Move.java | 4 ++-- .../java/com/plotsquared/core/command/Near.java | 2 +- .../java/com/plotsquared/core/command/Owner.java | 2 +- .../java/com/plotsquared/core/command/Save.java | 3 ++- .../java/com/plotsquared/core/command/Swap.java | 6 +++--- .../java/com/plotsquared/core/command/Toggle.java | 1 - .../java/com/plotsquared/core/command/Trust.java | 8 ++++---- .../java/com/plotsquared/core/command/Unlink.java | 3 ++- 10 files changed, 25 insertions(+), 20 deletions(-) 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 c2aa48394..e08aa2d47 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Leave.java +++ b/Core/src/main/java/com/plotsquared/core/command/Leave.java @@ -58,12 +58,15 @@ public class Leave extends Command { public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { - final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); - checkTrue(plot.hasOwner(), Captions.PLOT_UNOWNED); - checkTrue(plot.isAdded(player.getUUID()), Captions.NOT_ADDED_TRUSTED); - checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage()); + final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); + checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); + checkTrue(plot.isAdded(player.getUUID()), TranslatableCaption.of("member.not_added_trusted")); + if (args.length == 0) { + sendUsage(player); + return CompletableFuture.completedFuture(false); + } if (plot.isOwner(player.getUUID())) { - checkTrue(plot.hasOwner(), Captions.ALREADY_OWNER); + checkTrue(plot.hasOwner(), TranslatableCaption.of("member.already_owner")); // TODO setowner, other } else { UUID uuid = player.getUUID(); 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 8a98ae072..e50fa183a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Load.java +++ b/Core/src/main/java/com/plotsquared/core/command/Load.java @@ -71,7 +71,8 @@ public class Load extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, final String[] args) { final String world = player.getLocation().getWorldName(); if (!this.plotAreaManager.hasPlotArea(world)) { - return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); + return false; } final Plot plot = player.getCurrentPlot(); if (plot == null) { 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 16d19520a..bbe34d211 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Move.java +++ b/Core/src/main/java/com/plotsquared/core/command/Move.java @@ -66,7 +66,7 @@ public class Move extends SubCommand { return CompletableFuture.completedFuture(false); } if (!plot1.isOwner(player.getUUID()) && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) { + .hasPermission(player, Captions.PERMISSION_ADMIN)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return CompletableFuture.completedFuture(false); } @@ -98,7 +98,7 @@ public class Move extends SubCommand { return CompletableFuture.completedFuture(false); } if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated()))) { + .hasPermission(player, Captions.PERMISSION_ADMIN))) { player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible")); return CompletableFuture.completedFuture(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 44dce1449..2ae21fd60 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Near.java +++ b/Core/src/main/java/com/plotsquared/core/command/Near.java @@ -51,7 +51,7 @@ public class Near extends Command { public CompletableFuture execute(PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) throws CommandException { - final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT); + final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); player.sendMessage( TranslatableCaption.of("near.plot_near"), Template.of("list", StringMan.join(plot.getPlayersInPlot(), ", ")) 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 7d5b69fa4..c713af479 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -95,7 +95,7 @@ public class Owner extends SetCommand { boolean force = event.getEventResult() == Result.FORCE; if (uuid == null) { if (!force && !Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.getTranslated(), + .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER, true)) { return; } 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 080118bb9..86926fe89 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -65,7 +65,8 @@ public class Save extends SubCommand { @Override public boolean onCommand(final PlotPlayer player, final String[] args) { final String world = player.getLocation().getWorldName(); if (!this.plotAreaManager.hasPlotArea(world)) { - return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD); + player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); + return false; } final Plot plot = player.getCurrentPlot(); if (plot == 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 0288406fa..5c16dd351 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Swap.java +++ b/Core/src/main/java/com/plotsquared/core/command/Swap.java @@ -52,11 +52,11 @@ public class Swap 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())) { + .hasPermission(player, Captions.PERMISSION_ADMIN)) { player.sendMessage(TranslatableCaption.of("permission.no_plot_perms")); return CompletableFuture.completedFuture(false); } diff --git a/Core/src/main/java/com/plotsquared/core/command/Toggle.java b/Core/src/main/java/com/plotsquared/core/command/Toggle.java index 566565e1c..53c94440a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Toggle.java +++ b/Core/src/main/java/com/plotsquared/core/command/Toggle.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; import com.plotsquared.core.util.task.RunnableVal2; diff --git a/Core/src/main/java/com/plotsquared/core/command/Trust.java b/Core/src/main/java/com/plotsquared/core/command/Trust.java index e5ba1617e..20f5db2cc 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trust.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trust.java @@ -69,12 +69,12 @@ public class Trust extends Command { RunnableVal2 whenDone) throws CommandException { final Plot currentPlot = player.getCurrentPlot(); if (currentPlot == null) { - throw new CommandException(Captions.NOT_IN_PLOT); + throw new CommandException(TranslatableCaption.of("errors.not_in_plot")); } - checkTrue(currentPlot.hasOwner(), Captions.PLOT_UNOWNED); + checkTrue(currentPlot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue(currentPlot.isOwner(player.getUUID()) || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), - Captions.NO_PLOT_PERMS); + TranslatableCaption.of("permission.no_plot_perms")); checkTrue(args.length == 1, TranslatableCaption.of("commandconfig.command_syntax"), Templates.of("value", getUsage())); @@ -131,7 +131,7 @@ public class Trust extends Command { checkTrue(!uuids.isEmpty(), null); checkTrue(size <= currentPlot.getArea().getMaxPlotMembers() || Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST), - Captions.PLOT_MAX_MEMBERS); + TranslatableCaption.of("member.plot_max_members")); // Success confirm.run(this, () -> { for (UUID uuid : uuids) { 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 ac4056a0e..9450720bf 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Unlink.java +++ b/Core/src/main/java/com/plotsquared/core/command/Unlink.java @@ -64,7 +64,8 @@ public class Unlink extends SubCommand { return false; } if (!plot.hasOwner()) { - return !sendMessage(player, Captions.PLOT_UNOWNED); + player.sendMessage(TranslatableCaption.of("info.plot_unowned")); + return false; } if (!plot.isMerged()) { player.sendMessage(TranslatableCaption.of("merge.unlink_impossible"));