From 8df1248929d1eee5f340896e82e1eb8bc3e9b64a Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Tue, 18 Feb 2020 00:58:21 +0100 Subject: [PATCH] Use CaptionUtility for formatting --- .../plotsquared/plot/commands/Auto.java | 5 +++-- .../plotsquared/plot/commands/Claim.java | 3 ++- .../plotsquared/plot/commands/Grant.java | 5 +++-- .../plotsquared/plot/commands/Like.java | 2 +- .../plotsquared/plot/commands/ListCmd.java | 13 +++++++------ .../plotsquared/plot/commands/Set.java | 5 +++-- .../plotsquared/plot/commands/SetCommand.java | 9 +++++---- .../plotsquared/plot/object/PlotArea.java | 3 +-- .../plotsquared/plot/object/PlotPlayer.java | 5 +++-- .../plotsquared/plot/util/EventUtil.java | 6 ++---- .../plotsquared/plot/util/LegacyConverter.java | 5 +++-- 11 files changed, 33 insertions(+), 28 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java index 294e4668a..c2b0fe814 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; 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.Settings; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; @@ -220,11 +221,11 @@ public class Auto extends SubCommand { return true; } if (!Permissions.hasPermission(player, - Captions.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) + CaptionUtility.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)); + CaptionUtility.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)); return true; } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java index c6acc1010..d54b32117 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Claim.java @@ -1,6 +1,7 @@ package com.github.intellectualsites.plotsquared.plot.commands; 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.Settings; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; @@ -58,7 +59,7 @@ public class Claim extends SubCommand { "non-existent: " + schematic); } if (!Permissions - .hasPermission(player, Captions + .hasPermission(player, CaptionUtility .format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) && !Permissions .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java index a3d8855ec..9a6e74d57 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands; import com.github.intellectualsites.plotsquared.commands.Command; 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.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; @@ -33,9 +34,9 @@ import java.util.concurrent.CompletableFuture; case "add": case "check": if (!Permissions.hasPermission(player, - Captions.format(Captions.PERMISSION_GRANT.getTranslated(), arg0))) { + CaptionUtility.format(Captions.PERMISSION_GRANT.getTranslated(), arg0))) { Captions.NO_PERMISSION.send(player, - Captions.format(Captions.PERMISSION_GRANT.getTranslated(), arg0)); + CaptionUtility.format(Captions.PERMISSION_GRANT.getTranslated(), arg0)); return CompletableFuture.completedFuture(false); } if (args.length > 2) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java index 2ffd866e6..191ca458f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Like.java @@ -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.Settings; 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.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.Rating; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java index cecb42d56..1605fc397 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java @@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.plot.PlotSquared; 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.flags.implementations.DoneFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.PriceFlag; @@ -138,9 +139,9 @@ public class ListCmd extends SubCommand { } if (!Permissions .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, - Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); + CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); return false; } plots = new ArrayList<>(PlotSquared.get().getPlots(world)); @@ -163,9 +164,9 @@ public class ListCmd extends SubCommand { } if (!Permissions .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, - Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); + CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world)); return false; } plots = area == null ? new ArrayList() : new ArrayList<>(area.getPlots()); @@ -308,9 +309,9 @@ public class ListCmd extends SubCommand { return false; } if (!Permissions - .hasPermission(player, Captions + .hasPermission(player, CaptionUtility .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])); return false; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java index 438086b43..120d9d020 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands; import com.github.intellectualsites.plotsquared.commands.Command; 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.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; @@ -50,9 +51,9 @@ import java.util.stream.IntStream; for (String component : components) { if (component.equalsIgnoreCase(args[0])) { - if (!Permissions.hasPermission(player, Captions + if (!Permissions.hasPermission(player, CaptionUtility .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(), component)); return false; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SetCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SetCommand.java index 8ec4bee2c..8c2c0740a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SetCommand.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SetCommand.java @@ -1,5 +1,6 @@ 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.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Plot; @@ -19,9 +20,9 @@ public abstract class SetCommand extends SubCommand { if (!plot.hasOwner()) { if (!Permissions .hasPermission(player, - Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { + CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { 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); return false; } @@ -29,9 +30,9 @@ public abstract class SetCommand extends SubCommand { if (!plot.isOwner(player.getUUID())) { if (!Permissions .hasPermission(player, - Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { + CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { 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); return false; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java index 7ec5dd127..77ae1f5d8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java @@ -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.ConfigurationNode; 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.Flags; import com.github.intellectualsites.plotsquared.plot.flags.FlagContainer; 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.IndependentPlotGenerator; import com.github.intellectualsites.plotsquared.plot.util.EconHandler; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java index 6262af9f9..6aedc3b51 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java @@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.object; import com.github.intellectualsites.plotsquared.commands.CommandCaller; import com.github.intellectualsites.plotsquared.plot.PlotSquared; 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.Settings; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; @@ -623,7 +624,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { if (getMeta("teleportOnLogin", true)) { teleport(location); sendMessage( - Captions.format(Captions.TELEPORTED_TO_PLOT.getTranslated()) + CaptionUtility.format(Captions.TELEPORTED_TO_PLOT.getTranslated()) + " (quitLoc) (" + plotX + "," + plotZ + ")"); } @@ -635,7 +636,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { if (getMeta("teleportOnLogin", true)) { if (plot.isLoaded()) { teleport(location); - sendMessage(Captions.format( + sendMessage(CaptionUtility.format( Captions.TELEPORTED_TO_PLOT.getTranslated()) + " (quitLoc-unloaded) (" + plotX + "," + plotZ + ")"); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java index 4db1b1a14..dab84bc7f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java @@ -1,10 +1,10 @@ package com.github.intellectualsites.plotsquared.plot.util; 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.Settings; 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.MiscPlaceFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.MobPlaceFlag; @@ -26,8 +26,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; -import java.util.Optional; -import java.util.Set; import java.util.UUID; public abstract class EventUtil { @@ -94,7 +92,7 @@ public abstract class EventUtil { .getArea() instanceof SinglePlotArea)) { TaskManager.runTask(() -> plot.teleportPlayer(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 + ")"); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java index 38db9b9f4..b1418de50 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java @@ -2,6 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.util; import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection; 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.object.BlockBucket; import com.sk89q.worldedit.world.block.BlockState; @@ -81,7 +82,7 @@ import java.util.Map; @NonNull final String key, @NonNull final String block) { final BlockBucket bucket = this.blockToBucket(block); this.setString(section, key, bucket); - PlotSquared.log(Captions + PlotSquared.log(CaptionUtility .format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), block, bucket.toString())); } @@ -90,7 +91,7 @@ import java.util.Map; final BlockState[] blocks = this.splitBlockList(blockList); final BlockBucket bucket = this.blockListToBucket(blocks); this.setString(section, key, bucket); - PlotSquared.log(Captions + PlotSquared.log(CaptionUtility .format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), plotBlockArrayString(blocks), bucket.toString())); }