Use CaptionUtility for formatting

This commit is contained in:
Hannes Greule 2020-02-18 00:58:21 +01:00
parent baeb9aa2af
commit 8df1248929
11 changed files with 33 additions and 28 deletions

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
@ -220,11 +221,11 @@ public class Auto extends SubCommand {
return true; return true;
} }
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player,
Captions.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) CaptionUtility.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)); CaptionUtility.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic));
return true; return true;
} }
} }

View File

@ -1,6 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.commands; package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
@ -58,7 +59,7 @@ public class Claim extends SubCommand {
"non-existent: " + schematic); "non-existent: " + schematic);
} }
if (!Permissions if (!Permissions
.hasPermission(player, Captions .hasPermission(player, CaptionUtility
.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) .format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -33,9 +34,9 @@ import java.util.concurrent.CompletableFuture;
case "add": case "add":
case "check": case "check":
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player,
Captions.format(Captions.PERMISSION_GRANT.getTranslated(), arg0))) { CaptionUtility.format(Captions.PERMISSION_GRANT.getTranslated(), arg0))) {
Captions.NO_PERMISSION.send(player, Captions.NO_PERMISSION.send(player,
Captions.format(Captions.PERMISSION_GRANT.getTranslated(), arg0)); CaptionUtility.format(Captions.PERMISSION_GRANT.getTranslated(), arg0));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (args.length > 2) { if (args.length > 2) {

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.Rating; import com.github.intellectualsites.plotsquared.plot.object.Rating;

View File

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType; import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag;
@ -138,9 +139,9 @@ public class ListCmd extends SubCommand {
} }
if (!Permissions if (!Permissions
.hasPermission(player, .hasPermission(player,
Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) { CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world));
return false; return false;
} }
plots = new ArrayList<>(PlotSquared.get().getPlots(world)); plots = new ArrayList<>(PlotSquared.get().getPlots(world));
@ -163,9 +164,9 @@ public class ListCmd extends SubCommand {
} }
if (!Permissions if (!Permissions
.hasPermission(player, .hasPermission(player,
Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) { CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world));
return false; return false;
} }
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots()); plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
@ -308,9 +309,9 @@ public class ListCmd extends SubCommand {
return false; return false;
} }
if (!Permissions if (!Permissions
.hasPermission(player, Captions .hasPermission(player, CaptionUtility
.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]))) { .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0])); .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]));
return false; return false;
} }

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.Command; import com.github.intellectualsites.plotsquared.commands.Command;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
@ -50,9 +51,9 @@ import java.util.stream.IntStream;
for (String component : components) { for (String component : components) {
if (component.equalsIgnoreCase(args[0])) { if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(player, Captions if (!Permissions.hasPermission(player, CaptionUtility
.format(Captions.PERMISSION_SET_COMPONENT.getTranslated(), component))) { .format(Captions.PERMISSION_SET_COMPONENT.getTranslated(), component))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_SET_COMPONENT.getTranslated(), .format(Captions.PERMISSION_SET_COMPONENT.getTranslated(),
component)); component));
return false; return false;

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.commands; package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
@ -19,9 +20,9 @@ public abstract class SetCommand extends SubCommand {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions if (!Permissions
.hasPermission(player, .hasPermission(player,
Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId())); CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()));
MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED); MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED);
return false; return false;
} }
@ -29,9 +30,9 @@ public abstract class SetCommand extends SubCommand {
if (!plot.isOwner(player.getUUID())) { if (!plot.isOwner(player.getUUID())) {
if (!Permissions if (!Permissions
.hasPermission(player, .hasPermission(player,
Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId())); CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()));
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -5,11 +5,10 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Configuration; import com.github.intellectualsites.plotsquared.plot.config.Configuration;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode; import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer; import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer; import com.github.intellectualsites.plotsquared.plot.flags.GlobalFlagContainer;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld; import com.github.intellectualsites.plotsquared.plot.generator.GridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;

View File

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.commands.CommandCaller; import com.github.intellectualsites.plotsquared.commands.CommandCaller;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType; import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
@ -623,7 +624,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
teleport(location); teleport(location);
sendMessage( sendMessage(
Captions.format(Captions.TELEPORTED_TO_PLOT.getTranslated()) CaptionUtility.format(Captions.TELEPORTED_TO_PLOT.getTranslated())
+ " (quitLoc) (" + plotX + " (quitLoc) (" + plotX
+ "," + plotZ + ")"); + "," + plotZ + ")");
} }
@ -635,7 +636,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
if (plot.isLoaded()) { if (plot.isLoaded()) {
teleport(location); teleport(location);
sendMessage(Captions.format( sendMessage(CaptionUtility.format(
Captions.TELEPORTED_TO_PLOT.getTranslated()) Captions.TELEPORTED_TO_PLOT.getTranslated())
+ " (quitLoc-unloaded) (" + plotX + "," + plotZ + " (quitLoc-unloaded) (" + plotX + "," + plotZ
+ ")"); + ")");

View File

@ -1,10 +1,10 @@
package com.github.intellectualsites.plotsquared.plot.util; package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DeviceInteractFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DeviceInteractFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscPlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MiscPlaceFlag;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag;
@ -26,8 +26,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
public abstract class EventUtil { public abstract class EventUtil {
@ -94,7 +92,7 @@ public abstract class EventUtil {
.getArea() instanceof SinglePlotArea)) { .getArea() instanceof SinglePlotArea)) {
TaskManager.runTask(() -> plot.teleportPlayer(player)); TaskManager.runTask(() -> plot.teleportPlayer(player));
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
Captions.format(Captions.TELEPORTED_TO_ROAD.getTranslated()) + " (on-login) " + "(" + plot.getId().x + ";" + plot CaptionUtility.format(Captions.TELEPORTED_TO_ROAD.getTranslated()) + " (on-login) " + "(" + plot.getId().x + ";" + plot
.getId().y + ")"); .getId().y + ")");
} }
} }

View File

@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -81,7 +82,7 @@ import java.util.Map;
@NonNull final String key, @NonNull final String block) { @NonNull final String key, @NonNull final String block) {
final BlockBucket bucket = this.blockToBucket(block); final BlockBucket bucket = this.blockToBucket(block);
this.setString(section, key, bucket); this.setString(section, key, bucket);
PlotSquared.log(Captions PlotSquared.log(CaptionUtility
.format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), block, bucket.toString())); .format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), block, bucket.toString()));
} }
@ -90,7 +91,7 @@ import java.util.Map;
final BlockState[] blocks = this.splitBlockList(blockList); final BlockState[] blocks = this.splitBlockList(blockList);
final BlockBucket bucket = this.blockListToBucket(blocks); final BlockBucket bucket = this.blockListToBucket(blocks);
this.setString(section, key, bucket); this.setString(section, key, bucket);
PlotSquared.log(Captions PlotSquared.log(CaptionUtility
.format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), plotBlockArrayString(blocks), .format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), plotBlockArrayString(blocks),
bucket.toString())); bucket.toString()));
} }