Just merge the whole thing. Merge branch 'v6' into features/v6/queue-features

# Conflicts:
#	Core/src/main/resources/lang/messages_en.json
This commit is contained in:
dordsor21 2020-11-01 18:58:24 +00:00
commit ee9b2e8bf8
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
25 changed files with 275 additions and 404 deletions

View File

@ -39,12 +39,12 @@ dependencies {
// Implementation details // Implementation details
// //
// ~~Spyware~~ Metrics // Metrics
implementation("org.bstats:bstats-bukkit:1.7") implementation("org.bstats:bstats-bukkit:1.7")
// Minecraft // Minecraft
compileOnlyApi("com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT") compileOnlyApi("com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT")
implementation("io.papermc:paperlib:1.0.4") implementation("io.papermc:paperlib:1.0.5")
// Plugins // Plugins
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT") { compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT") {

View File

@ -82,6 +82,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -685,7 +686,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
.of("msg", BukkitUtil.LEGACY_COMPONENT_SERIALIZER.deserialize(ChatColor.translateAlternateColorCodes('&', message))); .of("msg", BukkitUtil.LEGACY_COMPONENT_SERIALIZER.deserialize(ChatColor.translateAlternateColorCodes('&', message)));
} else { } else {
msgTemplate = Template.of("msg", BukkitUtil.MINI_MESSAGE.deserialize( msgTemplate = Template.of("msg", BukkitUtil.MINI_MESSAGE.deserialize(
ChatColor.stripColor(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(TextComponent.builder(message).build())))); ChatColor.stripColor(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(Component.text(message)))));
} }
for (PlotPlayer<?> receiver : plotRecipients) { for (PlotPlayer<?> receiver : plotRecipients) {
receiver.sendMessage(msg, msgTemplate, plotTemplate, senderTemplate); receiver.sendMessage(msg, msgTemplate, plotTemplate, senderTemplate);
@ -694,7 +695,7 @@ public class PlayerEventListener extends PlotListener implements Listener {
Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format"); Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format");
Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY()); Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY());
Template spysenderTemplate = Template.of("sender", sender); Template spysenderTemplate = Template.of("sender", sender);
Template spymessageTemplate = Template.of("msg", TextComponent.builder(message).build()); Template spymessageTemplate = Template.of("msg", Component.text(message));
for (PlotPlayer<?> player : spies) { for (PlotPlayer<?> player : spies) {
player.sendMessage(spymsg, plotidTemplate, spysenderTemplate, spymessageTemplate); player.sendMessage(spymsg, plotidTemplate, spysenderTemplate, spymessageTemplate);
} }

View File

@ -12,7 +12,7 @@ dependencies {
compileOnlyApi("org.yaml:snakeyaml:1.26") // Some platforms provide this compileOnlyApi("org.yaml:snakeyaml:1.26") // Some platforms provide this
// Adventure stuff // Adventure stuff
api("net.kyori:adventure-api:4.0.0-SNAPSHOT") api("net.kyori:adventure-api:4.1.1")
api("net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT") api("net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT")
// Guice // Guice

View File

@ -29,9 +29,7 @@ import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.CaptionHolder; import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
@ -113,8 +111,10 @@ public class Area extends SubCommand {
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@WorldFile @Nonnull final File worldFile, @WorldFile @Nonnull final File worldFile,
@Nonnull final HybridPlotWorldFactory hybridPlotWorldFactory, @Nonnull final HybridPlotWorldFactory hybridPlotWorldFactory,
@Nonnull final SetupUtils setupUtils, @Nonnull final WorldUtil worldUtil, @Nonnull final SetupUtils setupUtils,
@Nonnull final RegionManager regionManager, @Nonnull final GlobalBlockQueue blockQueue) { @Nonnull final WorldUtil worldUtil,
@Nonnull final RegionManager regionManager,
@Nonnull final GlobalBlockQueue blockQueue) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;
@ -137,31 +137,26 @@ public class Area extends SubCommand {
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.area.create")) { if (!Permissions.hasPermission(player, "plots.area.create")) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.area.create"));
Template.of("node", "plots.area.create"));
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
player.sendMessage(TranslatableCaption.of("single.single_area_needs_name"), player.sendMessage(TranslatableCaption.of("single.single_area_needs_name"), Template.of("command", "/plot area single <name>"));
Template.of("command", "/plot area single <name>"));
return false; return false;
} }
final PlotArea existingArea = final PlotArea existingArea = this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]);
this.plotAreaManager.getPlotArea(player.getLocation().getWorldName(), args[1]);
if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) { if (existingArea != null && existingArea.getId().equalsIgnoreCase(args[1])) {
player.sendMessage(TranslatableCaption.of("single.single_area_name_taken")); player.sendMessage(TranslatableCaption.of("single.single_area_name_taken"));
return false; return false;
} }
final LocalSession localSession = final LocalSession localSession = WorldEdit.getInstance().getSessionManager().getIfPresent(player.toActor());
WorldEdit.getInstance().getSessionManager().getIfPresent(player.toActor());
if (localSession == null) { if (localSession == null) {
player.sendMessage(TranslatableCaption.of("single.single_area_missing_selection")); player.sendMessage(TranslatableCaption.of("single.single_area_missing_selection"));
return false; return false;
} }
Region playerSelectedRegion = null; Region playerSelectedRegion = null;
try { try {
playerSelectedRegion = playerSelectedRegion = localSession.getSelection(((Player) player.toActor()).getWorld());
localSession.getSelection(((Player) player.toActor()).getWorld());
} catch (final Exception ignored) { } catch (final Exception ignored) {
} }
if (playerSelectedRegion == null) { if (playerSelectedRegion == null) {
@ -172,8 +167,8 @@ public class Area extends SubCommand {
player.sendMessage(TranslatableCaption.of("single.single_area_not_square")); player.sendMessage(TranslatableCaption.of("single.single_area_not_square"));
return false; return false;
} }
if (this.plotAreaManager.getPlotAreas( if (this.plotAreaManager.getPlotAreas(Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(),
Objects.requireNonNull(playerSelectedRegion.getWorld()).getName(), CuboidRegion.makeCuboid(playerSelectedRegion)).length != 0) { CuboidRegion.makeCuboid(playerSelectedRegion)).length != 0) {
player.sendMessage(TranslatableCaption.of("single.single_area_overlapping")); player.sendMessage(TranslatableCaption.of("single.single_area_overlapping"));
} }
// Alter the region // Alter the region
@ -181,18 +176,15 @@ public class Area extends SubCommand {
final BlockVector3 playerSelectionMax = playerSelectedRegion.getMaximumPoint(); final BlockVector3 playerSelectionMax = playerSelectedRegion.getMaximumPoint();
// Create a new selection that spans the entire vertical range of the world // Create a new selection that spans the entire vertical range of the world
final CuboidRegion selectedRegion = final CuboidRegion selectedRegion =
new CuboidRegion(playerSelectedRegion.getWorld(), new CuboidRegion(playerSelectedRegion.getWorld(), BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
BlockVector3.at(playerSelectionMin.getX(), 0, playerSelectionMin.getZ()),
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ())); BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ()));
// There's only one plot in the area... // There's only one plot in the area...
final PlotId plotId = PlotId.of(1, 1); final PlotId plotId = PlotId.of(1, 1);
final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory
.create(player.getLocation().getWorldName(), args[1], .create(player.getLocation().getWorldName(), args[1], Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(),
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(),
plotId, plotId); plotId, plotId);
// Plot size is the same as the region width // Plot size is the same as the region width
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
// We use a schematic generator // We use a schematic generator
hybridPlotWorld.setTerrain(PlotAreaTerrainType.NONE); hybridPlotWorld.setTerrain(PlotAreaTerrainType.NONE);
// It is always a partial plot world // It is always a partial plot world
@ -200,30 +192,24 @@ public class Area extends SubCommand {
// We save the schematic :D // We save the schematic :D
hybridPlotWorld.PLOT_SCHEMATIC = true; hybridPlotWorld.PLOT_SCHEMATIC = true;
// Set the road width to 0 // Set the road width to 0
hybridPlotWorld.ROAD_WIDTH = hybridPlotWorld.ROAD_WIDTH = hybridPlotWorld.ROAD_OFFSET_X = hybridPlotWorld.ROAD_OFFSET_Z = 0;
hybridPlotWorld.ROAD_OFFSET_X = hybridPlotWorld.ROAD_OFFSET_Z = 0;
// Set the plot height to the selection height // Set the plot height to the selection height
hybridPlotWorld.PLOT_HEIGHT = hybridPlotWorld.ROAD_HEIGHT = hybridPlotWorld.PLOT_HEIGHT = hybridPlotWorld.ROAD_HEIGHT = hybridPlotWorld.WALL_HEIGHT = playerSelectionMin.getBlockY();
hybridPlotWorld.WALL_HEIGHT = playerSelectionMin.getBlockY();
// No sign plz // No sign plz
hybridPlotWorld.setAllowSigns(false); hybridPlotWorld.setAllowSigns(false);
final File parentFile = FileUtils.getFile(PlotSquared.platform().getDirectory(), final File parentFile = FileUtils.getFile(PlotSquared.platform().getDirectory(),
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + hybridPlotWorld.getWorldName() + File.separator
+ hybridPlotWorld.getWorldName() + File.separator + hybridPlotWorld + hybridPlotWorld.getId());
.getId());
if (!parentFile.exists() && !parentFile.mkdirs()) { if (!parentFile.exists() && !parentFile.mkdirs()) {
player.sendMessage(TranslatableCaption.of("single.single_area_could_not_make_directories")); player.sendMessage(TranslatableCaption.of("single.single_area_could_not_make_directories"));
return false; return false;
} }
final File file = new File(parentFile, "plot.schem"); final File file = new File(parentFile, "plot.schem");
try (final ClipboardWriter clipboardWriter = BuiltInClipboardFormat.SPONGE_SCHEMATIC try (final ClipboardWriter clipboardWriter = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) {
.getWriter(new FileOutputStream(file))) {
final BlockArrayClipboard clipboard = new BlockArrayClipboard(selectedRegion); final BlockArrayClipboard clipboard = new BlockArrayClipboard(selectedRegion);
final EditSession editSession = WorldEdit.getInstance().getEditSessionFactory() final EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(selectedRegion.getWorld(), -1);
.getEditSession(selectedRegion.getWorld(), -1);
final ForwardExtentCopy forwardExtentCopy = final ForwardExtentCopy forwardExtentCopy =
new ForwardExtentCopy(editSession, selectedRegion, clipboard, new ForwardExtentCopy(editSession, selectedRegion, clipboard, selectedRegion.getMinimumPoint());
selectedRegion.getMinimumPoint());
forwardExtentCopy.setCopyingBiomes(true); forwardExtentCopy.setCopyingBiomes(true);
forwardExtentCopy.setCopyingEntities(true); forwardExtentCopy.setCopyingEntities(true);
Operations.complete(forwardExtentCopy); Operations.complete(forwardExtentCopy);
@ -245,15 +231,12 @@ public class Area extends SubCommand {
final BlockVector3 singlePos1 = selectedRegion.getMinimumPoint(); final BlockVector3 singlePos1 = selectedRegion.getMinimumPoint();
// Now the schematic is saved, which is wonderful! // Now the schematic is saved, which is wonderful!
PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld) PlotAreaBuilder singleBuilder = PlotAreaBuilder.ofPlotArea(hybridPlotWorld).plotManager(PlotSquared.platform().getPluginName())
.plotManager(PlotSquared.platform().getPluginName()) .generatorName(PlotSquared.platform().getPluginName()).maximumId(plotId).minimumId(plotId);
.generatorName(PlotSquared.platform().getPluginName()).maximumId(plotId)
.minimumId(plotId);
Runnable singleRun = () -> { Runnable singleRun = () -> {
final String path = final String path =
"worlds." + hybridPlotWorld.getWorldName() + ".areas." + hybridPlotWorld "worlds." + hybridPlotWorld.getWorldName() + ".areas." + hybridPlotWorld.getId() + '-' + singleBuilder.minimumId() + '-'
.getId() + '-' + singleBuilder.minimumId() + '-' + singleBuilder + singleBuilder.maximumId();
.maximumId();
final int offsetX = singlePos1.getX(); final int offsetX = singlePos1.getX();
final int offsetZ = singlePos1.getZ(); final int offsetZ = singlePos1.getZ();
if (offsetX != 0) { if (offsetX != 0) {
@ -267,10 +250,7 @@ public class Area extends SubCommand {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
player.sendMessage(TranslatableCaption.of("single.single_area_created")); player.sendMessage(TranslatableCaption.of("single.single_area_created"));
} else { } else {
player.sendMessage( player.sendMessage(TranslatableCaption.of("errors.error_create"), Template.of("world", hybridPlotWorld.getWorldName()));
TranslatableCaption.of("errors.error_create"),
Template.of("world", hybridPlotWorld.getWorldName())
);
} }
}; };
singleRun.run(); singleRun.run();
@ -279,8 +259,7 @@ public class Area extends SubCommand {
case "setup": case "setup":
case "create": case "create":
if (!Permissions.hasPermission(player, "plots.area.create")) { if (!Permissions.hasPermission(player, "plots.area.create")) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.area.create"));
Template.of("node", "plots.area.create"));
return false; return false;
} }
switch (args.length) { switch (args.length) {
@ -291,103 +270,82 @@ public class Area extends SubCommand {
case 2: case 2:
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "pos1": { // Set position 1 case "pos1": { // Set position 1
HybridPlotWorld area = (HybridPlotWorld) metaData HybridPlotWorld area = (HybridPlotWorld) metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>())
.computeIfAbsent(player.getUUID(), .get("area_create_area");
missingUUID -> new HashMap<>()).get("area_create_area");
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"), player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...")); Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]..."));
return false; return false;
} }
Location location = player.getLocation(); Location location = player.getLocation();
metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()) metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_pos1", location);
.put("area_pos1", location); player.sendMessage(TranslatableCaption.of("set.set_attribute"), Template.of("attribute", "area_pos1"),
player.sendMessage(TranslatableCaption.of("set.set_attribute"),
Template.of("attribute", "area_pos1"),
Template.of("value", location.getX() + "," + location.getZ())); Template.of("value", location.getX() + "," + location.getZ()));
player.sendMessage(TranslatableCaption.of("area.set_pos2"), player.sendMessage(TranslatableCaption.of("area.set_pos2"), Template.of("command", "/plot area create pos2"));
Template.of("command", "/plot area create pos2"));
return true; return true;
} }
case "pos2": // Set position 2 and finish creation for type=2 (partial) case "pos2": // Set position 2 and finish creation for type=2 (partial)
final HybridPlotWorld area = (HybridPlotWorld) metaData final HybridPlotWorld area =
.computeIfAbsent(player.getUUID(), (HybridPlotWorld) metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>())
missingUUID -> new HashMap<>()).get("area_create_area"); .get("area_create_area");
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"), player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"),
Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]...")); Templates.of("value", "/plot area create [world[:id]] [<modifier>=<value>]..."));
return false; return false;
} }
Location pos1 = player.getLocation(); Location pos1 = player.getLocation();
Location pos2 = (Location) metaData Location pos2 =
.computeIfAbsent(player.getUUID(), (Location) metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).get("area_pos1");
missingUUID -> new HashMap<>()).get("area_pos1");
int dx = Math.abs(pos1.getX() - pos2.getX()); int dx = Math.abs(pos1.getX() - pos2.getX());
int dz = Math.abs(pos1.getZ() - pos2.getZ()); int dz = Math.abs(pos1.getZ() - pos2.getZ());
int numX = Math.max(1, int numX = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
(dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE); int numZ = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
int numZ = Math.max(1,
(dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
int ddx = dx - (numX * area.SIZE - area.ROAD_WIDTH); int ddx = dx - (numX * area.SIZE - area.ROAD_WIDTH);
int ddz = dz - (numZ * area.SIZE - area.ROAD_WIDTH); int ddz = dz - (numZ * area.SIZE - area.ROAD_WIDTH);
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx; int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz; int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz;
int tx = Math.max(pos1.getX(), pos2.getX()) - ddx; int tx = Math.max(pos1.getX(), pos2.getX()) - ddx;
int tz = Math.max(pos1.getZ(), pos2.getZ()) - ddz; int tz = Math.max(pos1.getZ(), pos2.getZ()) - ddz;
int lower = (area.ROAD_WIDTH & 1) == 0 ? int lower = (area.ROAD_WIDTH & 1) == 0 ? area.ROAD_WIDTH / 2 - 1 : area.ROAD_WIDTH / 2;
area.ROAD_WIDTH / 2 - 1 :
area.ROAD_WIDTH / 2;
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz); final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
final Set<PlotArea> areas = this.plotAreaManager final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(area.getWorldName(), region);
.getPlotAreasSet(area.getWorldName(), region);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
player.sendMessage(TranslatableCaption.of("cluster.cluster_intersection"), player.sendMessage(TranslatableCaption.of("cluster.cluster_intersection"),
Template.of("cluster", areas.iterator().next().toString())); Template.of("cluster", areas.iterator().next().toString()));
return false; return false;
} }
PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area) PlotAreaBuilder builder = PlotAreaBuilder.ofPlotArea(area).plotManager(PlotSquared.platform().getPluginName())
.plotManager(PlotSquared.platform().getPluginName()) .generatorName(PlotSquared.platform().getPluginName()).minimumId(PlotId.of(1, 1))
.generatorName(PlotSquared.platform().getPluginName()) .maximumId(PlotId.of(numX, numZ));
.minimumId(PlotId.of(1, 1)).maximumId(PlotId.of(numX, numZ));
final String path = final String path =
"worlds." + area.getWorldName() + ".areas." + area.getId() + '-' "worlds." + area.getWorldName() + ".areas." + area.getId() + '-' + builder.minimumId() + '-' + builder
+ builder.minimumId() + '-' + builder.maximumId(); .maximumId();
Runnable run = () -> { Runnable run = () -> {
if (offsetX != 0) { if (offsetX != 0) {
this.worldConfiguration this.worldConfiguration.set(path + ".road.offset.x", offsetX);
.set(path + ".road.offset.x", offsetX);
} }
if (offsetZ != 0) { if (offsetZ != 0) {
this.worldConfiguration this.worldConfiguration.set(path + ".road.offset.z", offsetZ);
.set(path + ".road.offset.z", offsetZ);
} }
final String world = this.setupUtils.setupWorld(builder); final String world = this.setupUtils.setupWorld(builder);
if (this.worldUtil.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
player.sendMessage(TranslatableCaption.of("setup.setup_finished")); player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
player.teleport(this.worldUtil.getSpawn(world), player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND);
TeleportCause.COMMAND);
if (area.getTerrain() != PlotAreaTerrainType.ALL) { if (area.getTerrain() != PlotAreaTerrainType.ALL) {
QueueCoordinator queue = QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
blockQueue.getNewQueue(worldUtil.getWeWorld(world)); queue.setChunkConsumer(chunk -> AugmentedUtils.generate(null, world, chunk.getX(), chunk.getZ(), null));
queue.setChunkConsumer(chunk -> AugmentedUtils
.generate(null, world, chunk.getX(), chunk.getZ(),
null));
queue.addReadChunks(region.getChunks()); queue.addReadChunks(region.getChunks());
queue.enqueue(); queue.enqueue();
} }
} else { } else {
player.sendMessage( player.sendMessage(TranslatableCaption.of("errors.error_create"), Template.of("world", area.getWorldName()));
TranslatableCaption.of("errors.error_create"),
Template.of("world", area.getWorldName())
);
} }
}; };
if (hasConfirmation(player)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(player, CmdConfirm.addPending(player, getCommandString() + " create pos2 (Creates world)", run);
getCommandString() + " create pos2 (Creates world)", run);
} else { } else {
run.run(); run.run();
} }
@ -403,17 +361,14 @@ public class Area extends SubCommand {
} }
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder(); PlotAreaBuilder builder = PlotAreaBuilder.newBuilder();
builder.worldName(split[0]); builder.worldName(split[0]);
final HybridPlotWorld pa = this.hybridPlotWorldFactory final HybridPlotWorld pa =
.create(builder.worldName(), id, this.hybridPlotWorldFactory.create(builder.worldName(), id, PlotSquared.platform().getDefaultGenerator(), null, null);
PlotSquared.platform().getDefaultGenerator(), null, null);
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id); PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
if (other != null && Objects.equals(pa.getId(), other.getId())) { if (other != null && Objects.equals(pa.getId(), other.getId())) {
player.sendMessage(TranslatableCaption.of("setup.setup_world_taken"), player.sendMessage(TranslatableCaption.of("setup.setup_world_taken"), Template.of("value", pa.toString()));
Template.of("value", pa.toString()));
return false; return false;
} }
Set<PlotArea> areas = Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(pa.getWorldName());
this.plotAreaManager.getPlotAreasSet(pa.getWorldName());
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
PlotArea area = areas.iterator().next(); PlotArea area = areas.iterator().next();
pa.setType(area.getType()); pa.setType(area.getType());
@ -422,11 +377,9 @@ public class Area extends SubCommand {
for (int i = 2; i < args.length; i++) { for (int i = 2; i < args.length; i++) {
String[] pair = args[i].split("="); String[] pair = args[i].split("=");
if (pair.length != 2) { if (pair.length != 2) {
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"),
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1,", getCommandString()), Template.of("value1,", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...") Template.of("value2", " create [world[:id]] [<modifier>=<value>]..."));
);
return false; return false;
} }
switch (pair[0].toLowerCase()) { switch (pair[0].toLowerCase()) {
@ -449,49 +402,40 @@ public class Area extends SubCommand {
break; break;
case "f": case "f":
case "floor": case "floor":
pa.TOP_BLOCK = pa.TOP_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "m": case "m":
case "main": case "main":
pa.MAIN_BLOCK = pa.MAIN_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "w": case "w":
case "wall": case "wall":
pa.WALL_FILLING = pa.WALL_FILLING = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "b": case "b":
case "border": case "border":
pa.WALL_BLOCK = pa.WALL_BLOCK = ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
ConfigurationUtil.BLOCK_BUCKET.parseString(pair[1]);
break; break;
case "terrain": case "terrain":
pa.setTerrain(PlotAreaTerrainType.fromString(pair[1]) pa.setTerrain(PlotAreaTerrainType.fromString(pair[1])
.orElseThrow(() -> new IllegalArgumentException( .orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid terrain.")));
pair[1] + " is not a valid terrain.")));
builder.terrainType(pa.getTerrain()); builder.terrainType(pa.getTerrain());
break; break;
case "type": case "type":
pa.setType(PlotAreaType.fromString(pair[1]).orElseThrow( pa.setType(PlotAreaType.fromString(pair[1])
() -> new IllegalArgumentException( .orElseThrow(() -> new IllegalArgumentException(pair[1] + " is not a valid type.")));
pair[1] + " is not a valid type.")));
builder.plotAreaType(pa.getType()); builder.plotAreaType(pa.getType());
break; break;
default: default:
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"),
TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value1", getCommandString()), Template.of("value1", getCommandString()),
Template.of("value2", " create [world[:id]] [<modifier>=<value>]...") Template.of("value2", " create [world[:id]] [<modifier>=<value>]..."));
);
return false; return false;
} }
} }
if (pa.getType() != PlotAreaType.PARTIAL) { if (pa.getType() != PlotAreaType.PARTIAL) {
if (this.worldUtil.isWorld(pa.getWorldName())) { if (this.worldUtil.isWorld(pa.getWorldName())) {
player.sendMessage(TranslatableCaption.of("setup.setup_world_taken"), player.sendMessage(TranslatableCaption.of("setup.setup_world_taken"), Template.of("value", pa.getWorldName()));
Template.of("value", pa.getWorldName()));
return false; return false;
} }
Runnable run = () -> { Runnable run = () -> {
@ -499,8 +443,7 @@ public class Area extends SubCommand {
if (!this.worldConfiguration.contains(path)) { if (!this.worldConfiguration.contains(path)) {
this.worldConfiguration.createSection(path); this.worldConfiguration.createSection(path);
} }
ConfigurationSection section = ConfigurationSection section = this.worldConfiguration.getConfigurationSection(path);
this.worldConfiguration.getConfigurationSection(path);
pa.saveConfiguration(section); pa.saveConfiguration(section);
pa.loadConfiguration(section); pa.loadConfiguration(section);
builder.plotManager(PlotSquared.platform().getPluginName()); builder.plotManager(PlotSquared.platform().getPluginName());
@ -508,13 +451,9 @@ public class Area extends SubCommand {
String world = this.setupUtils.setupWorld(builder); String world = this.setupUtils.setupWorld(builder);
if (this.worldUtil.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
player.sendMessage(TranslatableCaption.of("setup.setup_finished")); player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
player.teleport(this.worldUtil.getSpawn(world), player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND);
TeleportCause.COMMAND);
} else { } else {
player.sendMessage( player.sendMessage(TranslatableCaption.of("errors.error_create"), Template.of("world", pa.getWorldName()));
TranslatableCaption.of("errors.error_create"),
Template.of("world", pa.getWorldName())
);
} }
try { try {
this.worldConfiguration.save(this.worldFile); this.worldConfiguration.save(this.worldFile);
@ -523,49 +462,37 @@ public class Area extends SubCommand {
} }
}; };
if (hasConfirmation(player)) { if (hasConfirmation(player)) {
CmdConfirm.addPending(player, CmdConfirm.addPending(player, getCommandString() + ' ' + StringMan.join(args, " "), run);
getCommandString() + ' ' + StringMan.join(args, " "), run);
} else { } else {
run.run(); run.run();
} }
return true; return true;
} }
if (pa.getId() == null) { if (pa.getId() == null) {
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"), Template.of("value", getUsage()));
TranslatableCaption.of("commandconfig.command_syntax"), player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"),
Template.of("value", getUsage())); Template.of("value1", getCommandString()), Template.of("value2", " 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; return false;
} }
if (this.worldUtil.isWorld(pa.getWorldName())) { if (this.worldUtil.isWorld(pa.getWorldName())) {
if (!player.getLocation().getWorldName().equals(pa.getWorldName())) { if (!player.getLocation().getWorldName().equals(pa.getWorldName())) {
player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), TeleportCause.COMMAND);
TeleportCause.COMMAND);
} }
} else { } else {
builder.terrainType(PlotAreaTerrainType.NONE); builder.terrainType(PlotAreaTerrainType.NONE);
builder.plotAreaType(PlotAreaType.NORMAL); builder.plotAreaType(PlotAreaType.NORMAL);
this.setupUtils.setupWorld(builder); this.setupUtils.setupWorld(builder);
player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), player.teleport(this.worldUtil.getSpawn(pa.getWorldName()), TeleportCause.COMMAND);
TeleportCause.COMMAND);
} }
metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa); metaData.computeIfAbsent(player.getUUID(), missingUUID -> new HashMap<>()).put("area_create_area", pa);
player.sendMessage( player.sendMessage(TranslatableCaption.of("single.get_position"), Template.of("command", getCommandString()));
TranslatableCaption.of("single.get_position"),
Template.of("command", getCommandString())
);
break; break;
} }
return true; return true;
case "i": case "i":
case "info": { case "info": {
if (!Permissions.hasPermission(player, "plots.area.info")) { if (!Permissions.hasPermission(player, "plots.area.info")) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.area.info"));
Template.of("node", "plots.area.info"));
return false; return false;
} }
PlotArea area; PlotArea area;
@ -577,17 +504,13 @@ public class Area extends SubCommand {
area = this.plotAreaManager.getPlotAreaByString(args[1]); area = this.plotAreaManager.getPlotAreaByString(args[1]);
break; break;
default: default:
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"), Template.of("value1", getCommandString()),
TranslatableCaption.of("commandconfig.command_syntax_extended"), Template.of("value2", " info [area]"));
Template.of("value1", getCommandString()),
Template.of("value2", " info [area]")
);
return false; return false;
} }
if (area == null) { if (area == null) {
if (args.length == 2) { if (args.length == 2) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), Template.of("value", args[1]));
Template.of("value", args[1]));
} else { } else {
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world")); player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
} }
@ -616,11 +539,11 @@ public class Area extends SubCommand {
Template typeTemplate = Template.of("type", area.getType().name()); Template typeTemplate = Template.of("type", area.getType().name());
Template terrainTemplate = Template.of("terrain", area.getTerrain().name()); Template terrainTemplate = Template.of("terrain", area.getTerrain().name());
Template usageTemplate = Template.of("usage", String.format("%.2f", percent)); Template usageTemplate = Template.of("usage", String.format("%.2f", percent));
Template claimedTemplate = Template.of("name", String.valueOf(claimed)); Template claimedTemplate = Template.of("claimed", String.valueOf(claimed));
Template clustersTemplate = Template.of("name", String.valueOf(clusters)); Template clustersTemplate = Template.of("clusters", String.valueOf(clusters));
Template regionTemplate = Template.of("name", region); Template regionTemplate = Template.of("region", region);
Template generatorTemplate = Template.of("name", generator); Template generatorTemplate = Template.of("generator", generator);
Template footerTemplate = Template.of("name", TranslatableCaption.of("info.plot_info_footer").getComponent(player)); Template footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player));
player.sendMessage(TranslatableCaption.of("info.area_info_format"), headerTemplate, nameTemplate, typeTemplate, terrainTemplate, player.sendMessage(TranslatableCaption.of("info.area_info_format"), headerTemplate, nameTemplate, typeTemplate, terrainTemplate,
usageTemplate, claimedTemplate, clustersTemplate, regionTemplate, generatorTemplate, footerTemplate); usageTemplate, claimedTemplate, clustersTemplate, regionTemplate, generatorTemplate, footerTemplate);
return true; return true;
@ -628,8 +551,7 @@ public class Area extends SubCommand {
case "l": case "l":
case "list": case "list":
if (!Permissions.hasPermission(player, "plots.area.list")) { if (!Permissions.hasPermission(player, "plots.area.list")) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.area.list"));
Template.of("node", "plots.area.list"));
return false; return false;
} }
int page; int page;
@ -643,17 +565,12 @@ public class Area extends SubCommand {
break; break;
} }
default: default:
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax_extended"), Template.of("value1", getCommandString()),
TranslatableCaption.of("commandconfig.command_syntax_extended"), Template.of("value2", " list [#]"));
Template.of("value1", getCommandString()),
Template.of("value2", " list [#]")
);
return false; return false;
} }
final List<PlotArea> areas = final List<PlotArea> areas = new ArrayList<>(Arrays.asList(this.plotAreaManager.getAllPlotAreas()));
new ArrayList<>(Arrays.asList(this.plotAreaManager.getAllPlotAreas())); paginate(player, areas, 8, page, new RunnableVal3<Integer, PlotArea, CaptionHolder>() {
paginate(player, areas, 8, page,
new RunnableVal3<Integer, PlotArea, CaptionHolder>() {
@Override public void run(Integer i, PlotArea area, CaptionHolder caption) { @Override public void run(Integer i, PlotArea area, CaptionHolder caption) {
String name; String name;
double percent; double percent;
@ -664,15 +581,13 @@ public class Area extends SubCommand {
if (area.getType() == PlotAreaType.PARTIAL) { if (area.getType() == PlotAreaType.PARTIAL) {
PlotId min = area.getMin(); PlotId min = area.getMin();
PlotId max = area.getMax(); PlotId max = area.getMax();
name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' name = area.getWorldName() + ';' + area.getId() + ';' + min + ';' + max;
+ max; int size = (max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1);
int size = percent = claimed == 0 ? 0 : claimed / (double) size;
(max.getX() - min.getX() + 1) * (max.getY() - min.getY() + 1);
percent = claimed == 0 ? 0 : size / (double) claimed;
region = area.getRegion().toString(); region = area.getRegion().toString();
} else { } else {
name = area.getWorldName(); name = area.getWorldName();
percent = claimed == 0 ? 0 : Short.MAX_VALUE * Short.MAX_VALUE / (double) claimed; percent = claimed == 0 ? 0 : (double) claimed / Short.MAX_VALUE * Short.MAX_VALUE;
region = "N/A"; region = "N/A";
} }
Template claimedTemplate = Template.of("claimed", String.valueOf(claimed)); Template claimedTemplate = Template.of("claimed", String.valueOf(claimed));
@ -685,14 +600,14 @@ public class Area extends SubCommand {
clustersTemplate, regionTemplate, generatorTemplate)); clustersTemplate, regionTemplate, generatorTemplate));
Template tooltipTemplate = Template.of("hover_info", tooltip); Template tooltipTemplate = Template.of("hover_info", tooltip);
Template visitcmdTemplate = Template.of("command_tp", "/plot area tp " + area.toString()); Template visitcmdTemplate = Template.of("command_tp", "/plot area tp " + area.toString());
Template infocmdTemplate = Template.of("command_info", "/plot area info " + area.toString());
Template numberTemplate = Template.of("number", String.valueOf(i)); Template numberTemplate = Template.of("number", String.valueOf(i));
Template nameTemplate = Template.of("area_name", name); Template nameTemplate = Template.of("area_name", name);
Template typeTemplate = Template.of("area_type", area.getType().name()); Template typeTemplate = Template.of("area_type", area.getType().name());
Template terrainTemplate = Template.of("area_terrain", area.getTerrain().name()); Template terrainTemplate = Template.of("area_terrain", area.getTerrain().name());
Caption item = TranslatableCaption.of("info.area_list_item"); caption.set(TranslatableCaption.of("info.area_list_item"));
caption.set(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE caption.setTemplates(tooltipTemplate, visitcmdTemplate, numberTemplate, nameTemplate, typeTemplate, terrainTemplate,
.parse(item.getComponent(player), tooltipTemplate, visitcmdTemplate, numberTemplate, nameTemplate, typeTemplate, infocmdTemplate);
terrainTemplate))));
} }
}, "/plot area list", TranslatableCaption.of("list.area_list_header_paged")); }, "/plot area list", TranslatableCaption.of("list.area_list_header_paged"));
return true; return true;
@ -701,28 +616,20 @@ public class Area extends SubCommand {
case "reset": case "reset":
case "regenerate": { case "regenerate": {
if (!Permissions.hasPermission(player, "plots.area.regen")) { if (!Permissions.hasPermission(player, "plots.area.regen")) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.area.regen"));
Template.of("node", "plots.area.regen"));
return false; return false;
} }
final PlotArea area = player.getApplicablePlotArea(); final PlotArea area = player.getApplicablePlotArea();
if (area == null) { if (area == null) {
player.sendMessage( player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
TranslatableCaption.of("errors.not_in_plot_world")
);
return false; return false;
} }
if (area.getType() != PlotAreaType.PARTIAL) { if (area.getType() != PlotAreaType.PARTIAL) {
player.sendMessage( player.sendMessage(TranslatableCaption.of("single.delete_world_region"), Template.of("world", area.getWorldName()));
TranslatableCaption.of("single.delete_world_region"),
Template.of("world", area.getWorldName())
);
return false; return false;
} }
QueueCoordinator queue = QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName()));
blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName())); queue.setChunkConsumer(chunk -> AugmentedUtils.generate(null, area.getWorldName(), chunk.getX(), chunk.getZ(), null));
queue.setChunkConsumer(chunk -> AugmentedUtils
.generate(null, area.getWorldName(), chunk.getX(), chunk.getZ(), null));
queue.addReadChunks(area.getRegion().getChunks()); queue.addReadChunks(area.getRegion().getChunks());
queue.setCompleteTask(() -> player.sendMessage(TranslatableCaption.of("single.regeneration_complete"))); queue.setCompleteTask(() -> player.sendMessage(TranslatableCaption.of("single.regeneration_complete")));
queue.enqueue(); queue.enqueue();
@ -734,21 +641,16 @@ public class Area extends SubCommand {
case "visit": case "visit":
case "tp": case "tp":
if (!Permissions.hasPermission(player, "plots.area.tp")) { if (!Permissions.hasPermission(player, "plots.area.tp")) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Template.of("node", "plots.area.tp"));
Template.of("node", "plots.area.tp"));
return false; return false;
} }
if (args.length != 2) { if (args.length != 2) {
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.command_syntax"), Template.of("value", "/plot visit [area]"));
TranslatableCaption.of("commandconfig.command_syntax"),
Template.of("value", "/plot visit [area]")
);
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[1]);
if (area == null) { if (area == null) {
player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), player.sendMessage(TranslatableCaption.of("errors.not_valid_plot_world"), Template.of("value", args[1]));
Template.of("value", args[1]));
return false; return false;
} }
Location center; Location center;
@ -757,13 +659,10 @@ public class Area extends SubCommand {
player.teleport(center, TeleportCause.COMMAND); player.teleport(center, TeleportCause.COMMAND);
} else { } else {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
center = Location.at(area.getWorldName(), region.getMinimumPoint().getX() center = Location.at(area.getWorldName(),
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, region.getMinimumPoint().getX() + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, 0,
0, region.getMinimumPoint().getZ() region.getMinimumPoint().getZ() + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) this.worldUtil.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(),
/ 2);
this.worldUtil
.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(),
y -> player.teleport(center.withY(1 + y), TeleportCause.COMMAND)); y -> player.teleport(center.withY(1 + y), TeleportCause.COMMAND));
} }
return true; return true;

View File

@ -248,7 +248,7 @@ public abstract class Command {
if (page < 0) { if (page < 0) {
page = 0; page = 0;
} }
int totalPages = (int) Math.ceil((double) c.size() / size); int totalPages = (int) Math.floor((double) c.size() / size);
if (page > totalPages) { if (page > totalPages) {
page = totalPages; page = totalPages;
} }
@ -266,9 +266,9 @@ public abstract class Command {
int i = page * size; int i = page * size;
for (T obj : subList) { for (T obj : subList) {
i++; i++;
CaptionHolder msg = new CaptionHolder(); final CaptionHolder msg = new CaptionHolder();
add.run(i, obj, msg); add.run(i, obj, msg);
player.sendMessage(msg.get()); player.sendMessage(msg.get(), msg.getTemplates());
} }
// Send the footer // Send the footer
if (page < totalPages && page > 0) { // Back | Next if (page < totalPages && page > 0) { // Back | Next

View File

@ -147,7 +147,7 @@ public class Debug extends SubCommand {
player.sendMessage(StaticCaption.of(msg.toString())); player.sendMessage(StaticCaption.of(msg.toString()));
return true; return true;
} }
TextComponent.Builder information = TextComponent.builder(); TextComponent.Builder information = Component.text();
Component header = MINI_MESSAGE.parse(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n"); Component header = MINI_MESSAGE.parse(TranslatableCaption.of("debug.debug_header").getComponent(player) + "\n");
String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n"; String line = TranslatableCaption.of("debug.debug_line").getComponent(player) + "\n";
String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n"; String section = TranslatableCaption.of("debug.debug_section").getComponent(player) + "\n";

View File

@ -33,6 +33,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.helpmenu.HelpMenu; import com.plotsquared.core.util.helpmenu.HelpMenu;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
@ -105,17 +106,17 @@ public class Help extends Command {
} }
} }
if (cat == null && page == 0) { if (cat == null && page == 0) {
TextComponent.Builder builder = TextComponent.builder(); TextComponent.Builder builder = Component.text();
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_header").getComponent(player))); builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_header").getComponent(player)));
for (CommandCategory c : CommandCategory.values()) { for (CommandCategory c : CommandCategory.values()) {
builder.append("\n").append(MINI_MESSAGE builder.append(Component.newline()).append(MINI_MESSAGE
.parse(TranslatableCaption.of("help.help_info_item").getComponent(player), Template.of("category", c.name().toLowerCase()), .parse(TranslatableCaption.of("help.help_info_item").getComponent(player), Template.of("category", c.name().toLowerCase()),
Template.of("category_desc", c.getComponent(player)))); Template.of("category_desc", c.getComponent(player))));
} }
builder.append("\n").append(MINI_MESSAGE builder.append(Component.newline()).append(MINI_MESSAGE
.parse(TranslatableCaption.of("help.help_info_item").getComponent(player), Template.of("category", "all"), .parse(TranslatableCaption.of("help.help_info_item").getComponent(player), Template.of("category", "all"),
Template.of("category_desc", "Display all commands"))); Template.of("category_desc", "Display all commands")));
builder.append("\n").append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_footer").getComponent(player))); builder.append(Component.newline()).append(MINI_MESSAGE.parse(TranslatableCaption.of("help.help_footer").getComponent(player)));
player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.asComponent()))); player.sendMessage(StaticCaption.of(MINI_MESSAGE.serialize(builder.asComponent())));
return true; return true;
} }

View File

@ -70,7 +70,7 @@ public class Inbox extends SubCommand {
if (max > comments.length) { if (max > comments.length) {
max = comments.length; max = comments.length;
} }
TextComponent.Builder builder = TextComponent.builder(); TextComponent.Builder builder = Component.text();
builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("list.comment_list_header_paged").getComponent(player) + '\n', builder.append(MINI_MESSAGE.parse(TranslatableCaption.of("list.comment_list_header_paged").getComponent(player) + '\n',
Template.of("amount", String.valueOf(comments.length)), Template.of("cur", String.valueOf(page + 1)), Template.of("amount", String.valueOf(comments.length)), Template.of("cur", String.valueOf(page + 1)),
Template.of("max", String.valueOf(totalPages + 1)), Template.of("word", "all"))); Template.of("max", String.valueOf(totalPages + 1)), Template.of("word", "all")));

View File

@ -58,7 +58,7 @@ public class Leave extends Command {
RunnableVal2<Command, CommandResult> whenDone) throws CommandException { RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot")); final Plot plot = check(player.getCurrentPlot(), TranslatableCaption.of("errors.not_in_plot"));
checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned")); checkTrue(plot.hasOwner(), TranslatableCaption.of("info.plot_unowned"));
checkTrue(plot.isAdded(player.getUUID()), TranslatableCaption.of("member.not_added_trusted")); checkTrue(plot.isAdded(player.getUUID()), TranslatableCaption.of("members.not_added_trusted"));
if (args.length == 0) { if (args.length == 0) {
sendUsage(player); sendUsage(player);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);

View File

@ -27,13 +27,12 @@ package com.plotsquared.core.command;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Caption; import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.CaptionHolder; import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates; import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
@ -52,10 +51,11 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy; import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -80,16 +80,14 @@ public class ListCmd extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EconHandler econHandler; private final EconHandler econHandler;
@Inject public ListCmd(@Nonnull final PlotAreaManager plotAreaManager, @Inject public ListCmd(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EconHandler econHandler) {
@Nonnull final EconHandler econHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.econHandler = econHandler; this.econHandler = econHandler;
} }
private String[] getArgumentList(PlotPlayer player) { private String[] getArgumentList(PlotPlayer player) {
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
if (this.econHandler != null && Permissions if (this.econHandler != null && Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
args.add("forsale"); args.add("forsale");
} }
if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {
@ -162,11 +160,8 @@ public class ListCmd extends SubCommand {
final Consumer<PlotQuery> plotConsumer = query -> { final Consumer<PlotQuery> plotConsumer = query -> {
if (query == null) { if (query == null) {
player.sendMessage( player.sendMessage(TranslatableCaption.of("commandconfig.did_you_mean"),
TranslatableCaption.of("commandconfig.did_you_mean"), Template.of("value", new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"}).getBestMatch()));
Template.of("value", new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"})
.getBestMatch())
);
return; return;
} }
@ -190,8 +185,7 @@ public class ListCmd extends SubCommand {
switch (arg) { switch (arg) {
case "mine": case "mine":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.mine"));
Templates.of("node", "plots.list.mine"));
return false; return false;
} }
sort[0] = false; sort[0] = false;
@ -199,29 +193,25 @@ public class ListCmd extends SubCommand {
break; break;
case "shared": case "shared":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_SHARED)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.shared"));
Templates.of("node", "plots.list.shared"));
return false; return false;
} }
plotConsumer.accept(PlotQuery.newQuery().withMember(player.getUUID()).thatPasses(plot -> !plot.isOwnerAbs(player.getUUID()))); plotConsumer.accept(PlotQuery.newQuery().withMember(player.getUUID()).thatPasses(plot -> !plot.isOwnerAbs(player.getUUID())));
break; break;
case "world": case "world":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world"));
Templates.of("node", "plots.list.world"));
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.list.world." + world)) { if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world" + world));
Templates.of("node", "plots.list.world" + world));
return false; return false;
} }
plotConsumer.accept(PlotQuery.newQuery().inWorld(world)); plotConsumer.accept(PlotQuery.newQuery().inWorld(world));
break; break;
case "expired": case "expired":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_EXPIRED)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.expired"));
Templates.of("node", "plots.list.expired"));
return false; return false;
} }
if (ExpireManager.IMP == null) { if (ExpireManager.IMP == null) {
@ -232,13 +222,11 @@ public class ListCmd extends SubCommand {
break; break;
case "area": case "area":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_AREA)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.area"));
Templates.of("node", "plots.list.area"));
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.list.world." + world)) { if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world" + world));
Templates.of("node", "plots.list.world" + world));
return false; return false;
} }
if (area == null) { if (area == null) {
@ -249,16 +237,14 @@ public class ListCmd extends SubCommand {
break; break;
case "all": case "all":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_ALL)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.all"));
Templates.of("node", "plots.list.all"));
return false; return false;
} }
plotConsumer.accept(PlotQuery.newQuery().allPlots()); plotConsumer.accept(PlotQuery.newQuery().allPlots());
break; break;
case "done": case "done":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_DONE)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.done"));
Templates.of("node", "plots.list.done"));
return false; return false;
} }
sort[0] = false; sort[0] = false;
@ -266,8 +252,7 @@ public class ListCmd extends SubCommand {
break; break;
case "top": case "top":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_TOP)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.top"));
Templates.of("node", "plots.list.top"));
return false; return false;
} }
sort[0] = false; sort[0] = false;
@ -275,8 +260,7 @@ public class ListCmd extends SubCommand {
break; break;
case "forsale": case "forsale":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.forsale"));
Templates.of("node", "plots.list.forsale"));
return false; return false;
} }
if (this.econHandler.isSupported()) { if (this.econHandler.isSupported()) {
@ -286,16 +270,14 @@ public class ListCmd extends SubCommand {
break; break;
case "unowned": case "unowned":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_UNOWNED)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.unowned"));
Templates.of("node", "plots.list.unowned"));
return false; return false;
} }
plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getOwner() == null)); plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getOwner() == null));
break; break;
case "fuzzy": case "fuzzy":
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_FUZZY)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.fuzzy"));
Templates.of("node", "plots.list.fuzzy"));
return false; return false;
} }
if (args.length < (page == -1 ? 2 : 3)) { if (args.length < (page == -1 ? 2 : 3)) {
@ -315,21 +297,18 @@ public class ListCmd extends SubCommand {
default: default:
if (this.plotAreaManager.hasPlotArea(args[0])) { if (this.plotAreaManager.hasPlotArea(args[0])) {
if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) { if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_WORLD)) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world"));
Templates.of("node", "plots.list.world"));
return false; return false;
} }
if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) { if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) {
player.sendMessage(TranslatableCaption.of("permission.no_permission"), player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.world." + args[0]));
Templates.of("node", "plots.list.world." + args[0]));
return false; return false;
} }
plotConsumer.accept(PlotQuery.newQuery().inWorld(args[0])); plotConsumer.accept(PlotQuery.newQuery().inWorld(args[0]));
break; break;
} }
PlotSquared.get().getImpromptuUUIDPipeline() PlotSquared.get().getImpromptuUUIDPipeline().getSingle(args[0], (uuid, throwable) -> {
.getSingle(args[0], (uuid, throwable) -> {
if (throwable instanceof TimeoutException) { if (throwable instanceof TimeoutException) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} else if (throwable != null) { } else if (throwable != null) {
@ -341,13 +320,10 @@ public class ListCmd extends SubCommand {
} }
} }
if (uuid == null) { if (uuid == null) {
player.sendMessage(TranslatableCaption.of("errors.invalid_player"), player.sendMessage(TranslatableCaption.of("errors.invalid_player"), Templates.of("value", args[0]));
Templates.of("value", args[0]));
} else { } else {
if (!Permissions if (!Permissions.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) {
.hasPermission(player, Permission.PERMISSION_LIST_PLAYER)) { player.sendMessage(TranslatableCaption.of("permission.no_permission"), Templates.of("node", "plots.list.player"));
player.sendMessage(TranslatableCaption.of("permission.no_permission"),
Templates.of("node", "plots.list.player"));
} else { } else {
sort[0] = false; sort[0] = false;
plotConsumer.accept(PlotQuery.newQuery().ownedBy(uuid).withSortingStrategy(SortingStrategy.SORT_BY_TEMP)); plotConsumer.accept(PlotQuery.newQuery().ownedBy(uuid).withSortingStrategy(SortingStrategy.SORT_BY_TEMP));
@ -376,32 +352,32 @@ public class ListCmd extends SubCommand {
} else { } else {
color = TranslatableCaption.of("info.plot_list_default"); color = TranslatableCaption.of("info.plot_list_default");
} }
String trusted = MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_trusted").getComponent(player), Component trusted = MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_trusted").getComponent(player),
Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted())))); Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted())));
String members = MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_members").getComponent(player), Component members = MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_members").getComponent(player),
Template.of("members", PlayerManager.getPlayerList(plot.getMembers())))); Template.of("members", PlayerManager.getPlayerList(plot.getMembers())));
Template command_tp = Template.of("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId()); Template command_tp = Template.of("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId());
Template command_info = Template.of("command_info", "/plot info " + plot.getArea() + ";" + plot.getId()); Template command_info = Template.of("command_info", "/plot info " + plot.getArea() + ";" + plot.getId());
Template hover_info = Template.of("hover_info", trusted + "\n" + members); Template hover_info =
Template.of("hover_info", MINI_MESSAGE.serialize(Component.text().append(trusted).append(Component.newline()).append(members).asComponent()));
Template numberTemplate = Template.of("number", String.valueOf(i)); Template numberTemplate = Template.of("number", String.valueOf(i));
Template plotTemplate = Template plotTemplate = Template.of("plot", MINI_MESSAGE.parse(color.getComponent(player), Template.of("plot", plot.toString())));
Template.of("plot", MINI_MESSAGE.serialize(MINI_MESSAGE.parse(color.getComponent(player), Template.of("plot", plot.toString()))));
String prefix = ""; String prefix = "";
String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player); String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player);
String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player); String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player);
StringBuilder builder = new StringBuilder(); TextComponent.Builder builder = Component.text();
try { try {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) { for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid()); PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid());
Template prefixTemplate = Template.of("prefix", prefix); Template prefixTemplate = Template.of("prefix", prefix);
Template playerTemplate = Template.of("prefix", uuidMapping.getUsername()); Template playerTemplate = Template.of("player", uuidMapping.getUsername());
if (pp != null) { if (pp != null) {
builder.append(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate))); builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate));
} else { } else {
builder.append(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate))); builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate));
} }
prefix = ", "; prefix = ", ";
} }
@ -419,18 +395,16 @@ public class ListCmd extends SubCommand {
} catch (TimeoutException e) { } catch (TimeoutException e) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} }
Template players = Template.of("players", builder.toString()); Template players = Template.of("players", builder.asComponent());
caption.set(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE caption.set(TranslatableCaption.of("info.plot_list_item"));
.parse(TranslatableCaption.of("info.plot_list_item").getComponent(player), command_tp, command_info, hover_info, numberTemplate, caption.setTemplates(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players);
plotTemplate, players))));
} }
}, "/plot list " + args[0], TranslatableCaption.of("list.plot_list_header_paged")); }, "/plot list " + args[0], TranslatableCaption.of("list.plot_list_header_paged"));
} }
@Override public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) { @Override public Collection<Command> tab(PlotPlayer<?> player, String[] args, boolean space) {
final List<String> completions = new LinkedList<>(); final List<String> completions = new LinkedList<>();
if (this.econHandler.isSupported() && Permissions if (this.econHandler.isSupported() && Permissions.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
.hasPermission(player, Permission.PERMISSION_LIST_FOR_SALE)) {
completions.add("forsale"); completions.add("forsale");
} }
if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) { if (Permissions.hasPermission(player, Permission.PERMISSION_LIST_MINE)) {

View File

@ -45,10 +45,11 @@ public class PluginCmd extends SubCommand {
StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared.platform().getPluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"), StaticCaption.of("<gray>>> </gray><gold><bold>" + PlotSquared.platform().getPluginName() + " <reset><gray>(<gold>Version</gold><gray>: </gray><gold><version></gold><gray>)</gray>"),
Template.of("version", String.valueOf(PlotSquared.get().getVersion())) Template.of("version", String.valueOf(PlotSquared.get().getVersion()))
); );
player.sendMessage(StaticCaption.of("<gray> >> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray><gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray><gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>")); player.sendMessage(StaticCaption.of("<gray>>> </gray><gold><bold>Authors<reset><gray>: </gray><gold>Citymonstret </gold><gray>& </gray><gold>Empire92 </gold><gray>& </gray><gold>MattBDev </gold><gray>& </gray><gold>dordsor21 </gold><gray>& </gray><gold>NotMyFault </gold><gray>& </gray><gold>SirYwell</gold>"));
player.sendMessage(StaticCaption.of("<gray> >> </gray><gold><bold>Wiki<reset><gray>: </gray><gold><click:open_url>https://wiki.intellectualsites.com/plotsquared/home</gold>")); player.sendMessage(StaticCaption.of("<gray>>> </gray><gold><bold>Wiki<reset><gray>: </gray><gold><click:open_url:https://wiki.intellectualsites.com/plotsquared/home>https://wiki.intellectualsites.com/plotsquared/home</gold>"));
player.sendMessage(StaticCaption.of("<gray>>> </gray><gold><bold>Discord<reset><gray>: </gray><gold><click:open_url:https://discord.gg/KxkjDVg>https://discord.gg/KxkjDVg</gold>"));
player.sendMessage( player.sendMessage(
StaticCaption.of("<gray> >> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"), StaticCaption.of("<gray>>> </gray><gold><bold>Premium<reset><gray>: <gold><value></gold>"),
Template.of("value", String.valueOf(PremiumVerification.isPremium())) Template.of("value", String.valueOf(PremiumVerification.isPremium()))
); );
}); });

View File

@ -60,10 +60,8 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;

View File

@ -25,9 +25,12 @@
*/ */
package com.plotsquared.core.configuration.caption; package com.plotsquared.core.configuration.caption;
import net.kyori.adventure.text.minimessage.Template;
public class CaptionHolder { public class CaptionHolder {
private Caption caption = StaticCaption.of(""); private Caption caption = StaticCaption.of("");
private Template[] templates = new Template[0];
public void set(Caption caption) { public void set(Caption caption) {
this.caption = caption; this.caption = caption;
@ -37,4 +40,12 @@ public class CaptionHolder {
return this.caption; return this.caption;
} }
public Template[] getTemplates() {
return this.templates;
}
public void setTemplates(Template... templates) {
this.templates = templates;
}
} }

View File

@ -47,7 +47,7 @@ public interface PermissionHolder {
} }
/** /**
* Check the the highest permission a PlotPlayer has within a specified range.<br> * Check the highest permission a PlotPlayer has within a specified range.<br>
* - Excessively high values will lag<br> * - Excessively high values will lag<br>
* - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}<br> * - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}<br>
* *

View File

@ -799,12 +799,12 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
} }
/** /**
* Send a title to to the player * Send a title to the player
* *
* @param title Title * @param title Title
* @param subtitle Subtitle * @param subtitle Subtitle
* @param fadeIn Fade in time (in ticks) * @param fadeIn Fade in time (in ticks)
* @param stay The the title stays for (in ticks) * @param stay The title stays for (in ticks)
* @param fadeOut Fade out time (in ticks) * @param fadeOut Fade out time (in ticks)
* @param replacements Variable replacements * @param replacements Variable replacements
*/ */
@ -818,7 +818,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
Duration.of(stay * 50, ChronoUnit.MILLIS), Duration.of(stay * 50, ChronoUnit.MILLIS),
Duration.of(fadeOut * 50, ChronoUnit.MILLIS)); Duration.of(fadeOut * 50, ChronoUnit.MILLIS));
getAudience().showTitle(Title getAudience().showTitle(Title
.of(titleComponent, subtitleComponent, times)); .title(titleComponent, subtitleComponent, times));
} }
@Override public void sendMessage(@Nonnull final Caption caption, @Override public void sendMessage(@Nonnull final Caption caption,

View File

@ -76,6 +76,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -2663,9 +2664,9 @@ public class Plot {
String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player); String alias = !this.getAlias().isEmpty() ? this.getAlias() : TranslatableCaption.of("info.none").getComponent(player);
Location bot = this.getCorners()[0]; Location bot = this.getCorners()[0];
PlotSquared.platform().getWorldUtil().getBiome(Objects.requireNonNull(this.getWorldName()), bot.getX(), bot.getZ(), biome -> { PlotSquared.platform().getWorldUtil().getBiome(Objects.requireNonNull(this.getWorldName()), bot.getX(), bot.getZ(), biome -> {
String trusted = PlayerManager.getPlayerList(this.getTrusted()); Component trusted = PlayerManager.getPlayerList(this.getTrusted());
String members = PlayerManager.getPlayerList(this.getMembers()); Component members = PlayerManager.getPlayerList(this.getMembers());
String denied = PlayerManager.getPlayerList(this.getDenied()); Component denied = PlayerManager.getPlayerList(this.getDenied());
String seen; String seen;
if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) { if (Settings.Enabled_Components.PLOT_EXPIRY && ExpireManager.IMP != null) {
if (this.isOnline()) { if (this.isOnline()) {
@ -2712,7 +2713,7 @@ public class Plot {
} }
} }
boolean build = this.isAdded(player.getUUID()); boolean build = this.isAdded(player.getUUID());
String owner = this.getOwners().isEmpty() ? "unowned" : PlayerManager.getPlayerList(this.getOwners()); Component owner = this.getOwners().isEmpty() ? Component.text("unowned") : PlayerManager.getPlayerList(this.getOwners());
Template headerTemplate = Template.of("header", TranslatableCaption.of("info.plot_info_header").getComponent(player)); Template headerTemplate = Template.of("header", TranslatableCaption.of("info.plot_info_header").getComponent(player));
Template footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player)); Template footerTemplate = Template.of("footer", TranslatableCaption.of("info.plot_info_footer").getComponent(player));
Template areaTemplate; Template areaTemplate;
@ -2748,13 +2749,14 @@ public class Plot {
} }
if (full && Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) { if (full && Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
double[] ratings = this.getAverageRatings(); double[] ratings = this.getAverageRatings();
String rating = ""; StringBuilder rating = new StringBuilder();
String prefix = ""; String prefix = "";
for (int i = 0; i < ratings.length; i++) { for (int i = 0; i < ratings.length; i++) {
rating += prefix + Settings.Ratings.CATEGORIES.get(i) + '=' + String.format("%.1f", ratings[i]); rating.append(prefix).append(Settings.Ratings.CATEGORIES.get(i)).append('=')
.append(String.format("%.1f", ratings[i]));
prefix = ","; prefix = ",";
} }
ratingTemplate = Template.of("rating", rating); ratingTemplate = Template.of("rating", rating.toString());
} else { } else {
ratingTemplate = Template.of("rating", String.format("%.1f", this.getAverageRating()) + '/' + max); ratingTemplate = Template.of("rating", String.format("%.1f", this.getAverageRating()) + '/' + max);
} }

View File

@ -388,9 +388,7 @@ public abstract class PlotArea {
this.spawnCustom = config.getBoolean("event.spawn.custom"); this.spawnCustom = config.getBoolean("event.spawn.custom");
this.spawnBreeding = config.getBoolean("event.spawn.breeding"); this.spawnBreeding = config.getBoolean("event.spawn.breeding");
List<String> roadflags = config.getStringList("flags.default"); List<String> roadflags = config.getStringList("road.flags");
if (roadflags.isEmpty()) {
roadflags = config.getStringList("road.flags");
if (roadflags.isEmpty()) { if (roadflags.isEmpty()) {
roadflags = new ArrayList<>(); roadflags = new ArrayList<>();
ConfigurationSection section = config.getConfigurationSection("road.flags"); ConfigurationSection section = config.getConfigurationSection("road.flags");
@ -401,7 +399,6 @@ public abstract class PlotArea {
} }
} }
} }
}
this.getRoadFlagContainer().addAll(parseFlags(roadflags)); this.getRoadFlagContainer().addAll(parseFlags(roadflags));
Component roadFlagsComponent = null; Component roadFlagsComponent = null;

View File

@ -93,7 +93,7 @@ public class Permissions {
} }
/** /**
* Check the the highest permission a PlotPlayer has within a specified range.<br> * Check the highest permission a PlotPlayer has within a specified range.<br>
* - Excessively high values will lag<br> * - Excessively high values will lag<br>
* - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}<br> * - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}<br>
* *

View File

@ -27,6 +27,7 @@ package com.plotsquared.core.util;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.ConsolePlayer;
@ -34,6 +35,7 @@ import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
@ -110,9 +112,9 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
* - Uses the format {@link TranslatableCaption#of(String)} of "info.plot_user_list" for the returned string * - Uses the format {@link TranslatableCaption#of(String)} of "info.plot_user_list" for the returned string
* *
* @param uuids UUIDs * @param uuids UUIDs
* @return Name list * @return Component of name list
*/ */
@Nonnull public static String getPlayerList(@Nonnull final Collection<UUID> uuids) { @Nonnull public static Component getPlayerList(@Nonnull final Collection<UUID> uuids) {
if (uuids.size() < 1) { if (uuids.size() < 1) {
TranslatableCaption.of("info.none"); TranslatableCaption.of("info.none");
} }
@ -141,7 +143,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
} }
String c = TranslatableCaption.of("info.plot_user_list").getComponent(ConsolePlayer.getConsole()); String c = TranslatableCaption.of("info.plot_user_list").getComponent(ConsolePlayer.getConsole());
Component list = MINI_MESSAGE.deserialize(""); TextComponent.Builder list = Component.text();
for (int x = 0; x < users.size(); x++) { for (int x = 0; x < users.size(); x++) {
if (x + 1 == uuids.size()) { if (x + 1 == uuids.size()) {
list.append(MINI_MESSAGE.parse(c, Template.of("user", users.get(x)))); list.append(MINI_MESSAGE.parse(c, Template.of("user", users.get(x))));
@ -149,7 +151,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
list.append(MINI_MESSAGE.parse(c + ", ", Template.of("user", users.get(x)))); list.append(MINI_MESSAGE.parse(c + ", ", Template.of("user", users.get(x))));
} }
} }
return list.toString(); return list.asComponent();
} }
/** /**

View File

@ -1,5 +1,5 @@
<p align="center"> <p align="center">
<img src="https://i.imgur.com/33Y65YL.png" width="300"> <img src="plotsquared-logo.png" width="300">
</p> </p>
--- ---

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-rc-3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

21
gradlew.bat vendored
View File

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

BIN
plotsquared-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB