Some more work done towards json

This commit is contained in:
N0tMyFaultOG 2020-07-21 21:39:52 +02:00
parent 6040e1bb5e
commit 2aa5c276c9
14 changed files with 698 additions and 334 deletions

View File

@ -72,6 +72,7 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
@ -346,9 +347,10 @@ public class Area extends SubCommand {
}, null);
}
} else {
MainUtil.sendMessage(player,
"An error occurred while creating the world: " + area
.getWorldName());
player.sendMessage(
TranslatableCaption.of("errors.error_create"),
Template.of("world", area.getWorldName())
);
}
};
if (hasConfirmation(player)) {
@ -386,8 +388,11 @@ public class Area extends SubCommand {
for (int i = 2; i < args.length; i++) {
String[] pair = args[i].split("=");
if (pair.length != 2) {
Captions.COMMAND_SYNTAX.send(player, getCommandString()
+ " create [world[:id]] [<modifier>=<value>]...");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1,", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
switch (pair[0].toLowerCase()) {
@ -441,8 +446,11 @@ public class Area extends SubCommand {
builder.plotAreaType(pa.getType());
break;
default:
Captions.COMMAND_SYNTAX.send(player, getCommandString()
+ " create [world[:id]] [<modifier>=<value>]...");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
}
@ -468,9 +476,10 @@ public class Area extends SubCommand {
player.teleport(this.worldUtil.getSpawn(world),
TeleportCause.COMMAND);
} else {
MainUtil.sendMessage(player,
"An error occurred while creating the world: " + pa
.getWorldName());
player.sendMessage(
TranslatableCaption.of("errors.error_create"),
Template.of("world", pa.getWorldName())
);
}
try {
this.worldConfiguration.save(this.worldFile);
@ -487,8 +496,15 @@ public class Area extends SubCommand {
return true;
}
if (pa.getId() == null) {
Captions.COMMAND_SYNTAX.send(player, getCommandString()
+ " create [world[:id]] [<modifier>=<value>]...");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", getCommandString + )
);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...")
);
return false;
}
if (this.worldUtil.isWorld(pa.getWorldName())) {
@ -504,9 +520,10 @@ public class Area extends SubCommand {
TeleportCause.COMMAND);
}
player.setMeta("area_create_area", pa);
MainUtil.sendMessage(player,
"$1Go to the first corner and use: $2 " + getCommandString()
+ " create pos1");
player.sendMessage(
TranslatableCaption.of("single.get_position"),
Template.of("command", getCommandString())
);
break;
}
return true;
@ -526,7 +543,11 @@ public class Area extends SubCommand {
area = this.plotAreaManager.getPlotAreaByString(args[1]);
break;
default:
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " info [area]")
);
return false;
}
if (area == null) {
@ -584,7 +605,11 @@ public class Area extends SubCommand {
break;
}
default:
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()),
Template.of("value2", " list [#]")
);
return false;
}
final List<PlotArea> areas = new ArrayList<>(Arrays.asList(this.plotAreaManager.getAllPlotAreas()));
@ -640,12 +665,16 @@ public class Area extends SubCommand {
}
final PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(
TranslatableCaption.of("errors.not_in_plot_world")
);
return false;
}
if (area.getType() != PlotAreaType.PARTIAL) {
MainUtil.sendMessage(player,
"$4Stop the server and delete: " + area.getWorldName() + "/region");
player.sendMessage(
TranslatableCaption.of("single.delete_world_region"),
Template.of("world", area.getWorldName())
);
return false;
}
this.regionManager.largeRegionTask(area.getWorldName(), area.getRegion(),
@ -655,7 +684,9 @@ public class Area extends SubCommand {
.generate(null, area.getWorldName(), value.getX(), value.getZ(),
null);
}
}, () -> player.sendMessage("Regen complete"));
}, () -> player.sendMessage(
TranslatableCaption.of("single.regeneration_complete"))
);
return true;
}
case "goto":
@ -669,7 +700,10 @@ public class Area extends SubCommand {
return false;
}
if (args.length != 2) {
Captions.COMMAND_SYNTAX.send(player, "/plot visit [area]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot visit [area]")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
@ -694,12 +728,9 @@ public class Area extends SubCommand {
return true;
case "delete":
case "remove":
MainUtil.sendMessage(player,
"$1World creation settings may be stored in multiple locations:"
+ "\n$3 - $2Bukkit bukkit.yml" + "\n$3 - $2" + PlotSquared.platform()
.getPluginName() + " settings.yml"
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
+ "\n$1Stop the server and delete it from these locations.");
player.sendMessage(
TranslatableCaption.of("single.worldcreation_location")
);
return true;
}
sendUsage(player);

View File

@ -29,6 +29,7 @@ import com.google.common.collect.Lists;
import com.google.common.primitives.Ints;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.CaptionUtility;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
@ -213,11 +214,16 @@ public class Auto extends SubCommand {
size_z = Integer.parseInt(split[1]);
break;
default:
MainUtil.sendMessage(player, "Correct use /plot auto [length,width]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", getUsage())
);
return true;
}
if (size_x < 1 || size_z < 1) {
MainUtil.sendMessage(player, "Error: size<=0");
player.sendMessage(
TranslatableCaption.of("error.plot_size")
);
}
if (args.length > 1) {
schematic = args[1];
@ -261,16 +267,21 @@ public class Auto extends SubCommand {
if (schematic != null && !schematic.isEmpty()) {
if (!plotarea.hasSchematic(schematic)) {
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid_named"),
Template.of("schemname", schematic),
Template.of("reason", "non-existant")
);
return true;
}
if (!force && !Permissions.hasPermission(player, CaptionUtility
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(),
schematic));
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated())
);
return true;
}
}
@ -282,11 +293,17 @@ public class Auto extends SubCommand {
cost = (size_x * size_z) * cost;
if (cost > 0d) {
if (!force && this.econHandler.getMoney(player) < cost) {
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", String.valueOf(cost))
);
return true;
}
this.econHandler.withdrawMoney(player, cost);
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", String.valueOf(cost))
);
}
}
// TODO handle type 2 (partial) the same as normal worlds!

View File

@ -37,6 +37,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
import java.nio.file.Files;
@ -131,26 +132,35 @@ public final class Backup extends Command {
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
} else if (!plot.hasOwner()) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_UNOWNED.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_unowned")
);
} else if (plot.isMerged()) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_MERGED.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_merged")
);
} else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_ADMIN_BACKUP_OTHER.getTranslated())
);
} else {
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_OTHER.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_other")
);
} else {
backupProfile.createBackup().whenComplete((backup, throwable) -> {
if (throwable != null) {
sendMessage(player, Captions.BACKUP_SAVE_FAILED, throwable.getMessage());
throwable.printStackTrace();
} else {
sendMessage(player, Captions.BACKUP_SAVE_SUCCESS);
player.sendMessage(TranslatableCaption.of("backups.backup_save_success"));
}
});
}
@ -170,34 +180,50 @@ public final class Backup extends Command {
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
} else if (!plot.hasOwner()) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_UNOWNED.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_unowned")
);
} else if (plot.isMerged()) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_MERGED.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_merged")
);
} else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_ADMIN_BACKUP_OTHER.getTranslated())
);
} else {
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_OTHER.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_other")
);
} else {
backupProfile.listBackups().whenComplete((backups, throwable) -> {
if (throwable != null) {
sendMessage(player, Captions.BACKUP_LIST_FAILED, throwable.getMessage());
player.sendMessage(
TranslatableCaption.of("backups.backup_list_failed"),
Template.of("reason", throwable.getMessage())
);
throwable.printStackTrace();
} else {
sendMessage(player, Captions.BACKUP_LIST_HEADER,
plot.getId().toCommaSeparatedString());
player.sendMessage(
TranslatableCaption.of("backups.backup_list_header"),
Template.of("plot", plot.getId().toCommaSeparatedString())
);
try {
for (int i = 0; i < backups.size(); i++) {
sendMessage(player, Captions.BACKUP_LIST_ENTRY,
Integer.toString(i + 1), DateTimeFormatter.RFC_1123_DATE_TIME
.format(ZonedDateTime.ofInstant(
player.sendMessage(
TranslatableCaption.of("backups.backup_list_entry"),
Template.of("number", Integer.toString(i + 1)),
Template.of("value", DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.ofInstant(
Instant.ofEpochMilli(backups.get(i).getCreationTime()),
ZoneId.systemDefault())));
ZoneId.systemDefault())))
);
}
} catch (final Exception e) {
e.printStackTrace();
@ -221,54 +247,81 @@ public final class Backup extends Command {
if (plot == null) {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
} else if (!plot.hasOwner()) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_UNOWNED.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_unowned")
);
} else if (plot.isMerged()) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_MERGED.getTranslated());
sendMessage(player, Captions.BACKUP_IMPOSSIBLE, "merged");
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_merged")
);
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_merged")
);
} else if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_ADMIN_BACKUP_OTHER.getTranslated())
);
} else if (args.length == 0) {
sendMessage(player, Captions.BACKUP_LOAD_USAGE);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "Usage: /plot backup save/list/load")
);
} else {
final int number;
try {
number = Integer.parseInt(args[0]);
} catch (final Exception e) {
sendMessage(player, Captions.NOT_A_NUMBER, args[0]);
player.sendMessage(
TranslatableCaption.of("invalid.not_a_number"),
Template.of("value", args[0])
);
return;
}
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
if (backupProfile instanceof NullBackupProfile) {
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
Captions.GENERIC_OTHER.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_other")
);
} else {
backupProfile.listBackups().whenComplete((backups, throwable) -> {
if (throwable != null) {
sendMessage(player, Captions.BACKUP_LOAD_FAILURE, throwable.getMessage());
player.sendMessage(
TranslatableCaption.of("backups.backup_load_failure"),
Template.of("reason", throwable.getMessage())
);
throwable.printStackTrace();
} else {
if (number < 1 || number > backups.size()) {
sendMessage(player, Captions.BACKUP_LOAD_FAILURE,
Captions.GENERIC_INVALID_CHOICE.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_invalid_choice")
);
} else {
final com.plotsquared.core.backup.Backup backup =
backups.get(number - 1);
if (backup == null || backup.getFile() == null || !Files
.exists(backup.getFile())) {
sendMessage(player, Captions.BACKUP_LOAD_FAILURE,
Captions.GENERIC_INVALID_CHOICE.getTranslated());
player.sendMessage(
TranslatableCaption.of("backup_impossible"),
Template.of("plot", "generic.generic_invalid_choice")
);
} else {
CmdConfirm.addPending(player, "/plot backup load " + number,
() -> backupProfile.restoreBackup(backup)
.whenComplete((n, error) -> {
if (error != null) {
sendMessage(player, Captions.BACKUP_LOAD_FAILURE,
error.getMessage());
player.sendMessage(
TranslatableCaption.of("backups.backup_load_failure"),
Template.of("reason", error.getMessage())
);
} else {
sendMessage(player, Captions.BACKUP_LOAD_SUCCESS);
player.sendMessage(TranslatableCaption.of("backup_load_success"));
}
}));
}

View File

@ -96,27 +96,33 @@ public class Claim extends SubCommand {
grants = Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
if (grants <= 0) {
player.removePersistentMeta("grantedPlots");
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
player.sendMessage(TranslatableCaption.of("permission.cant_claim_more_plots"));
}
} else {
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
player.sendMessage(TranslatableCaption.of("permission.cant_claim_more_plots"));
}
}
if (!plot.canClaim(player)) {
return sendMessage(player, Captions.PLOT_IS_CLAIMED);
player.sendMessage(TranslatableCaption.of("working.plot_is_claimed"));
}
final PlotArea area = plot.getArea();
if (schematic != null && !schematic.isEmpty()) {
if (area.isSchematicClaimSpecify()) {
if (!area.hasSchematic(schematic)) {
return sendMessage(player, Captions.SCHEMATIC_INVALID,
"non-existent: " + schematic);
player.sendMessage(
TranslatableCaption.of("schematics.schematic_invalid_named"),
Template.of("schemname", schematic),
Template.of("reason", "non-existant")
);
}
if (!Permissions.hasPermission(player, CaptionUtility
.format(player, Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC) && !force) {
return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic);
player.sendMessage(
TranslatableCaption.of("permission.no_schematic_permission"),
Template.of("value", schematic)
);
}
}
}
@ -125,10 +131,16 @@ public class Claim extends SubCommand {
double cost = costExr.evaluate((double) currentPlots);
if (cost > 0d) {
if (this.econHandler.getMoney(player) < cost) {
return sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
player.sendMessage(
TranslatableCaption.of("economy.cannot_afford_plot"),
Template.of("money", String.valueOf(cost))
);
}
this.econHandler.withdrawMoney(player, cost);
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
player.sendMessage(
TranslatableCaption.of("economy.removed_balance"),
Template.of("money", String.valueOf(cost))
);
}
}
if (grants > 0) {
@ -137,7 +149,11 @@ public class Claim extends SubCommand {
} else {
player.setPersistentMeta("grantedPlots", Ints.toByteArray(grants - 1));
}
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", (grants - 1));
player.sendMessage(
TranslatableCaption.of("economy.removed_granted_plot"),
Template.of("usedGrants", String.valueOf((grants -1))),
Template.of("remainingGrants", String.valueOf(grants))
);
}
int border = area.getBorder();
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
@ -151,7 +167,7 @@ public class Claim extends SubCommand {
if (!plot.claim(player, true, finalSchematic, false)) {
logger.info(Captions.PREFIX.getTranslated() + String
.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) {
PlotMergeEvent mergeEvent = Claim.this.eventDispatcher
@ -173,7 +189,7 @@ public class Claim extends SubCommand {
logger.info(Captions.PREFIX.getTranslated() + String
.format("Failed to add plot %s to the database",
plot.getId().toCommaSeparatedString()));
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
player.sendMessage(TranslatableCaption.of("working.plot_not_claimed"));
plot.setOwnerAbs(null);
});
return true;

View File

@ -28,6 +28,7 @@ package com.plotsquared.core.command;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.location.BlockLoc;
@ -39,6 +40,8 @@ import com.plotsquared.core.plot.PlotCluster;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.query.PlotQuery;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.minimessage.Template;
import java.util.HashSet;
import java.util.Set;
@ -58,7 +61,7 @@ public class Cluster extends SubCommand {
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
if (args.length == 0) {
// return arguments
MainUtil.sendMessage(player, Captions.CLUSTER_AVAILABLE_ARGS);
player.sendMessage(TranslatableCaption.of("cluster.cluster_available_args"));
return false;
}
String sub = args[0].toLowerCase();
@ -66,33 +69,52 @@ public class Cluster extends SubCommand {
case "l":
case "list": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_LIST)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_LIST);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_LIST.getTranslated())
);
return false;
}
if (args.length != 1) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster list");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster list")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
return false;
}
Set<PlotCluster> clusters = area.getClusters();
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_HEADING, clusters.size() + "");
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_heading"),
Template.of("amount", clusters.size() + "")
);
for (PlotCluster cluster : clusters) {
// Ignore unmanaged clusters
String name = "'" + cluster.getName() + "' : " + cluster.toString();
if (player.getUUID().equals(cluster.owner)) {
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, "&a" + name);
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_owner"),
Template.of("cluster", name)
);
} else if (cluster.helpers.contains(player.getUUID())) {
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, "&3" + name);
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_helpers"),
Template.of("cluster", name)
);
} else if (cluster.invited.contains(player.getUUID())) {
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, "&9" + name);
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element_invited"),
Template.of("cluster", name)
);
} else {
MainUtil
.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, cluster.toString());
player.sendMessage(
TranslatableCaption.of("cluster.cluster_list_element"),
Template.of("cluster", cluster.toString())
);
}
}
return true;
@ -100,25 +122,29 @@ public class Cluster extends SubCommand {
case "c":
case "create": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_CREATE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_CREATE);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_CREATE.getTranslated())
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
return false;
}
if (args.length != 4) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster create <name> <id-bot> <id-top>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster create <name> <id-bot> <id-top>")
);
return false;
}
int currentClusters = Settings.Limit.GLOBAL ?
player.getClusterCount() :
player.getPlotCount(player.getLocation().getWorldName());
if (currentClusters >= player.getAllowedPlots()) {
return sendMessage(player, Captions.CANT_CLAIM_MORE_CLUSTERS);
player.sendMessage(TranslatableCaption.of("permission.cant_claim_more_clusters"));
}
PlotId pos1;
PlotId pos2;
@ -127,13 +153,13 @@ public class Cluster extends SubCommand {
pos1 = PlotId.fromString(args[2]);
pos2 = PlotId.fromString(args[3]);
} catch (IllegalArgumentException ignored) {
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id"));
return false;
}
// check if name is taken
String name = args[1];
if (area.getCluster(name) != null) {
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
player.sendMessage(TranslatableCaption.of("alias.alias_is_taken"));
return false;
}
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
@ -144,12 +170,18 @@ public class Cluster extends SubCommand {
//check if overlap
PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2);
if (cluster != null) {
MainUtil.sendMessage(player, Captions.CLUSTER_INTERSECTION, cluster.getName());
player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"),
Template.of("cluster", cluster.getName())
);
return false;
}
// Check if it occupies existing plots
if (!area.contains(pos1) || !area.contains(pos2)) {
Captions.CLUSTER_OUTSIDE.send(player, area);
player.sendMessage(
TranslatableCaption.of("cluster.cluster_outside"),
Template.of("area", area)
);
return false;
}
Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
@ -159,8 +191,10 @@ public class Cluster extends SubCommand {
UUID uuid = player.getUUID();
for (Plot plot : plots) {
if (!plot.isOwner(uuid)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_CREATE_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_CREATE_OTHER.getTranslated())
);
return false;
}
}
@ -178,8 +212,10 @@ public class Cluster extends SubCommand {
.hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE,
Settings.Limit.MAX_PLOTS);
if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()));
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_SIZE.getTranslated() + "." + (current + cluster.getArea()))
);
return false;
}
// create cluster
@ -195,63 +231,74 @@ public class Cluster extends SubCommand {
}
}
}
MainUtil.sendMessage(player, Captions.CLUSTER_ADDED);
player.sendMessage(TranslatableCaption.of("cluster.cluster_added"));
return true;
}
case "disband":
case "del":
case "delete": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_DELETE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_DELETE);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_DELETE.getTranslated())
);
return false;
}
if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster delete [name]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster delete [name]")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster;
if (args.length == 2) {
cluster = area.getCluster(args[1]);
if (cluster == null) {
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
);
return false;
}
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("cluster.not_in_cluster"));
return false;
}
}
if (!cluster.owner.equals(player.getUUID())) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_DELETE_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_DELETE_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_DELETE_OTHER.getTranslated()));
return false;
}
}
DBFunc.delete(cluster);
MainUtil.sendMessage(player, Captions.CLUSTER_DELETED);
player.sendMessage(TranslatableCaption.of("cluster.cluster_deleted"));
return true;
}
case "res":
case "resize": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_RESIZE);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE.getTranslated()));
return false;
}
if (args.length != 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster resize <pos1> <pos2>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster delete [name]")
);
return false;
}
PlotId pos1;
@ -261,7 +308,7 @@ public class Cluster extends SubCommand {
pos1 = PlotId.fromString(args[2]);
pos2 = PlotId.fromString(args[3]);
} catch (IllegalArgumentException ignored) {
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id"));
return false;
}
if (pos2.getX() < pos1.getX() || pos2.getY() < pos1.getY()) {
@ -271,27 +318,30 @@ public class Cluster extends SubCommand {
// check if in cluster
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_pcluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_RESIZE_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission")
Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE_OTHER.getTranslated()));
return false;
}
}
//check if overlap
PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2);
if (intersect != null) {
MainUtil
.sendMessage(player, Captions.CLUSTER_INTERSECTION, intersect.getName());
player.sendMessage(
TranslatableCaption.of("cluster.cluster_intersection"),
Template.of("cluster", intersect.getName())
);
return false;
}
Set<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
@ -304,8 +354,10 @@ public class Cluster extends SubCommand {
if (!removed.isEmpty()) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_SHRINK)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_RESIZE_SHRINK);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE_SHRINK.getTranslated())
);
return false;
}
}
@ -313,8 +365,10 @@ public class Cluster extends SubCommand {
if (!newPlots.isEmpty()) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_EXPAND)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_RESIZE_EXPAND);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_RESIZE_EXPAND.getTranslated())
);
return false;
}
}
@ -329,44 +383,52 @@ public class Cluster extends SubCommand {
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
Settings.Limit.MAX_PLOTS);
if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER.getTranslated() + "." + (current + cluster
.getArea()));
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER.getTranslated() + "." + (current + cluster
.getArea()))
);
return false;
}
// resize cluster
DBFunc.resizeCluster(cluster, pos1, pos2);
MainUtil.sendMessage(player, Captions.CLUSTER_RESIZED);
player.sendMessage(TranslatableCaption.of("cluster.clister_resized"));
return true;
}
case "add":
case "inv":
case "invite": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_INVITE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_INVITE);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_INVITE.getTranslated())
);
return false;
}
if (args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster invite <player>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster invite <player>")
);
return false;
}
// check if in cluster
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_INVITE_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_INVITE_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_INVITE_OTHER.getTranslated())
);
return false;
}
}
@ -374,23 +436,27 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[1], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} else if (throwable != null) {
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[1]);
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[1])
);
} else {
if (!cluster.isAdded(uuid)) {
// add the user if not added
cluster.invited.add(uuid);
DBFunc.setInvited(cluster, uuid);
final PlotPlayer otherPlayer =
PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
if (otherPlayer != null) {
MainUtil.sendMessage(otherPlayer, Captions.CLUSTER_INVITED,
cluster.getName());
player.sendMessage(
TranslatableCaption.of("cluster.cluster_invited"),
Template.of("cluster", cluster.getName())
);
}
}
MainUtil.sendMessage(player, Captions.CLUSTER_ADDED_USER);
player.sendMessage(TranslatableCaption.of("cluster.cluster_added_user"));
}
});
return true;
@ -399,29 +465,35 @@ public class Cluster extends SubCommand {
case "remove":
case "kick": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_KICK)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_KICK);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_KICK.getTranslated())
);
return false;
}
if (args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster kick <player>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster kick <player>")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_KICK_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_KICK_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_KICK_OTHER.getTranslated())
);
return false;
}
}
@ -429,15 +501,20 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[1], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} else if (throwable != null) {
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[1]);
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[1])
);
} else {
// Can't kick if the player is yourself, the owner, or not added to the cluster
if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner)
|| !cluster.isAdded(uuid)) {
MainUtil.sendMessage(player, Captions.CANNOT_KICK_PLAYER,
cluster.getName());
player.sendMessage(
TranslatableCaption.of("cluster.cannot_kick_player"),
Template.of("value", cluster.getName())
);
} else {
if (cluster.helpers.contains(uuid)) {
cluster.helpers.remove(uuid);
@ -449,8 +526,10 @@ public class Cluster extends SubCommand {
final PlotPlayer player2 =
PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid);
if (player2 != null) {
MainUtil.sendMessage(player2, Captions.CLUSTER_REMOVED,
cluster.getName());
player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"),
Template.of("cluster", cluster.getName())
);
}
for (final Plot plot : PlotQuery.newQuery().inWorld(player2.getLocation()
.getWorldName()).ownedBy(uuid)) {
@ -459,7 +538,7 @@ public class Cluster extends SubCommand {
plot.unclaim();
}
}
MainUtil.sendMessage(player2, Captions.CLUSTER_KICKED_USER);
player.sendMessage(TranslatableCaption.of("cluster.cluster_kicked_user"));
}
}
});
@ -468,40 +547,47 @@ public class Cluster extends SubCommand {
case "quit":
case "leave": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_LEAVE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_LEAVE);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_LEAVE.getTranslated())
);
return false;
}
if (args.length != 1 && args.length != 2) {
MainUtil
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster leave [name]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster leave [name]")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
PlotCluster cluster;
if (args.length == 2) {
cluster = area.getCluster(args[1]);
if (cluster == null) {
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster_name"),
Template.of("cluster", args[1])
);
return false;
}
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
}
UUID uuid = player.getUUID();
if (!cluster.isAdded(uuid)) {
MainUtil.sendMessage(player, Captions.CLUSTER_NOT_ADDED);
player.sendMessage(TranslatableCaption.of("cluster.cluster_not_added"));
return false;
}
if (uuid.equals(cluster.owner)) {
MainUtil.sendMessage(player, Captions.CLUSTER_CANNOT_LEAVE);
player.sendMessage(TranslatableCaption.of("cluster.cluster_cannot_leave"));
return false;
}
if (cluster.helpers.contains(uuid)) {
@ -510,7 +596,10 @@ public class Cluster extends SubCommand {
}
cluster.invited.remove(uuid);
DBFunc.removeInvited(cluster, uuid);
MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED, cluster.getName());
player.sendMessage(
TranslatableCaption.of("cluster.cluster_removed"),
Template.of("cluster", cluster.getName())
);
for (final Plot plot : PlotQuery.newQuery().inWorld(player.getLocation().getWorldName())
.ownedBy(uuid)) {
PlotCluster current = plot.getCluster();
@ -525,43 +614,52 @@ public class Cluster extends SubCommand {
case "helper":
case "helpers": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_HELPERS)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_HELPERS);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_HELPERS.getTranslated())
);
return false;
}
if (args.length != 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster helpers <add|remove> <player>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster helpers <add | remove> <player>")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(args[2], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) {
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} else if (throwable != null) {
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[2]);
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Template.of("value", args[2])
);
} else {
if (args[1].equalsIgnoreCase("add")) {
cluster.helpers.add(uuid);
DBFunc.setHelper(cluster, uuid);
MainUtil.sendMessage(player, Captions.CLUSTER_ADDED_HELPER);
player.sendMessage(TranslatableCaption.of("cluster.cluster_added_helper"));
} else if (args[1].equalsIgnoreCase("remove")) {
cluster.helpers.remove(uuid);
DBFunc.removeHelper(cluster, uuid);
MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED_HELPER);
player.sendMessage(TranslatableCaption.of("cluster.cluster_removed_helper"));
} else {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot cluster helpers <add|remove> <player>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster helpers <add | remove> <player>")
);
}
}
});
@ -571,65 +669,77 @@ public class Cluster extends SubCommand {
case "home":
case "tp": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_TP)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_TP);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_TP.getTranslated())
);
return false;
}
if (args.length != 2) {
MainUtil
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster tp <name>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster tp <name>")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
return false;
}
PlotCluster cluster = area.getCluster(args[1]);
if (cluster == null) {
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster"),
Template.of("cluster", args[1])
);
return false;
}
UUID uuid = player.getUUID();
if (!cluster.isAdded(uuid)) {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_TP_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_TP_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_TP_OTHER.getTranslated())
);
return false;
}
}
cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND));
return MainUtil.sendMessage(player, Captions.CLUSTER_TELEPORTING);
player.sendMessage(TranslatableCaption.of("cluster.cluster_teleporting"));
}
case "i":
case "info":
case "show":
case "information": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_INFO)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_INFO);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_TP.getTranslated())
);
return false;
}
if (args.length != 1 && args.length != 2) {
MainUtil
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster info [name]");
return false;
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster info [name]")
);
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
PlotCluster cluster;
if (args.length == 2) {
cluster = area.getCluster(args[1]);
if (cluster == null) {
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
return false;
}
player.sendMessage(
TranslatableCaption.of("cluster.invalid_cluster"),
Template.of("cluster", args[1])
);
} else {
cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
}
@ -638,7 +748,7 @@ public class Cluster extends SubCommand {
PlotSquared.get().getImpromptuUUIDPipeline()
.getSingle(cluster.owner, (username, throwable) -> {
if (throwable instanceof TimeoutException) {
MainUtil.sendMessage(player, Captions.FETCHING_PLAYERS_TIMEOUT);
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} else {
final String owner;
if (username == null) {
@ -665,28 +775,35 @@ public class Cluster extends SubCommand {
case "setspawn":
case "sethome":
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_SETHOME)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_SETHOME);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_SETHOME.getTranslated())
);
return false;
}
if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster sethome");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot cluster sethome")
);
return false;
}
PlotArea area = player.getApplicablePlotArea();
if (area == null) {
Captions.NOT_IN_PLOT_WORLD.send(player);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
PlotCluster cluster = area.getCluster(player.getLocation());
if (cluster == null) {
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
player.sendMessage(TranslatableCaption.of("errors.not_in_cluster"));
return false;
}
if (!cluster.hasHelperRights(player.getUUID())) {
if (!Permissions
.hasPermission(player, Captions.PERMISSION_CLUSTER_SETHOME_OTHER)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_CLUSTER_SETHOME_OTHER);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_CLUSTER_SETHOME_OTHER.getTranslated())
);
return false;
}
}
@ -696,9 +813,9 @@ public class Cluster extends SubCommand {
cluster.settings.setPosition(blockloc);
DBFunc.setPosition(cluster,
relative.getX() + "," + relative.getY() + "," + relative.getZ());
return MainUtil.sendMessage(player, Captions.POSITION_SET);
player.sendMessage(TranslatableCaption.of("position.position_set"));
}
MainUtil.sendMessage(player, Captions.CLUSTER_AVAILABLE_ARGS);
player.sendMessage(TranslatableCaption.of("cluster.cluster_available_args"));
return false;
}
}

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
@ -35,6 +36,7 @@ import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull;
import java.util.ArrayList;
@ -67,27 +69,32 @@ public class Condense extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length != 2 && args.length != 3) {
sendUsage(player);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense <area> <start|stop|info> [radius]")
);
return false;
}
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
if (area == null || !this.worldUtil.isWorld(area.getWorldName())) {
MainUtil.sendMessage(player, "INVALID AREA");
player.sendMessage(TranslatableCaption.of("invalid.invalid_area"));
return false;
}
switch (args[1].toLowerCase()) {
case "start": {
if (args.length == 2) {
MainUtil.sendMessage(player,
"/plot condense " + area.toString() + " start <radius>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense" + area.toString() + " start <radius>")
);
return false;
}
if (Condense.TASK) {
MainUtil.sendMessage(player, "TASK ALREADY STARTED");
player.sendMessage(TranslatableCaption.of("condense.task_already_started"));
return false;
}
if (!MathMan.isInteger(args[2])) {
MainUtil.sendMessage(player, "INVALID RADIUS");
player.sendMessage(TranslatableCaption.of("condense.invalid_radius"));
return false;
}
int radius = Integer.parseInt(args[2]);
@ -131,7 +138,7 @@ public class Condense extends SubCommand {
int size = allPlots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) {
MainUtil.sendMessage(player, "RADIUS TOO SMALL");
player.sendMessage(TranslatableCaption.of("condense.radius_too_small"));
return false;
}
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
@ -145,20 +152,19 @@ public class Condense extends SubCommand {
start = start.getNextId();
}
if (free.isEmpty() || toMove.isEmpty()) {
MainUtil.sendMessage(player, "NO FREE PLOTS FOUND");
player.sendMessage(TranslatableCaption.of("condense.no_free_plots_found"));
return false;
}
MainUtil.sendMessage(player, "TASK STARTED...");
player.sendMessage(TranslatableCaption.of("condense.task_started"));
Condense.TASK = true;
Runnable run = new Runnable() {
@Override public void run() {
if (!Condense.TASK) {
MainUtil.sendMessage(player, "TASK CANCELLED.");
player.sendMessage(TranslatableCaption.of("condense.task_cancelled"));
}
if (allPlots.isEmpty()) {
Condense.TASK = false;
MainUtil.sendMessage(player,
"TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
player.sendMessage(TranslatableCaption.of("condense.task_complete"));
return;
}
final Runnable task = this;
@ -175,8 +181,11 @@ public class Condense extends SubCommand {
try {
result.set(origin.move(possible, () -> {
if (result.get()) {
MainUtil.sendMessage(player,
"Moving: " + origin + " -> " + possible);
player.sendMessage(
TranslatableCaption.of("condense.moving"),
Template.of("origin", String.valueOf(origin)),
Template.of("possible", String.valueOf(possible))
);
TaskManager.runTaskLater(task, TaskTime.ticks(1L));
}
}, false).get());
@ -189,11 +198,14 @@ public class Condense extends SubCommand {
}
if (free.isEmpty()) {
Condense.TASK = false;
MainUtil.sendMessage(player, "TASK FAILED. NO FREE PLOTS FOUND!");
player.sendMessage(TranslatableCaption.of("condense.task_failed"));
return;
}
if (i >= free.size()) {
MainUtil.sendMessage(player, "SKIPPING COMPLEX PLOT: " + origin);
player.sendMessage(
TranslatableCaption.of("condense.skipping"),
Template.of("plot", String.valueOf(origin))
);
}
}
};
@ -202,20 +214,22 @@ public class Condense extends SubCommand {
}
case "stop":
if (!Condense.TASK) {
MainUtil.sendMessage(player, "TASK ALREADY STOPPED");
player.sendMessage(TranslatableCaption.of("condense.task_already_stopped"));
return false;
}
Condense.TASK = false;
MainUtil.sendMessage(player, "TASK STOPPED");
player.sendMessage(TranslatableCaption.of("condense.task_stopped"));
return true;
case "info":
if (args.length == 2) {
MainUtil.sendMessage(player,
"/plot condense " + area.toString() + " info <radius>");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot condense " + area.toString() + " info <radius>")
);
return false;
}
if (!MathMan.isInteger(args[2])) {
MainUtil.sendMessage(player, "INVALID RADIUS");
player.sendMessage(TranslatableCaption.of("condense.invalid_radius"));
return false;
}
int radius = Integer.parseInt(args[2]);
@ -223,24 +237,37 @@ public class Condense extends SubCommand {
int size = plots.size();
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
if (radius < minimumRadius) {
MainUtil.sendMessage(player, "RADIUS TOO SMALL");
player.sendMessage(TranslatableCaption.of("condense.radius_too_small"));
return false;
}
int maxMove = getPlots(plots, minimumRadius).size();
int userMove = getPlots(plots, radius).size();
MainUtil.sendMessage(player, "=== DEFAULT EVAL ===");
MainUtil.sendMessage(player, "MINIMUM RADIUS: " + minimumRadius);
MainUtil.sendMessage(player, "MAXIMUM MOVES: " + maxMove);
MainUtil.sendMessage(player, "=== INPUT EVAL ===");
MainUtil.sendMessage(player, "INPUT RADIUS: " + radius);
MainUtil.sendMessage(player, "ESTIMATED MOVES: " + userMove);
MainUtil.sendMessage(player,
"ESTIMATED TIME: No idea, times will drastically change based on the system performance and load");
MainUtil.sendMessage(player, "&e - Radius is measured in plot width");
player.sendMessage(TranslatableCaption.of("condense.default_eval"));
player.sendMessage(
TranslatableCaption.of("condense.minimum_radius"),
Template.of("minimumRadius", String.valueOf(minimumRadius))
);
player.sendMessage(
TranslatableCaption.of("condense.minimum_radius"),
Template.of("maxMove", String.valueOf(maxMove))
);
player.sendMessage(TranslatableCaption.of("condense.input_eval"));
player.sendMessage(
TranslatableCaption.of("condense.input_radius"),
Template.of("radius", String.valueOf(radius))
);
player.sendMessage(
TranslatableCaption.of("condense.estimated_moves"),
Template.of("userMove", String.valueOf(userMove))
);
player.sendMessage(TranslatableCaption.of("condense.eta"));
player.sendMessage(TranslatableCaption.of("condense.radius_measured"));
return true;
}
MainUtil.sendMessage(player,
"/plot condense " + area.getWorldName() + " <start|stop|info> [radius]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value","/plot condense " + area.getWorldName() + " <start|stop|info> [radius]")
);
return false;
}

View File

@ -62,22 +62,27 @@ public class Continue extends SubCommand {
}
if (!plot.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.NO_PLOT_PERMS.getTranslated())
);
return false;
}
if (!DoneFlag.isDone(plot)) {
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
player.sendMessage(TranslatableCaption.of("done.done_not_done"));
return false;
}
int size = plot.getConnectedPlots().size();
if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots()
< player.getPlotCount() + size)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_ADMIN_COMMAND_CONTINUE);
player.sendMessage(
TranslatableCaption.of("permission.no_permission"),
Template.of("node", Captions.PERMISSION_ADMIN_COMMAND_CONTINUE.getTranslated())
);
return false;
}
if (plot.getRunning() > 0) {
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
return false;
}
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(DoneFlag.class);
@ -90,7 +95,7 @@ public class Continue extends SubCommand {
return true;
}
plot.removeFlag(event.getFlag());
MainUtil.sendMessage(player, Captions.DONE_REMOVED);
player.sendMessage(TranslatableCaption.of("done.done_removed"));
return true;
}
}

View File

@ -31,6 +31,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions;
import net.kyori.adventure.text.minimessage.Template;
@CommandDeclaration(command = "copy",
permission = "plots.copy",
@ -50,11 +51,14 @@ public class Copy extends SubCommand {
}
if (!plot1.isOwner(player.getUUID()) && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN.getTranslated())) {
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
return false;
}
if (args.length != 1) {
sendUsage(player);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot copy <X;Z>")
);
return false;
}
Plot plot2 = Plot.getPlotFromString(player, args[0], true);
@ -62,18 +66,21 @@ public class Copy extends SubCommand {
return false;
}
if (plot1.equals(plot2)) {
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
sendUsage(player);
player.sendMessage(TranslatableCaption.of("invalid.not_valid_plot_id"));
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot copy <X;Z>")
);
return false;
}
if (!plot1.getArea().isCompatible(plot2.getArea())) {
Captions.PLOTWORLD_INCOMPATIBLE.send(player);
player.sendMessage(TranslatableCaption.of("errors.plotworld_incompatible"));
return false;
}
if (plot1.copy(plot2, () -> MainUtil.sendMessage(player, Captions.COPY_SUCCESS))) {
if (plot1.copy(plot2, () -> player.sendMessage(TranslatableCaption.of("move.copy_success")))) {
return true;
} else {
MainUtil.sendMessage(player, Captions.REQUIRES_UNOWNED);
player.sendMessage(TranslatableCaption.of("move.requires_unowned"));
return false;
}
}

View File

@ -59,10 +59,10 @@ public class CreateRoadSchematic extends SubCommand {
return false;
}
if (!(location.getPlotArea() instanceof HybridPlotWorld)) {
return sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
}
this.hybridUtils.setupRoadSchematic(plot);
MainUtil.sendMessage(player, Captions.SCHEMATIC_ROAD_CREATED);
player.sendMessage(TranslatableCaption.of("schematics.schematic_road_created"));
return true;
}
}

View File

@ -27,6 +27,8 @@ package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.database.Database;
@ -45,6 +47,8 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.FileUtils;
import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template;
import sun.net.TransferProtocolClient;
import javax.annotation.Nonnull;
import java.io.File;
@ -84,14 +88,13 @@ public class DatabaseCommand extends SubCommand {
TaskManager.runTaskAsync(() -> {
try {
ArrayList<Plot> ps = new ArrayList<>(plots);
MainUtil.sendMessage(player, "&6Starting...");
player.sendMessage(TranslatableCaption.of("database.starting_conversion"));
manager.createPlotsAndData(ps, () -> {
MainUtil.sendMessage(player, "&6Database conversion finished!");
player.sendMessage(TranslatableCaption.of("database.conversion_done"));
manager.close();
});
} catch (Exception e) {
MainUtil
.sendMessage(player, "Failed to insert plot objects, see stacktrace for info");
player.sendMessage(TranslatableCaption.of("database.conversion_failed"));
e.printStackTrace();
}
});
@ -99,7 +102,10 @@ public class DatabaseCommand extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
if (args.length < 1) {
sendUsage(player);
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot database [area] <sqlite|mysql|import>")
);
return false;
}
List<Plot> plots;
@ -111,8 +117,11 @@ public class DatabaseCommand extends SubCommand {
plots = PlotSquared.get().sortPlotsByTemp(PlotQuery.newQuery().allPlots().asList());
}
if (args.length < 1) {
sendUsage(player);
MainUtil.sendMessage(player, "[arg] indicates an optional argument");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot database [area] <sqlite|mysql|import>")
);
player.sendMessage(TranslatableCaption.of("database.arg"));
return false;
}
try {
@ -121,17 +130,22 @@ public class DatabaseCommand extends SubCommand {
switch (args[0].toLowerCase()) {
case "import":
if (args.length < 2) {
MainUtil
.sendMessage(player, "/plot database import <sqlite file> [prefix]");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot database import <sqlite file> [prefix]")
);
return false;
}
File file = FileUtils.getFile(PlotSquared.platform().getDirectory(),
args[1].endsWith(".db") ? args[1] : args[1] + ".db");
if (!file.exists()) {
MainUtil.sendMessage(player, "&6Database does not exist: " + file);
player.sendMessage(
TranslatableCaption.of("database.does_not_exist"),
Template.of("value", String.valueOf(file))
);
return false;
}
MainUtil.sendMessage(player, "&6Starting...");
player.sendMessage(TranslatableCaption.of("database.starting_conversion"));
implementation = new SQLite(file);
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "",
this.eventDispatcher, this.plotListener, this.worldConfiguration);
@ -164,8 +178,7 @@ public class DatabaseCommand extends SubCommand {
continue;
}
}
MainUtil.sendMessage(player,
"Skipping duplicate plot: " + plot + " | id=" + plot.temp);
player.sendMessage(StaticCaption.of("Skipping duplicate plot: " + plot + " | id=" + plot.temp));
continue;
}
plot.setArea(pa);
@ -178,12 +191,11 @@ public class DatabaseCommand extends SubCommand {
}
}
DBFunc.createPlotsAndData(plots,
() -> MainUtil.sendMessage(player, "&6Database conversion finished!"));
() -> player.sendMessage(TranslatableCaption.of("database.conversion_done")));
return true;
case "mysql":
if (args.length < 6) {
return MainUtil.sendMessage(player,
"/plot database mysql [host] [port] [username] [password] [database] {prefix}");
player.sendMessage(StaticCaption.of("/plot database mysql [host] [port] [username] [password] [database] {prefix}"));
}
String host = args[1];
String port = args[2];
@ -197,36 +209,33 @@ public class DatabaseCommand extends SubCommand {
break;
case "sqlite":
if (args.length < 2) {
return MainUtil.sendMessage(player, "/plot database sqlite [file]");
player.sendMessage(StaticCaption.of("/plot database sqlite [file]"));
}
File sqliteFile =
FileUtils.getFile(PlotSquared.platform().getDirectory(), args[1] + ".db");
implementation = new SQLite(sqliteFile);
break;
default:
return MainUtil.sendMessage(player, "/plot database [sqlite/mysql]");
player.sendMessage(StaticCaption.of("/plot database [sqlite/mysql]"));
}
try {
SQLManager manager = new SQLManager(implementation, prefix, this.eventDispatcher, this.plotListener, this.worldConfiguration);
DatabaseCommand.insertPlots(manager, plots, player);
return true;
} catch (ClassNotFoundException | SQLException e) {
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");
MainUtil.sendMessage(player,
"&d==== Here is an ugly stacktrace, if you are interested in those things ===");
player.sendMessage(TranslatableCaption.of("database.failed_to_save_plots"));
player.sendMessage(StaticCaption.of(("=== Begin of stacktrace. ===")));
e.printStackTrace();
MainUtil.sendMessage(player, "&d==== End of stacktrace ====");
MainUtil
.sendMessage(player, "$1Please make sure you are using the correct arguments!");
player.sendMessage(StaticCaption.of(("=== End of stacktrace. ===")));
player.sendMessage(TranslatableCaption.of("database.invalid_args"));
return false;
}
} catch (ClassNotFoundException | SQLException e) {
MainUtil.sendMessage(player, "$1Failed to open connection, read stacktrace for info");
MainUtil.sendMessage(player,
"&d==== Here is an ugly stacktrace, if you are interested in those things ===");
player.sendMessage(TranslatableCaption.of("database.failed_to_open"));
player.sendMessage(StaticCaption.of(("=== Begin of stacktrace. ===")));
e.printStackTrace();
MainUtil.sendMessage(player, "&d==== End of stacktrace ====");
MainUtil.sendMessage(player, "$1Please make sure you are using the correct arguments!");
player.sendMessage(StaticCaption.of(("=== End of stacktrace. ===")));
player.sendMessage(TranslatableCaption.of("database.invalid_args"));
return false;
}
}

View File

@ -26,6 +26,7 @@
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 java.util.ArrayList;
@ -46,10 +47,10 @@ public class DebugAllowUnsafe extends SubCommand {
if (unsafeAllowed.contains(player.getUUID())) {
unsafeAllowed.remove(player.getUUID());
sendMessage(player, Captions.DEBUGALLOWUNSAFE_OFF);
player.sendMessage(TranslatableCaption.of("unsafe.debugallowunsafe_off"));
} else {
unsafeAllowed.add(player.getUUID());
sendMessage(player, Captions.DEBUGALLOWUNSAFE_ON);
player.sendMessage(TranslatableCaption.of("unsafe.debugallowunsafe_on"));
}
return true;
}

View File

@ -27,9 +27,11 @@ package com.plotsquared.core.command;
import com.google.common.io.Files;
import com.google.inject.Inject;
import com.google.inject.internal.cglib.transform.$ClassTransformer;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -63,6 +65,8 @@ import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.world.block.BlockState;
import javafx.collections.transformation.TransformationList;
import net.kyori.adventure.text.minimessage.Template;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -92,7 +96,6 @@ public class DebugExec extends SubCommand {
private static final Logger logger = LoggerFactory.getLogger("P2/" + DebugExec.class.getSimpleName());
private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher;
private final WorldEdit worldEdit;
@ -162,7 +165,6 @@ public class DebugExec extends SubCommand {
this.scope = context.getBindings(ScriptContext.ENGINE_SCOPE);
// stuff
this.scope.put("MainUtil", new MainUtil());
this.scope.put("Settings", new Settings());
this.scope.put("StringMan", new StringMan());
this.scope.put("MathMan", new MathMan());
@ -219,42 +221,45 @@ public class DebugExec extends SubCommand {
}
PlotAnalysis analysis = plot.getComplexity(null);
if (analysis != null) {
MainUtil.sendMessage(player, "Changes/column: " + analysis.changes / 1.0);
player.sendMessage(
TranslatableCaption.of("debugexec.changes_column"),
Template.of("value", analysis.changes / 1.0)
);
return true;
}
MainUtil.sendMessage(player, "$1Starting task...");
player.sendMessage(TranslatableCaption.of("debugexec.starting_task"));
this.hybridUtils.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@Override public void run(PlotAnalysis value) {
MainUtil.sendMessage(player,
"$1Done: $2Use $3/plot debugexec analyze$2 for more information");
player.sendMessage(StaticCaption.of("&6Done: &7Use &6/plot debugexec analyze &7for more information."));
}
});
return true;
}
case "calibrate-analysis":
if (args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot debugexec analyze <threshold>");
MainUtil.sendMessage(player,
"$1<threshold> $2= $1The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating "
+ "it)");
player.sendMessage(
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot debugexec analyze <threshold>")
);
player.sendMessage(TranslatableCaption.of("debugexec.threshold_default"));
return false;
}
double threshold;
try {
threshold = Integer.parseInt(args[1]) / 100d;
} catch (NumberFormatException ignored) {
MainUtil.sendMessage(player, "$2Invalid threshold: " + args[1]);
MainUtil.sendMessage(player,
"$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100");
player.sendMessage(
TranslatableCaption.of("debugexec.invalid_threshold"),
Template.of("value", args[1])
);
player.sendMessage(TranslatableCaption.of("debugexec.threshold_default_double"));
return false;
}
PlotAnalysis.calcOptimalModifiers(() -> MainUtil
.sendMessage(player, "$1Thank you for calibrating plot expiry"), threshold);
PlotAnalysis.calcOptimalModifiers(() -> player.sendMessage(TranslatableCaption.of("debugexec.calibration_done")), threshold);
return true;
case "stop-expire":
if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
return MainUtil.sendMessage(player, "Task already halted");
player.sendMessage(TranslatableCaption.of("debugexec.task_halted"));
}
return MainUtil.sendMessage(player, "Cancelled task.");
case "remove-flag":

View File

@ -6,10 +6,10 @@
"move.move_success": "<prefix><dark_aqua>Successfully moved plot.</dark_aqua>",
"move.move_merged": "<prefix><gray>Merged plots may not be moved. Please unmerge the plot before performing the move.</gray>",
"move.copy_success": "<prefix><dark_aqua>Successfully copied plot.</dark_aqua>",
"move.reqiores_unowned": "<prefix><gray>The location specified is already occupied.</gray>",
"move.requires_unowned": "<prefix><gray>The location specified is already occupied.</gray>",
"debug.requires_unmerged": "<prefix><red>The plot cannot be merged.</red>",
"debug.degub_header": "<prefix> <gold>Debug Information</orange>\n",
"debug.debug_header": "<prefix> <gold>Debug Information</orange>\n",
"debug.debug_section": "<gray>>></gray> <gold><bold>&l<val></bold></gold>",
"debug.debug_line": "<gray>>></gray> <gold><var></gold><gray>:</gray><gold> <val></gold>\n",
"debug.plot_debug": "<gray>[<gold>Plot </gold><gray>Debug] (</gray><gold><plot></gold><gray>): <message></gray>",
@ -31,13 +31,16 @@
"cluster.cluster_available_args": "<prefix><gold>The following sub commands are available: </gold><dark_aqua>list</dark_aqua><gray>, </gray><dark_aqua>create</dark_aqua><gray>, </gray><dark_aqua>delete</dark_aqua><gray>, </gray><dark_aqua>resize</dark_aqua><gray>, </gray><dark_aqua>invite</dark_aqua><gray>, </gray><dark_aqua>kick</dark_aqua><gray>, </gray><dark_aqua>leave</dark_aqua><gray>, </gray><dark_aqua>members</dark_aqua><gray>, </gray><dark_aqua>info</dark_aqua><gray>, </gray><dark_aqua>tp</dark_aqua><gray>, </gray><dark_aqua>sethome</dark_aqua>",
"cluster.cluster_list_heading": "<prefix><gray>There are </gray><gold><amount></gold><gray> clusters in this world.</gray>",
"cluster.cluster_list_element": "<prefix><gray> - </gray><gold><cluster></gold>\n",
"cluster.cluster_list_element_owner": "<prefix><gray> - </gray><green><cluster></green>\n",
"cluster.cluster_list_element_helpers": "<prefix><gray> - </gray><dark_aqua><cluster></dark_aqua>\n",
"cluster.cluster_list_element_invited": "<prefix><gray> - </gray><blue><cluster></blue>\n",
"cluster.cluster_intersection": "<prefix><gray>The proposed area overlaps with: <cluster></gray>",
"cluster.cluster_outside": "<prefix><gray>The proposed area is outside the plot area: <area></gray>",
"cluster.cluster_added": "<prefix><dark_aqua>Successfully created the cluster.</dark_aqua>",
"cluster.cluster_deleted": "<prefix><dark_aqua>Successfully deleted the cluster.</ark_aqua>",
"cluster.cluster_resized": "<prefix><dark_aqua>Successfully resized the cluster.</dark_aqua>",
"cluter.cluster_added_user": "<prefix><dark_aqua>Successfully added user to the cluster.</dark_aqua>",
"cluster.cannot_kick_player": "<prefix><red>You cannot kick that player.</red>",
"cluster.cluster_added_user": "<prefix><dark_aqua>Successfully added user to the cluster.</dark_aqua>",
"cluster.cannot_kick_player": "<prefix><red>You cannot kick that player: </red><gray><name></gray>",
"cluster.cluster_invited": "<prefix><gold>You have been invited to the following cluster: </gold><gray><cluster>.</gray>",
"cluster.cluster_removed": "<prefix><gold>You have been removed from cluster: </gold><gray><cluster>.</gray>",
"cluster.cluster_kicked_user": "<prefix><dark_aqua>Successfully kicked the user from the cluster.</dark_aqua>",
@ -152,6 +155,7 @@
"schematics.schematic_too_large": "<prefix><red>The plot is too large for this action!</red>",
"schematics.schematic_missing_arg": "<prefix><gray>You need to specify an argument. Possible values: </gray><gold>save</gold><gray>, </gray><gold>paste </gold><gray>, </gray><gold>exportall</gold><gray>, </gray><gold>list</gold>",
"schematics.schematic_invalid": "<prefix><red>That is not a valid schematic. Reason: </red><gray><reason>.</gray>",
"schematics.schematic_invalid_named": "<prefix><red><schemname> is not a valid schematic. Reason: </red><gray><reason>.</gray>",
"schematics.schematic_paste_merged": "<prefix><red>Schematics cannot be pasted onto merged plots. Please unmerge the plot before performing the paste.</red>",
"schematics.schematic_paste_failed": "<prefix><red>Failed to paste the schematic.</red>",
"schematics.schematic_paste_success": "<prefix><dark_aqua>The schematic pasted successfully.</dark_aqua>",
@ -211,8 +215,9 @@
"commandconfig.not_valid_subcommand": "<prefix><gray>That is not a valid subcommand.</gray>",
"commandconfig.did_you_mean": "<prefix><gray>Did you mean: <gold><value></gold></gray>",
"commandconfig.subcommand_set_options_header": "<prefix><gray>Possible Values: <values>",
"commandconfig.command_syntax": "<prefix><gold>Usage: <gray><value></gray></gold>",
"commandconfig.flag_tutorial_usage": "<prefix><gold>Have an admin set the flag: <gray><flag></gray></gold>",
"commandconfig.command_syntax": "<prefix><gold>Usage: </gold><gray><value></gray>",
"commandconfig.command_syntax_extended": "<prefix><gold>Usage: </gold><gray><value1> <value2></gray>",
"commandconfig.flag_tutorial_usage": "<prefix><gold>Have an admin set the flag: </gold><gray><flag></gray>",
"invalid.component_illegal_block": "<prefix><red>You are not allowed to generate a component containing the block <gray><value></gray></red>",
"invalid.not_valid_block": "<prefix><red>That's not a valid block: <gray><value></gray></red>",
@ -224,6 +229,46 @@
"invalid.number_not_positive": "<prefix><red>That's not a positive number: <gray><value></gray></red>",
"invalid.not_a_number": "<prefix><red><gray><value></gray> is not a valid number.</red>",
"condense.invalid_area": "<prefix><red>Invalid area.</red>",
"condense.task_already_started": "<prefix><red>Task already started.</red>",
"condense.invalid_radius": "<prefix><red>Invalid radius.</red>",
"condense.radius_too_small": "<prefix><red>Radius too small.</red>",
"condense.no_free_plots_found": "<prefix><red>No free plots found.</red>",
"condense.task_started": "<prefix><gold>Task started...</gold>",
"condense.task_cancelled": "<prefix><gold>Task cancelled.</gold>",
"condense.task_complete": "<prefix><gold>Task complete. Please verify that no new plots have been claimed during the task.</gold>",
"condense.moving": "<gold>Moving: </gold><gray><origin></gray><gold> -> </gold><green><possible></green>",
"condense.task_failed": "<prefix><red>Task failed. No free plots found.</red>",
"condense.skipping": "<prefix><red>Skipping complex plot: </red><gold><plot></gold><red>.</red>",
"condense.task_already_stopped": "<prefix><gold>Task already stopped.</gold>",
"condense.task_stopped": "<prefix><gold>Task already stopped.</gold>",
"condense.default_eval": "<dark_gray><strikethrough>=== <reset> <gold>DEFAULT EVAL </gold><dark_gray><strikethrough>===</dark_gray>",
"condense.minimum_radius": "<gold><Minimum radius: </gold><gray><minimumRadius></gray>",
"condense.maximum_moved": "<gold>Maximum moved: </gold><gray><maximumMoves></gray>",
"condense.input_eval": "<dark_gray><strikethrough>=== <reset> <gold>INPUT EVAL </gold><dark_gray><strikethrough>===</dark_gray>",
"condense.input_radius": "<gold>Input radius: </gold><gray><radius></gray>",
"condense.estimated_moves": "<gold>Estimated moves: </gold><gray><userMove></gray>",
"condense.eta": "<prefix><gold>Estimated time: No idea, times will drastically change based on the system performance and load.</gold>",
"condense.radius_measured": "<yellow> - Radius is measured in plot width.</yellow>",
"database.starting_conversion": "<prefix><gold>Starting...</gold>",
"database.conversion_done": "<prefix><gold>Database conversion finished.<gold>",
"database.conversion_failed": "<prefix><red>Failed to insert plot objects, see stacktrace for info.</red>",
"database.arg": "<prefix><gray>[arg] indicates an optional argument.</gray>",
"database.does_not_exist": "<prefix><red>Database does not exist: </red><gray><value></gray><red>.</red>",
"database.failed_to_save_plots": "<prefix><red>Failed to save plots, read stacktrace for info.</red>",
"database.invalid_args": "<prefix><red>Please make sure you are using the correct arguments.</red>",
"database.failed_to_open": "<prefix><red>Failed to open connection, read stacktrace for info.</red>",
"debugexec.changes_column": "<prefix><gold>Changes/column: </gold><gray><value></gray>",
"debugexec.starting_task": "<prefix><gold>Starting task...</gold>",
"debugexec.threshold_default": "<prefix><gray>`threshold` = The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating it.</gray>",
"debugexec.invalid_threshold": "<prefix><red>Invalid threshold: </red><gray><value></gray>",
"debugexec.threshold_default_double": "<prefix><gray>$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100.</gray>",
"debugexec.calibration_done": "<prefix><gold>Thank you for calibrating plot expiry.</gold>",
"debugexec.task_halted": "<prefix><gray>Task already halted.</gray>",
"errors.invalid_player": "<prefix><red>Player not found: <gray><value></gray>.</red>",
"errors.invalid_player_offline": "<prefix><red>The player must be online: <gray><player></gray>.</red>",
@ -243,6 +288,7 @@
"errors.player_no_plots": "<prefix><gray>That player does not own any plots.</gray>",
"errors.wait_for_timer": "<prefix><gray>A set block timer is bound to either the current plot or you. Please wait for it to finish.</gray>",
"errors.tile_entity_cap_reached": "<prefix><red>The total number of tile entities in this chunk may not exceed <gold><amount></gold>.</red>",
"error.plot_size": "<prefix><red>Error: size <= 0.</red>",
"debugpaste.debug_report_created": "<prefix><gold>Uploaded a full debug to: <gray><url></gray>",
@ -400,6 +446,10 @@
"single.single_area_failed_to_save": "<prefix><red>Error! Failed to save the area schematic.</red>",
"single.single_area_could_not_make_directories": "<prefix><red>Error! Failed to create the schematic directory.</red>",
"single.single_area_created": "<prefix><gold>The area was created successfully!</gold>",
"single.get_position": "<prefix><gold>Go to the first corner and use: <gray><command> to create position 1.</gold>",
"single.delete_world_region": "<prefix><red>Stop the server and delete: <world>/region.</red>",
"single.regeneration_complete": "<prefix><gold>Regeneration complete.</gold>",
"single.worldcreation_location": "<prefix><gold>World creation settings may be stored in multiple locations:</gold>\n<dark_gray> - </dark_gray><gray>bukkit.yml in your server's root folder.</gray>\n<dark_gray> - </dark_gray><gray>PlotSquared's settings.yml</gray>\n<dark_gray> - </dark_gray><gray>Hyperverse's worlds.yml (or any world management plugin)</gray>\n<dark_gray> - </dark_gray><red>Stop the server and delete it from these locations.</red>",
"legacyconfig.legacy_config_found": "<prefix><green>A legacy configuration file was detected. Conversion will be attempted.</green>",
"legacyconfig.legacy_config_backup": "<prefix><gold>A copy of worlds.yml has been saved in the file worlds.yml.old</gold>.",
@ -537,5 +587,31 @@
"flags.flag_error_string": "<prefix><red>Flag value must be alphanumeric. Some special characters are allowed.</red>",
"flags.flag_error_stringlist": "<prefix><red>Flag value must be a string list.</red>",
"flags.flag_error_weather": "<prefix><red>Flag must be a weather: 'rain' or 'sun'.</red>",
"flags.flag_error_music": "<prefix><red>Flag value must be a valid music disc ID.</red>"
"flags.flag_error_music": "<prefix><red>Flag value must be a valid music disc ID.</red>",
"commands.description.add": "<gray>Allow a user to build in a plot while the plot owner is online.</gray>",
"commands.description.alias": "<gray>Set the plot alias.</gray>",
"commands.description.area": "<gray>Create a new plot area.</gray>",
"commands.description.auto": "<gray>Claim the nearest plot.</gray>",
"commands.description.backup": "<gray>Manage plot backups.</gray>",
"commands.description.backup.save": "<gray>Create a plot backup.</gray>",
"commands.description.backup.list": "<gray>List available plot backups.</gray>",
"commands.description.backup.load": "<gray>Restore a plot backup</gray>",
"commands.description.biome": "<gray>Set the plot biome.</gray>",
"commands.description.buy": "<gray>Buy the plot you are standing on.</gray>",
"commands.description.caps": "<gray>Show plot entity caps.</gray>",
"commands.description.chat": "<gray>Toggles plot chat on or off.</gray>",
"commands.description.claim": "<gray>Claim the current plot you are standing on.</gray>",
"commands.description.clear": "<gray>Clear the plot you stand on.</gray>",
"commands.description.cluster": "<gray>Manage a plot cluster.</gray>",
"commands.description.comment": "<gray>Comment on a plot.</gray>",
"commands.description.condense": "<gray>Condense a plotworld.</gray>",
"commands.description.confirm": "<gray>Confirm an action.</gray>",
"commands.description.done": "<gray>Continue a plot that was previously marked as done.</gray>",
"commands.description.copy": "<gray>Copy a plot.</gray>",
"commands.description.createroadschematic": "<gray>Add a road schematic to your world using the roads around your current plot.</gray>",
"commands.description.database": "<gray>Convert/Backup Storage.</gray>",
"commands.description.debug": "<gray>Show debug information.</gray>",
"commands.description.debugallowunsafe": "<gray>Allow unsafe actions until toggled off.</gray>",
"commands.description.debugexec": "<gray>Multi-purpose debug command.</gray>"
}