Making progress on messages

This commit is contained in:
Hannes Greule 2020-08-03 23:59:16 +02:00
parent 4fb590889a
commit 3fd3baaa47
10 changed files with 25 additions and 20 deletions

View File

@ -58,12 +58,15 @@ public class Leave extends Command {
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> 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();

View File

@ -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) {

View File

@ -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);
}

View File

@ -51,7 +51,7 @@ public class Near extends Command {
public CompletableFuture<Boolean> execute(PlotPlayer<?> player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> 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(), ", "))

View File

@ -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;
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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;

View File

@ -69,12 +69,12 @@ public class Trust extends Command {
RunnableVal2<Command, CommandResult> 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) {

View File

@ -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"));