Remove deprecated method from Captions.java

This commit is contained in:
MattBDev 2019-12-06 21:18:56 -05:00
parent 05d6d557b8
commit 7760631751
13 changed files with 66 additions and 49 deletions

View File

@ -317,7 +317,8 @@ import java.util.zip.ZipInputStream;
e.printStackTrace(); e.printStackTrace();
} }
PlotSquared.log(Captions.PREFIX + Captions.ENABLED.f(IMP.getPluginName())); PlotSquared.log(Captions.PREFIX + Captions
.format(Captions.ENABLED.getTranslated(), IMP.getPluginName()));
} }
/** /**

View File

@ -218,11 +218,12 @@ public class Auto extends SubCommand {
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;
} }
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) if (!Permissions.hasPermission(player,
Captions.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.PERMISSION_CLAIM_SCHEMATIC.f(schematic)); Captions.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic));
return true; return true;
} }
} }

View File

@ -11,7 +11,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
import com.github.intellectualsites.plotsquared.plot.util.EconHandler; import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@ -59,7 +58,8 @@ public class Claim extends SubCommand {
"non-existent: " + schematic); "non-existent: " + schematic);
} }
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) .hasPermission(player, Captions
.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic); return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic);

View File

@ -40,8 +40,9 @@ public class FlagCmd extends SubCommand {
private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) { private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) {
key = key.toLowerCase(); key = key.toLowerCase();
value = value.toLowerCase(); value = value.toLowerCase();
String perm = String perm = Captions
Captions.PERMISSION_SET_FLAG_KEY_VALUE.f(key.toLowerCase(), value.toLowerCase()); .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(),
value.toLowerCase());
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) { if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
try { try {
int numeric = Integer.parseInt(value); int numeric = Integer.parseInt(value);
@ -52,9 +53,9 @@ public class FlagCmd extends SubCommand {
Settings.Limit.MAX_PLOTS; Settings.Limit.MAX_PLOTS;
final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric; final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric;
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
Captions.PERMISSION_SET_FLAG_KEY_VALUE .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
.f(key.toLowerCase(), value.toLowerCase())); key.toLowerCase(), value.toLowerCase()));
} }
return result; return result;
} }
@ -65,13 +66,14 @@ public class FlagCmd extends SubCommand {
final BlockStateListFlag blockListFlag = (BlockStateListFlag) flag; final BlockStateListFlag blockListFlag = (BlockStateListFlag) flag;
Set<BlockType> parsedBlocks = blockListFlag.parseValue(value); Set<BlockType> parsedBlocks = blockListFlag.parseValue(value);
for (final BlockType block : parsedBlocks) { for (final BlockType block : parsedBlocks) {
final String permission = Captions.PERMISSION_SET_FLAG_KEY_VALUE final String permission = Captions
.f(key.toLowerCase(), block.toString().toLowerCase()); .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
key.toLowerCase(), block.toString().toLowerCase());
final boolean result = Permissions.hasPermission(player, permission); final boolean result = Permissions.hasPermission(player, permission);
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
Captions.PERMISSION_SET_FLAG_KEY_VALUE .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
.f(key.toLowerCase(), value.toLowerCase())); key.toLowerCase(), value.toLowerCase()));
return false; return false;
} }
} }
@ -79,8 +81,9 @@ public class FlagCmd extends SubCommand {
} }
final boolean result = Permissions.hasPermission(player, perm); final boolean result = Permissions.hasPermission(player, perm);
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
Captions.PERMISSION_SET_FLAG_KEY_VALUE.f(key.toLowerCase(), value.toLowerCase())); .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(),
value.toLowerCase()));
} }
return result; return result;
} }
@ -196,11 +199,13 @@ public class FlagCmd extends SubCommand {
"/plot flag remove <flag> [values]"); "/plot flag remove <flag> [values]");
return false; return false;
} }
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player, Captions
Captions.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()))) { .format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[1].toLowerCase()))) {
if (args.length != 3) { if (args.length != 3) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
Captions.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase())); .format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[1].toLowerCase()));
return false; return false;
} }
for (String entry : args[2].split(",")) { for (String entry : args[2].split(",")) {

View File

@ -32,8 +32,10 @@ import java.util.concurrent.CompletableFuture;
switch (arg0) { switch (arg0) {
case "add": case "add":
case "check": case "check":
if (!Permissions.hasPermission(player, Captions.PERMISSION_GRANT.f(arg0))) { if (!Permissions.hasPermission(player,
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_GRANT.f(arg0)); Captions.format(Captions.PERMISSION_GRANT.getTranslated(), arg0))) {
Captions.NO_PERMISSION.send(player,
Captions.format(Captions.PERMISSION_GRANT.getTranslated(), arg0));
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
if (args.length > 2) { if (args.length > 2) {

View File

@ -137,9 +137,10 @@ public class ListCmd extends SubCommand {
return false; return false;
} }
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_LIST_WORLD_NAME.f(world))) { .hasPermission(player,
Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_LIST_WORLD_NAME.f(world)); Captions.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));
@ -161,9 +162,10 @@ public class ListCmd extends SubCommand {
return false; return false;
} }
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_LIST_WORLD_NAME.f(world))) { .hasPermission(player,
Captions.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_LIST_WORLD_NAME.f(world)); Captions.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 +310,10 @@ public class ListCmd extends SubCommand {
return false; return false;
} }
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_LIST_WORLD_NAME.f(args[0]))) { .hasPermission(player, Captions
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]))) {
Captions.PERMISSION_LIST_WORLD_NAME.f(args[0])); MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]));
return false; return false;
} }
plots = new ArrayList<>(PlotSquared.get().getPlots(args[0])); plots = new ArrayList<>(PlotSquared.get().getPlots(args[0]));

View File

@ -50,10 +50,11 @@ 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, if (!Permissions.hasPermission(player, Captions
Captions.PERMISSION_SET_COMPONENT.f(component))) { .format(Captions.PERMISSION_SET_COMPONENT.getTranslated(), component))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions
Captions.PERMISSION_SET_COMPONENT.f(component)); .format(Captions.PERMISSION_SET_COMPONENT.getTranslated(),
component));
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {

View File

@ -18,18 +18,20 @@ public abstract class SetCommand extends SubCommand {
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND.f(getFullId()))) { .hasPermission(player,
Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_ADMIN_COMMAND.f(getFullId())); Captions.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;
} }
} }
if (!plot.isOwner(player.getUUID())) { if (!plot.isOwner(player.getUUID())) {
if (!Permissions if (!Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND.f(getFullId()))) { .hasPermission(player,
Captions.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_ADMIN_COMMAND.f(getFullId())); Captions.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

@ -774,10 +774,6 @@ public enum Captions {
} }
} }
@Deprecated public String f(final Object... args) {
return format(getTranslated(), args);
}
@Override public String toString() { @Override public String toString() {
return this.translatedString; return this.translatedString;
} }

View File

@ -612,7 +612,8 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
if (getMeta("teleportOnLogin", true)) { if (getMeta("teleportOnLogin", true)) {
teleport(location); teleport(location);
sendMessage( sendMessage(
Captions.TELEPORTED_TO_PLOT.f() + " (quitLoc) (" + plotX Captions.format(Captions.TELEPORTED_TO_PLOT.getTranslated())
+ " (quitLoc) (" + plotX
+ "," + plotZ + ")"); + "," + plotZ + ")");
} }
}); });
@ -623,7 +624,8 @@ 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.TELEPORTED_TO_PLOT.f() sendMessage(Captions.format(
Captions.TELEPORTED_TO_PLOT.getTranslated())
+ " (quitLoc-unloaded) (" + plotX + "," + plotZ + " (quitLoc-unloaded) (" + plotX + "," + plotZ
+ ")"); + ")");
} }

View File

@ -87,7 +87,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.TELEPORTED_TO_ROAD.f() + " (on-login) " + "(" + plot.getId().x + ";" + plot Captions.format(Captions.TELEPORTED_TO_ROAD.getTranslated()) + " (on-login) " + "(" + plot.getId().x + ";" + plot
.getId().y + ")"); .getId().y + ")");
} }
} }

View File

@ -81,7 +81,8 @@ 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.LEGACY_CONFIG_REPLACED.f(block, bucket.toString())); PlotSquared.log(Captions
.format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), block, bucket.toString()));
} }
private void convertBlockList(@NonNull final ConfigurationSection section, private void convertBlockList(@NonNull final ConfigurationSection section,
@ -89,8 +90,9 @@ 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( PlotSquared.log(Captions
Captions.LEGACY_CONFIG_REPLACED.f(plotBlockArrayString(blocks), bucket.toString())); .format(Captions.LEGACY_CONFIG_REPLACED.getTranslated(), plotBlockArrayString(blocks),
bucket.toString()));
} }
private String plotBlockArrayString(@NonNull final BlockState[] blocks) { private String plotBlockArrayString(@NonNull final BlockState[] blocks) {

View File

@ -789,7 +789,9 @@ public class MainUtil {
value = df.format(value); value = df.format(value);
} }
flags.append(prefix) flags.append(prefix)
.append(Captions.PLOT_FLAG_LIST.f(entry.getKey().getName(), value)); .append(Captions
.format(Captions.PLOT_FLAG_LIST.getTranslated(), entry.getKey().getName(),
value));
prefix = ", "; prefix = ", ";
} }
} }