mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Prevent synchronous chunk loading whenever possible
This commit is contained in:
parent
7841ee3dcc
commit
5547185b3f
@ -776,7 +776,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
// to is identical to the plot's home location, and untrusted-visit is true
|
// to is identical to the plot's home location, and untrusted-visit is true
|
||||||
// i.e. untrusted-visit can override deny-teleport
|
// i.e. untrusted-visit can override deny-teleport
|
||||||
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
// this is acceptable, because otherwise it wouldn't make sense to have both flags set
|
||||||
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHome()
|
if (!result && !(plot.getFlag(UntrustedVisitFlag.class) && plot.getHomeSynchronous()
|
||||||
.equals(BukkitUtil.getLocationFull(to)))) {
|
.equals(BukkitUtil.getLocationFull(to)))) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
||||||
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
Captions.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
|
@ -162,7 +162,7 @@ public class Placeholders extends PlaceholderExpansion {
|
|||||||
if (pl.getCurrentPlot() == null) {
|
if (pl.getCurrentPlot() == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return plot.getBiome() + "";
|
return plot.getBiomeSynchronous() + "";
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.bukkit.util;
|
package com.github.intellectualsites.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.bukkit.BukkitMain;
|
||||||
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
@ -7,7 +8,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||||
@ -20,8 +20,10 @@ import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|||||||
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 com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -33,18 +35,16 @@ import org.bukkit.block.data.Directional;
|
|||||||
import org.bukkit.block.data.type.WallSign;
|
import org.bukkit.block.data.type.WallSign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
@ -104,17 +104,6 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return getPlot(player.getLocation());
|
return getPlot(player.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get home location.
|
|
||||||
*
|
|
||||||
* @param plot Plot that you want to get the location for
|
|
||||||
* @return plot bottom location
|
|
||||||
* @see Plot
|
|
||||||
*/
|
|
||||||
public static org.bukkit.Location getHomeLocation(Plot plot) {
|
|
||||||
return BukkitUtil.getLocation(plot.getHome());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotPlayer for an offline player.
|
* Get the PlotPlayer for an offline player.
|
||||||
*
|
*
|
||||||
@ -219,7 +208,6 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
*
|
*
|
||||||
* @param player the recipient of the message
|
* @param player the recipient of the message
|
||||||
* @param caption the message
|
* @param caption the message
|
||||||
* @see MainUtil#sendMessage(com.github.intellectualsites.plotsquared.commands.CommandCaller, Captions, String...)
|
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(Player player, Captions caption) {
|
public static void sendMessage(Player player, Captions caption) {
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
||||||
@ -303,11 +291,43 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return getWorld(worldName) != null;
|
return getWorld(worldName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BiomeType getBiome(String world, int x, int z) {
|
@Override public void getBiome(String world, int x, int z, final Consumer<BiomeType> result) {
|
||||||
|
ensureLoaded(world, x, z, chunk ->
|
||||||
|
result.accept(BukkitAdapter.adapt(getWorld(world).getBiome(x, z))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public BiomeType getBiomeSynchronous(String world, int x, int z) {
|
||||||
return BukkitAdapter.adapt(getWorld(world).getBiome(x, z));
|
return BukkitAdapter.adapt(getWorld(world).getBiome(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getHighestBlock(@NonNull final String world, final int x, final int z) {
|
@Override public void getHighestBlock(@NonNull final String world, final int x, final int z,
|
||||||
|
final Consumer<Integer> result) {
|
||||||
|
ensureLoaded(world, x, z, chunk -> {
|
||||||
|
final World bukkitWorld = getWorld(world);
|
||||||
|
// Skip top and bottom block
|
||||||
|
int air = 1;
|
||||||
|
for (int y = bukkitWorld.getMaxHeight() - 1; y >= 0; y--) {
|
||||||
|
Block block = bukkitWorld.getBlockAt(x, y, z);
|
||||||
|
Material type = block.getType();
|
||||||
|
if (type.isSolid()) {
|
||||||
|
if (air > 1) {
|
||||||
|
result.accept(y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
air = 0;
|
||||||
|
} else {
|
||||||
|
if (block.isLiquid()) {
|
||||||
|
result.accept(y);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
air++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.accept(bukkitWorld.getMaxHeight() - 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int getHighestBlockSynchronous(String world, int x, int z) {
|
||||||
final World bukkitWorld = getWorld(world);
|
final World bukkitWorld = getWorld(world);
|
||||||
// Skip top and bottom block
|
// Skip top and bottom block
|
||||||
int air = 1;
|
int air = 1;
|
||||||
@ -329,7 +349,17 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return bukkitWorld.getMaxHeight() - 1;
|
return bukkitWorld.getMaxHeight() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @Nullable public String[] getSign(@NonNull final Location location) {
|
@Override public void getSign(@NonNull final Location location, final Consumer<String[]> result) {
|
||||||
|
ensureLoaded(location, chunk -> {
|
||||||
|
final Block block = chunk.getWorld().getBlockAt(getLocation(location));
|
||||||
|
if (block.getState() instanceof Sign) {
|
||||||
|
Sign sign = (Sign) block.getState();
|
||||||
|
result.accept(sign.getLines());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override @Nullable public String[] getSignSynchronous(@NonNull final Location location) {
|
||||||
Block block = getWorld(location.getWorld())
|
Block block = getWorld(location.getWorld())
|
||||||
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
return TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
return TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
||||||
@ -365,6 +395,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
@Override @SuppressWarnings("deprecation")
|
@Override @SuppressWarnings("deprecation")
|
||||||
public void setSign(@NonNull final String worldName, final int x, final int y, final int z,
|
public void setSign(@NonNull final String worldName, final int x, final int y, final int z,
|
||||||
@NonNull final String[] lines) {
|
@NonNull final String[] lines) {
|
||||||
|
ensureLoaded(worldName, x, z, chunk -> {
|
||||||
final World world = getWorld(worldName);
|
final World world = getWorld(worldName);
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
// block.setType(Material.AIR);
|
// block.setType(Material.AIR);
|
||||||
@ -399,26 +430,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
}
|
}
|
||||||
sign.update(true);
|
sign.update(true);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addItems(@NonNull final String worldName, @NonNull final PlotItem items) {
|
|
||||||
final World world = getWorld(worldName);
|
|
||||||
final Block block = world.getBlockAt(items.x, items.y, items.z);
|
|
||||||
final org.bukkit.block.BlockState state = block.getState();
|
|
||||||
if (state instanceof InventoryHolder) {
|
|
||||||
InventoryHolder holder = (InventoryHolder) state;
|
|
||||||
Inventory inv = holder.getInventory();
|
|
||||||
for (int i = 0; i < items.types.length; i++) {
|
|
||||||
// ItemStack item = new ItemStack(LegacyMappings.fromLegacyId(items.id[i]).getMaterial(), items.amount[i], items.data[i]);
|
|
||||||
ItemStack item =
|
|
||||||
new ItemStack(BukkitAdapter.adapt(items.types[i]), items.amount[i]);
|
|
||||||
inv.addItem(item);
|
|
||||||
}
|
|
||||||
state.update(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isBlockSolid(@NonNull final BlockState block) {
|
@Override public boolean isBlockSolid(@NonNull final BlockState block) {
|
||||||
@ -471,7 +483,15 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
return new BukkitWorld(Bukkit.getWorld(world));
|
return new BukkitWorld(Bukkit.getWorld(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public BlockState getBlock(@NonNull final Location location) {
|
@Override public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) {
|
||||||
|
ensureLoaded(location, chunk -> {
|
||||||
|
final World world = getWorld(location.getWorld());
|
||||||
|
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
|
result.accept(BukkitAdapter.asBlockType(block.getType()).getDefaultState());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public BlockState getBlockSynchronous(@NonNull final Location location) {
|
||||||
final World world = getWorld(location.getWorld());
|
final World world = getWorld(location.getWorld());
|
||||||
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
||||||
@ -496,4 +516,24 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
@Override public void setFoodLevel(PlotPlayer player, int foodLevel) {
|
@Override public void setFoodLevel(PlotPlayer player, int foodLevel) {
|
||||||
Bukkit.getPlayer(player.getUUID()).setFoodLevel(foodLevel);
|
Bukkit.getPlayer(player.getUUID()).setFoodLevel(foodLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ensureLoaded(final String world, final int x, final int z, final Consumer<Chunk> chunkConsumer) {
|
||||||
|
PaperLib.getChunkAtAsync(getWorld(world), x << 4, z << 4, true).thenAccept(chunk ->
|
||||||
|
ensureMainThread(chunkConsumer, chunk));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ensureLoaded(final Location location, final Consumer<Chunk> chunkConsumer) {
|
||||||
|
PaperLib.getChunkAtAsync(getLocation(location), true).thenAccept(chunk ->
|
||||||
|
ensureMainThread(chunkConsumer, chunk));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> void ensureMainThread(final Consumer<T> consumer, final T value) {
|
||||||
|
if (Bukkit.isPrimaryThread()) {
|
||||||
|
consumer.accept(value);
|
||||||
|
} else {
|
||||||
|
Bukkit.getScheduler().runTask(BukkitMain.getPlugin(BukkitMain.class), () ->
|
||||||
|
consumer.accept(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -471,16 +471,18 @@ public class Area extends SubCommand {
|
|||||||
Location center;
|
Location center;
|
||||||
if (area.getType() != PlotAreaType.PARTIAL) {
|
if (area.getType() != PlotAreaType.PARTIAL) {
|
||||||
center = WorldUtil.IMP.getSpawn(area.getWorldName());
|
center = WorldUtil.IMP.getSpawn(area.getWorldName());
|
||||||
|
player.teleport(center, TeleportCause.COMMAND);
|
||||||
} else {
|
} else {
|
||||||
CuboidRegion region = area.getRegion();
|
CuboidRegion region = area.getRegion();
|
||||||
center = new Location(area.getWorldName(), region.getMinimumPoint().getX()
|
center = new Location(area.getWorldName(), region.getMinimumPoint().getX()
|
||||||
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
|
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
|
||||||
0, region.getMinimumPoint().getZ()
|
0, region.getMinimumPoint().getZ()
|
||||||
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
|
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
|
||||||
center.setY(1 + WorldUtil.IMP
|
WorldUtil.IMP.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y -> {
|
||||||
.getHighestBlock(area.getWorldName(), center.getX(), center.getZ()));
|
center.setY(1 + y);
|
||||||
}
|
|
||||||
player.teleport(center, TeleportCause.COMMAND);
|
player.teleport(center, TeleportCause.COMMAND);
|
||||||
|
});
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case "delete":
|
case "delete":
|
||||||
case "remove":
|
case "remove":
|
||||||
|
@ -94,7 +94,7 @@ public class Auto extends SubCommand {
|
|||||||
final String schematic) {
|
final String schematic) {
|
||||||
Set<Plot> plots = player.getPlots();
|
Set<Plot> plots = player.getPlots();
|
||||||
if (!plots.isEmpty()) {
|
if (!plots.isEmpty()) {
|
||||||
plots.iterator().next().teleportPlayer(player, TeleportCause.COMMAND);
|
plots.iterator().next().teleportPlayer(player, TeleportCause.COMMAND, result -> {});
|
||||||
} else {
|
} else {
|
||||||
autoClaimSafe(player, area, start, schematic);
|
autoClaimSafe(player, area, start, schematic);
|
||||||
}
|
}
|
||||||
|
@ -555,7 +555,7 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.teleport(cluster.getHome(), TeleportCause.COMMAND);
|
cluster.getHome(home -> player.teleport(home, TeleportCause.COMMAND));
|
||||||
return MainUtil.sendMessage(player, Captions.CLUSTER_TELEPORTING);
|
return MainUtil.sendMessage(player, Captions.CLUSTER_TELEPORTING);
|
||||||
}
|
}
|
||||||
case "i":
|
case "i":
|
||||||
|
@ -71,7 +71,7 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
Location location = manager.getSignLoc(plot);
|
Location location = manager.getSignLoc(plot);
|
||||||
BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4);
|
BlockVector2 chunk = BlockVector2.at(location.getX() >> 4, location.getZ() >> 4);
|
||||||
ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
||||||
String[] lines = WorldUtil.IMP.getSign(location);
|
String[] lines = WorldUtil.IMP.getSignSynchronous(location);
|
||||||
if (lines != null) {
|
if (lines != null) {
|
||||||
String line = lines[2];
|
String line = lines[2];
|
||||||
if (line != null && line.length() > 2) {
|
if (line != null && line.length() > 2) {
|
||||||
|
@ -47,7 +47,7 @@ public class Like extends SubCommand {
|
|||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot
|
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot
|
||||||
.isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
|
.isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
|
||||||
plot.teleportPlayer(player, TeleportCause.COMMAND);
|
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {});
|
||||||
MainUtil.sendMessage(player, Captions.RATE_THIS);
|
MainUtil.sendMessage(player, Captions.RATE_THIS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class MainCommand extends Command {
|
|||||||
.equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN)
|
.equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN)
|
||||||
|| Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_SUDO_AREA))
|
|| Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_SUDO_AREA))
|
||||||
&& !newPlot.isDenied(player.getUUID())) {
|
&& !newPlot.isDenied(player.getUUID())) {
|
||||||
Location newLoc = newPlot.getCenter();
|
Location newLoc = newPlot.getCenterSynchronous();
|
||||||
if (player.canTeleport(newLoc)) {
|
if (player.canTeleport(newLoc)) {
|
||||||
// Save meta
|
// Save meta
|
||||||
location = player.getMeta(PlotPlayer.META_LOCATION);
|
location = player.getMeta(PlotPlayer.META_LOCATION);
|
||||||
|
@ -24,7 +24,7 @@ public class Middle extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
player.teleport(plot.getCenter(), TeleportCause.COMMAND);
|
plot.getCenter(center -> player.teleport(center, TeleportCause.COMMAND));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class Rate extends SubCommand {
|
|||||||
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p
|
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(p)) && p
|
||||||
.isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p
|
.isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p
|
||||||
.isAdded(uuid)) {
|
.isAdded(uuid)) {
|
||||||
p.teleportPlayer(player, TeleportCause.COMMAND);
|
p.teleportPlayer(player, TeleportCause.COMMAND, result -> {});
|
||||||
MainUtil.sendMessage(player, Captions.RATE_THIS);
|
MainUtil.sendMessage(player, Captions.RATE_THIS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class Target extends SubCommand {
|
|||||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||||
int distance = Integer.MAX_VALUE;
|
int distance = Integer.MAX_VALUE;
|
||||||
for (Plot plot : PlotSquared.get().getPlots(location.getWorld())) {
|
for (Plot plot : PlotSquared.get().getPlots(location.getWorld())) {
|
||||||
double current = plot.getCenter().getEuclideanDistanceSquared(location);
|
double current = plot.getCenterSynchronous().getEuclideanDistanceSquared(location);
|
||||||
if (current < distance) {
|
if (current < distance) {
|
||||||
distance = (int) current;
|
distance = (int) current;
|
||||||
target = plot;
|
target = plot;
|
||||||
@ -45,7 +45,7 @@ public class Target extends SubCommand {
|
|||||||
} else if ((target = MainUtil.getPlotFromString(player, args[0], true)) == null) {
|
} else if ((target = MainUtil.getPlotFromString(player, args[0], true)) == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.setCompassTarget(target.getCenter());
|
target.getCenter(player::setCompassTarget);
|
||||||
MainUtil.sendMessage(player, Captions.COMPASS_TARGET);
|
MainUtil.sendMessage(player, Captions.COMPASS_TARGET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -149,13 +149,14 @@ public class Visit extends Command {
|
|||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
confirm.run(this, () -> {
|
confirm.run(this, () ->
|
||||||
if (plot.teleportPlayer(player, TeleportCause.COMMAND)) {
|
plot.teleportPlayer(player, TeleportCause.COMMAND, result -> {
|
||||||
|
if (result) {
|
||||||
whenDone.run(Visit.this, CommandResult.SUCCESS);
|
whenDone.run(Visit.this, CommandResult.SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
whenDone.run(Visit.this, CommandResult.FAILURE);
|
whenDone.run(Visit.this, CommandResult.FAILURE);
|
||||||
}
|
}
|
||||||
}, () -> whenDone.run(Visit.this, CommandResult.FAILURE));
|
}), () -> whenDone.run(Visit.this, CommandResult.FAILURE));
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
HybridUtils.UPDATE = true;
|
HybridUtils.UPDATE = true;
|
||||||
Set<BlockVector2> regions = new HashSet<>();
|
Set<BlockVector2> regions = new HashSet<>();
|
||||||
regions.add(ChunkManager.getRegion(plot.getCenter()));
|
regions.add(ChunkManager.getRegion(plot.getCenterSynchronous()));
|
||||||
return scheduleRoadUpdate(plot.getArea(), regions, extend, new HashSet<>());
|
return scheduleRoadUpdate(plot.getArea(), regions, extend, new HashSet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.object;
|
package com.github.intellectualsites.plotsquared.plot.object;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
@ -19,7 +18,14 @@ import com.github.intellectualsites.plotsquared.plot.generator.SquarePlotWorld;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
@ -60,6 +66,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.github.intellectualsites.plotsquared.plot.commands.SubCommand.sendMessage;
|
import static com.github.intellectualsites.plotsquared.plot.commands.SubCommand.sendMessage;
|
||||||
@ -1319,7 +1326,32 @@ public class Plot {
|
|||||||
return this.unlinkPlot(true, true);
|
return this.unlinkPlot(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getCenter() {
|
public void getCenter(final Consumer<Location> result) {
|
||||||
|
Location[] corners = getCorners();
|
||||||
|
Location top = corners[0];
|
||||||
|
Location bot = corners[1];
|
||||||
|
Location location =
|
||||||
|
new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
||||||
|
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||||
|
if (!isLoaded()) {
|
||||||
|
result.accept(location);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
|
||||||
|
int height = y;
|
||||||
|
if (area.allowSigns()) {
|
||||||
|
height = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
|
}
|
||||||
|
location.setY(1 + height);
|
||||||
|
result.accept(location);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated May cause synchronous chunk loads
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Location getCenterSynchronous() {
|
||||||
Location[] corners = getCorners();
|
Location[] corners = getCorners();
|
||||||
Location top = corners[0];
|
Location top = corners[0];
|
||||||
Location bot = corners[1];
|
Location bot = corners[1];
|
||||||
@ -1329,7 +1361,7 @@ public class Plot {
|
|||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
int y = WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ());
|
int y = WorldUtil.IMP.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
||||||
if (area.allowSigns()) {
|
if (area.allowSigns()) {
|
||||||
y = Math.max(y, getManager().getSignLoc(this).getY());
|
y = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
}
|
}
|
||||||
@ -1337,28 +1369,54 @@ public class Plot {
|
|||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getSide() {
|
/**
|
||||||
|
* @deprecated May cause synchronous chunk loads
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Location getSideSynchronous() {
|
||||||
CuboidRegion largest = getLargestRegion();
|
CuboidRegion largest = getLargestRegion();
|
||||||
int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1)
|
int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1)
|
||||||
+ largest.getMinimumPoint().getX();
|
+ largest.getMinimumPoint().getX();
|
||||||
int z = largest.getMinimumPoint().getZ() - 1;
|
int z = largest.getMinimumPoint().getZ() - 1;
|
||||||
PlotManager manager = getManager();
|
PlotManager manager = getManager();
|
||||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62;
|
int y = isLoaded() ? WorldUtil.IMP.getHighestBlockSynchronous(getWorldName(), x, z) : 62;
|
||||||
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
||||||
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
||||||
}
|
}
|
||||||
return new Location(getWorldName(), x, y + 1, z);
|
return new Location(getWorldName(), x, y + 1, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getSide(Consumer<Location> result) {
|
||||||
|
CuboidRegion largest = getLargestRegion();
|
||||||
|
int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1)
|
||||||
|
+ largest.getMinimumPoint().getX();
|
||||||
|
int z = largest.getMinimumPoint().getZ() - 1;
|
||||||
|
PlotManager manager = getManager();
|
||||||
|
if (isLoaded()) {
|
||||||
|
WorldUtil.IMP.getHighestBlock(getWorldName(), x, z, y -> {
|
||||||
|
int height = y;
|
||||||
|
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
||||||
|
height = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
||||||
|
}
|
||||||
|
result.accept(new Location(getWorldName(), x, height + 1, z));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
int y = 62;
|
||||||
|
if (area.allowSigns()) {
|
||||||
|
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
||||||
|
}
|
||||||
|
result.accept(new Location(getWorldName(), x, y + 1, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the home location for the plot
|
* @deprecated May cause synchronous chunk loading
|
||||||
*
|
|
||||||
* @return Home location
|
|
||||||
*/
|
*/
|
||||||
public Location getHome() {
|
@Deprecated
|
||||||
|
public Location getHomeSynchronous() {
|
||||||
BlockLoc home = this.getPosition();
|
BlockLoc home = this.getPosition();
|
||||||
if (home == null || home.getX() == 0 && home.getZ() == 0) {
|
if (home == null || home.getX() == 0 && home.getZ() == 0) {
|
||||||
return this.getDefaultHome(true);
|
return this.getDefaultHomeSynchronous(true);
|
||||||
} else {
|
} else {
|
||||||
Location bottom = this.getBottomAbs();
|
Location bottom = this.getBottomAbs();
|
||||||
Location location = new Location(bottom.getWorld(), bottom.getX() + home.getX(),
|
Location location = new Location(bottom.getWorld(), bottom.getX() + home.getX(),
|
||||||
@ -1367,15 +1425,46 @@ public class Plot {
|
|||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
if (!WorldUtil.IMP.getBlock(location).getBlockType().getMaterial().isAir()) {
|
if (!WorldUtil.IMP.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
||||||
location.setY(Math.max(1 + WorldUtil.IMP
|
location.setY(Math.max(1 + WorldUtil.IMP
|
||||||
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ()),
|
.getHighestBlockSynchronous(this.getWorldName(), location.getX(), location.getZ()),
|
||||||
bottom.getY()));
|
bottom.getY()));
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the home location for the plot
|
||||||
|
*/
|
||||||
|
public void getHome(final Consumer<Location> result) {
|
||||||
|
BlockLoc home = this.getPosition();
|
||||||
|
if (home == null || home.getX() == 0 && home.getZ() == 0) {
|
||||||
|
this.getDefaultHome(result);
|
||||||
|
} else {
|
||||||
|
Location bottom = this.getBottomAbs();
|
||||||
|
Location location = new Location(bottom.getWorld(), bottom.getX() + home.getX(),
|
||||||
|
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
|
||||||
|
home.getPitch());
|
||||||
|
if (!isLoaded()) {
|
||||||
|
result.accept(location);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WorldUtil.IMP.getBlock(location, block -> {
|
||||||
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
|
WorldUtil.IMP
|
||||||
|
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(), y -> {
|
||||||
|
location.setY(Math.max(1 + y,
|
||||||
|
bottom.getY()));
|
||||||
|
result.accept(location);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
result.accept(location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the home location
|
* Sets the home location
|
||||||
*
|
*
|
||||||
@ -1400,11 +1489,15 @@ public class Plot {
|
|||||||
*
|
*
|
||||||
* @return Location
|
* @return Location
|
||||||
*/
|
*/
|
||||||
public Location getDefaultHome() {
|
public void getDefaultHome(Consumer<Location> result) {
|
||||||
return getDefaultHome(false);
|
getDefaultHome(false, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getDefaultHome(boolean member) {
|
/**
|
||||||
|
* @deprecated May cause synchronous chunk loads
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Location getDefaultHomeSynchronous(final boolean member) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
@ -1424,12 +1517,47 @@ public class Plot {
|
|||||||
z = bot.getZ() + loc.getZ();
|
z = bot.getZ() + loc.getZ();
|
||||||
}
|
}
|
||||||
int y = loc.getY() < 1 ?
|
int y = loc.getY() < 1 ?
|
||||||
(isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) + 1 : 63) :
|
(isLoaded() ? WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 : 63) :
|
||||||
loc.getY();
|
loc.getY();
|
||||||
return new Location(plot.getWorldName(), x, y, z);
|
return new Location(plot.getWorldName(), x, y, z);
|
||||||
}
|
}
|
||||||
// Side
|
// Side
|
||||||
return plot.getSide();
|
return plot.getSideSynchronous();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getDefaultHome(boolean member, Consumer<Location> result) {
|
||||||
|
Plot plot = this.getBasePlot(false);
|
||||||
|
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
||||||
|
if (loc != null) {
|
||||||
|
int x;
|
||||||
|
int z;
|
||||||
|
if (loc.getX() == Integer.MAX_VALUE && loc.getZ() == Integer.MAX_VALUE) {
|
||||||
|
// center
|
||||||
|
CuboidRegion largest = plot.getLargestRegion();
|
||||||
|
x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX()
|
||||||
|
>> 1) + largest.getMinimumPoint().getX();
|
||||||
|
z = (largest.getMaximumPoint().getZ() >> 1) - (largest.getMinimumPoint().getZ()
|
||||||
|
>> 1) + largest.getMinimumPoint().getZ();
|
||||||
|
} else {
|
||||||
|
// specific
|
||||||
|
Location bot = plot.getBottomAbs();
|
||||||
|
x = bot.getX() + loc.getX();
|
||||||
|
z = bot.getZ() + loc.getZ();
|
||||||
|
}
|
||||||
|
if (loc.getY() < 1) {
|
||||||
|
if (isLoaded()) {
|
||||||
|
WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z, y ->
|
||||||
|
result.accept(new Location(plot.getWorldName(), x, y + 1, z)));
|
||||||
|
} else {
|
||||||
|
result.accept(new Location(plot.getWorldName(), x, 63, z));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.accept(new Location(plot.getWorldName(), x, loc.getY(), z));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Side
|
||||||
|
plot.getSide(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getVolume() {
|
public double getVolume() {
|
||||||
@ -1599,7 +1727,7 @@ public class Plot {
|
|||||||
setSign(player.getName());
|
setSign(player.getName());
|
||||||
MainUtil.sendMessage(player, Captions.CLAIMED);
|
MainUtil.sendMessage(player, Captions.CLAIMED);
|
||||||
if (teleport && Settings.Teleport.ON_CLAIM) {
|
if (teleport && Settings.Teleport.ON_CLAIM) {
|
||||||
teleportPlayer(player, TeleportCause.COMMAND);
|
teleportPlayer(player, TeleportCause.COMMAND, result -> {});
|
||||||
}
|
}
|
||||||
PlotArea plotworld = getArea();
|
PlotArea plotworld = getArea();
|
||||||
if (plotworld.isSchematicOnClaim()) {
|
if (plotworld.isSchematicOnClaim()) {
|
||||||
@ -1696,9 +1824,18 @@ public class Plot {
|
|||||||
*
|
*
|
||||||
* @return the name of the biome
|
* @return the name of the biome
|
||||||
*/
|
*/
|
||||||
public BiomeType getBiome() {
|
public void getBiome(Consumer<BiomeType> result) {
|
||||||
Location location = this.getCenter();
|
this.getCenter(location ->
|
||||||
return WorldUtil.IMP.getBiome(location.getWorld(), location.getX(), location.getZ());
|
WorldUtil.IMP.getBiome(location.getWorld(), location.getX(), location.getZ(), result));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated May cause synchronous chunk loads
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public BiomeType getBiomeSynchronous() {
|
||||||
|
final Location location = this.getCenterSynchronous();
|
||||||
|
return WorldUtil.IMP.getBiomeSynchronous(location.getWorld(), location.getX(), location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
@ -2190,9 +2327,6 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* Gets the set home location or 0,0,0 if no location is set<br>
|
* Gets the set home location or 0,0,0 if no location is set<br>
|
||||||
* - Does not take the default home location into account
|
* - Does not take the default home location into account
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @see #getHome()
|
|
||||||
*/
|
*/
|
||||||
public BlockLoc getPosition() {
|
public BlockLoc getPosition() {
|
||||||
return this.getSettings().getPosition();
|
return this.getSettings().getPosition();
|
||||||
@ -2234,7 +2368,7 @@ public class Plot {
|
|||||||
@Override public void run(String[] value) {
|
@Override public void run(String[] value) {
|
||||||
ChunkManager.manager
|
ChunkManager.manager
|
||||||
.loadChunk(location.getWorld(), location.getBlockVector2(), false);
|
.loadChunk(location.getWorld(), location.getBlockVector2(), false);
|
||||||
this.value = WorldUtil.IMP.getSign(location);
|
this.value = WorldUtil.IMP.getSignSynchronous(location);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (lines == null) {
|
if (lines == null) {
|
||||||
@ -2855,8 +2989,8 @@ public class Plot {
|
|||||||
* @param player the player
|
* @param player the player
|
||||||
* @return if the teleport succeeded
|
* @return if the teleport succeeded
|
||||||
*/
|
*/
|
||||||
public boolean teleportPlayer(final PlotPlayer player) {
|
public void teleportPlayer(final PlotPlayer player, Consumer<Boolean> result) {
|
||||||
return teleportPlayer(player, TeleportCause.PLUGIN);
|
teleportPlayer(player, TeleportCause.PLUGIN, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2866,25 +3000,21 @@ public class Plot {
|
|||||||
* @param cause the cause of the teleport
|
* @param cause the cause of the teleport
|
||||||
* @return if the teleport succeeded
|
* @return if the teleport succeeded
|
||||||
*/
|
*/
|
||||||
public boolean teleportPlayer(final PlotPlayer player, TeleportCause cause) {
|
public void teleportPlayer(final PlotPlayer player, TeleportCause cause, Consumer<Boolean> resultConsumer) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
Result result =
|
Result result =
|
||||||
PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot).getEventResult();
|
PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot).getEventResult();
|
||||||
if (result == Result.DENY) {
|
if (result == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
||||||
return false;
|
resultConsumer.accept(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
final Location location;
|
final Consumer<Location> locationConsumer = location -> {
|
||||||
if (this.area.isHomeAllowNonmember() || plot.isAdded(player.getUUID())) {
|
if (Settings.Teleport.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||||
location = this.getHome();
|
|
||||||
} else {
|
|
||||||
location = this.getDefaultHome(false);
|
|
||||||
}
|
|
||||||
if (Settings.Teleport.DELAY == 0 || Permissions
|
|
||||||
.hasPermission(player, "plots.teleport.delay.bypass")) {
|
|
||||||
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
|
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
|
||||||
player.teleport(location, cause);
|
player.teleport(location, cause);
|
||||||
return true;
|
resultConsumer.accept(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
MainUtil.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
@ -2900,7 +3030,13 @@ public class Plot {
|
|||||||
player.teleport(location, cause);
|
player.teleport(location, cause);
|
||||||
}
|
}
|
||||||
}, Settings.Teleport.DELAY * 20);
|
}, Settings.Teleport.DELAY * 20);
|
||||||
return true;
|
resultConsumer.accept(true);
|
||||||
|
};
|
||||||
|
if (this.area.isHomeAllowNonmember() || plot.isAdded(player.getUUID())) {
|
||||||
|
this.getHome(locationConsumer);
|
||||||
|
} else {
|
||||||
|
this.getDefaultHome(false, locationConsumer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,6 +7,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class PlotCluster {
|
public class PlotCluster {
|
||||||
public PlotArea area;
|
public PlotArea area;
|
||||||
@ -86,8 +87,6 @@ public class PlotCluster {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the area (in plots).
|
* Get the area (in plots).
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public int getArea() {
|
public int getArea() {
|
||||||
return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y);
|
return (1 + this.pos2.x - this.pos1.x) * (1 + this.pos2.y - this.pos1.y);
|
||||||
@ -125,26 +124,31 @@ public class PlotCluster {
|
|||||||
+ this.pos2.y;
|
+ this.pos2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getHome() {
|
public void getHome(Consumer<Location> result) {
|
||||||
BlockLoc home = this.settings.getPosition();
|
BlockLoc home = this.settings.getPosition();
|
||||||
Location toReturn;
|
Consumer<Location> locationConsumer = toReturn -> {
|
||||||
if (home.getY() == 0) {
|
MainUtil.getHeighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ(), max -> {
|
||||||
// default pos
|
|
||||||
Plot center = getCenterPlot();
|
|
||||||
toReturn = center.getHome();
|
|
||||||
if (toReturn.getY() == 0) {
|
|
||||||
PlotManager manager = this.area.getPlotManager();
|
|
||||||
Location location = manager.getSignLoc(center);
|
|
||||||
toReturn.setY(location.getY());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
toReturn = getClusterBottom().add(home.getX(), home.getY(), home.getZ());
|
|
||||||
}
|
|
||||||
int max = MainUtil.getHeighestBlock(this.area.getWorldName(), toReturn.getX(), toReturn.getZ());
|
|
||||||
if (max > toReturn.getY()) {
|
if (max > toReturn.getY()) {
|
||||||
toReturn.setY(1 + max);
|
toReturn.setY(1 + max);
|
||||||
}
|
}
|
||||||
return toReturn;
|
result.accept(toReturn);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if (home.getY() == 0) {
|
||||||
|
// default pos
|
||||||
|
Plot center = getCenterPlot();
|
||||||
|
center.getHome(location -> {
|
||||||
|
Location toReturn = location;
|
||||||
|
if (toReturn.getY() == 0) {
|
||||||
|
PlotManager manager = this.area.getPlotManager();
|
||||||
|
Location locationSign = manager.getSignLoc(center);
|
||||||
|
toReturn.setY(locationSign.getY());
|
||||||
|
}
|
||||||
|
locationConsumer.accept(toReturn);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
locationConsumer.accept(getClusterBottom().add(home.getX(), home.getY(), home.getZ()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotId getCenterPlotId() {
|
public PlotId getCenterPlotId() {
|
||||||
|
@ -628,8 +628,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
});
|
});
|
||||||
} else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
} else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||||
if (getMeta("teleportOnLogin", true)) {
|
if (getMeta("teleportOnLogin", true)) {
|
||||||
if (plot.teleportPlayer(PlotPlayer.this)) {
|
plot.teleportPlayer(PlotPlayer.this, result -> TaskManager.runTask(() -> {
|
||||||
TaskManager.runTask(() -> {
|
|
||||||
if (getMeta("teleportOnLogin", true)) {
|
if (getMeta("teleportOnLogin", true)) {
|
||||||
if (plot.isLoaded()) {
|
if (plot.isLoaded()) {
|
||||||
teleport(location);
|
teleport(location);
|
||||||
@ -639,8 +638,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
+ ")");
|
+ ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
|
import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -18,6 +15,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class SinglePlot extends Plot {
|
public class SinglePlot extends Plot {
|
||||||
private Set<CuboidRegion> regions = Collections.singleton(
|
private Set<CuboidRegion> regions = Collections.singleton(
|
||||||
@ -51,17 +49,8 @@ public class SinglePlot extends Plot {
|
|||||||
return (SinglePlotArea) super.getArea();
|
return (SinglePlotArea) super.getArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean teleportPlayer(final PlotPlayer player, TeleportCause cause) {
|
@Override public void getSide(Consumer<Location> result) {
|
||||||
if (isLoaded()) {
|
getCenter(result);
|
||||||
return super.teleportPlayer(player, cause);
|
|
||||||
} else {
|
|
||||||
Captions.NOT_LOADED.send(player);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public Location getSide() {
|
|
||||||
return getCenter();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected boolean isLoaded() {
|
@Override protected boolean isLoaded() {
|
||||||
|
@ -185,7 +185,7 @@ public class EventDispatcher {
|
|||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
if (Settings.Teleport.ON_LOGIN && plot != null && !(plot
|
if (Settings.Teleport.ON_LOGIN && plot != null && !(plot
|
||||||
.getArea() instanceof SinglePlotArea)) {
|
.getArea() instanceof SinglePlotArea)) {
|
||||||
TaskManager.runTask(() -> plot.teleportPlayer(player));
|
TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {}));
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
|
CaptionUtility.format(player, Captions.TELEPORTED_TO_ROAD.getTranslated())
|
||||||
+ " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")");
|
+ " (on-login) " + "(" + plot.getId().x + ";" + plot.getId().y + ")");
|
||||||
@ -195,7 +195,7 @@ public class EventDispatcher {
|
|||||||
public void doRespawnTask(final PlotPlayer player) {
|
public void doRespawnTask(final PlotPlayer player) {
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
if (Settings.Teleport.ON_DEATH && plot != null) {
|
if (Settings.Teleport.ON_DEATH && plot != null) {
|
||||||
TaskManager.runTask(() -> plot.teleportPlayer(player));
|
TaskManager.runTask(() -> plot.teleportPlayer(player, result -> {}));
|
||||||
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_ROAD);
|
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_ROAD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -232,7 +233,7 @@ public class MainUtil {
|
|||||||
*/
|
*/
|
||||||
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
|
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
|
||||||
BiomeType biome = area.getPlotBiome();
|
BiomeType biome = area.getPlotBiome();
|
||||||
if (!Objects.equals(WorldUtil.IMP.getBiome(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
|
if (!Objects.equals(WorldUtil.IMP.getBiomeSynchronous(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
|
||||||
(pos1.getZ() + pos2.getZ()) / 2), biome)) {
|
(pos1.getZ() + pos2.getZ()) / 2), biome)) {
|
||||||
MainUtil.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
|
MainUtil.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
|
||||||
biome);
|
biome);
|
||||||
@ -589,18 +590,15 @@ public class MainUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the highest block at a location.
|
* Get the highest block at a location.
|
||||||
*
|
|
||||||
* @param world
|
|
||||||
* @param x
|
|
||||||
* @param z
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static int getHeighestBlock(String world, int x, int z) {
|
public static void getHeighestBlock(String world, int x, int z, Consumer<Integer> result) {
|
||||||
int result = WorldUtil.IMP.getHighestBlock(world, x, z);
|
WorldUtil.IMP.getHighestBlock(world, x, z, highest -> {
|
||||||
if (result == 0) {
|
if (highest == 0) {
|
||||||
return 63;
|
result.accept(63);
|
||||||
|
} else {
|
||||||
|
result.accept(highest);
|
||||||
}
|
}
|
||||||
return result;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -752,18 +750,19 @@ public class MainUtil {
|
|||||||
/**
|
/**
|
||||||
* Format a string with plot information.
|
* Format a string with plot information.
|
||||||
*
|
*
|
||||||
* @param info
|
* @param iInfo
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
* @param full
|
* @param full
|
||||||
* @param whenDone
|
* @param whenDone
|
||||||
*/
|
*/
|
||||||
public static void format(String info, final Plot plot, PlotPlayer player, final boolean full,
|
public static void format(final String iInfo, final Plot plot, PlotPlayer player, final boolean full,
|
||||||
final RunnableVal<String> whenDone) {
|
final RunnableVal<String> whenDone) {
|
||||||
int num = plot.getConnectedPlots().size();
|
int num = plot.getConnectedPlots().size();
|
||||||
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
|
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
|
||||||
Location bot = plot.getCorners()[0];
|
Location bot = plot.getCorners()[0];
|
||||||
BiomeType biome = WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ());
|
WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ(), biome -> {
|
||||||
|
String info = iInfo;
|
||||||
String trusted = getPlayerList(plot.getTrusted());
|
String trusted = getPlayerList(plot.getTrusted());
|
||||||
String members = getPlayerList(plot.getMembers());
|
String members = getPlayerList(plot.getMembers());
|
||||||
String denied = getPlayerList(plot.getDenied());
|
String denied = getPlayerList(plot.getDenied());
|
||||||
@ -862,6 +861,7 @@ public class MainUtil {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
whenDone.run(info);
|
whenDone.run(info);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deleteDirectory(File directory) {
|
public static boolean deleteDirectory(File directory) {
|
||||||
|
@ -178,8 +178,7 @@ public abstract class SchematicHandler {
|
|||||||
if (pw instanceof ClassicPlotWorld) {
|
if (pw instanceof ClassicPlotWorld) {
|
||||||
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
||||||
} else {
|
} else {
|
||||||
y_offset_actual = yOffset + 1 + MainUtil
|
y_offset_actual = yOffset + 1 + WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(),
|
||||||
.getHeighestBlock(plot.getWorldName(),
|
|
||||||
region.getMinimumPoint().getX() + 1,
|
region.getMinimumPoint().getX() + 1,
|
||||||
region.getMinimumPoint().getZ() + 1);
|
region.getMinimumPoint().getZ() + 1);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.IntTag;
|
import com.sk89q.jnbt.IntTag;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
@ -15,6 +14,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
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 com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -25,11 +25,11 @@ import java.net.URL;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public abstract class WorldUtil {
|
public abstract class WorldUtil {
|
||||||
public static WorldUtil IMP;
|
public static WorldUtil IMP;
|
||||||
@ -38,7 +38,13 @@ public abstract class WorldUtil {
|
|||||||
|
|
||||||
public abstract boolean isWorld(String worldName);
|
public abstract boolean isWorld(String worldName);
|
||||||
|
|
||||||
public abstract String[] getSign(Location location);
|
public abstract void getSign(Location location, Consumer<String[]> result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated May result in synchronous chunk loading
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract String[] getSignSynchronous(Location location);
|
||||||
|
|
||||||
public abstract Location getSpawn(String world);
|
public abstract Location getSpawn(String world);
|
||||||
|
|
||||||
@ -52,13 +58,29 @@ public abstract class WorldUtil {
|
|||||||
|
|
||||||
public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(String name);
|
public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(String name);
|
||||||
|
|
||||||
public abstract BiomeType getBiome(String world, int x, int z);
|
public abstract void getBiome(String world, int x, int z, Consumer<BiomeType> result);
|
||||||
|
|
||||||
public abstract BlockState getBlock(Location location);
|
/**
|
||||||
|
* @deprecated May result in synchronous chunk loading
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract BiomeType getBiomeSynchronous(String world, int x, int z);
|
||||||
|
|
||||||
public abstract int getHighestBlock(String world, int x, int z);
|
public abstract void getBlock(Location location, Consumer<BlockState> result);
|
||||||
|
|
||||||
public abstract boolean addItems(String world, PlotItem item);
|
/**
|
||||||
|
* @deprecated May result in synchronous chunk loading
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract BlockState getBlockSynchronous(Location location);
|
||||||
|
|
||||||
|
public abstract void getHighestBlock(String world, int x, int z, final Consumer<Integer> result);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated May result in synchronous chunk loading
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public abstract int getHighestBlockSynchronous(String world, int x, int z);
|
||||||
|
|
||||||
public abstract void setSign(String world, int x, int y, int z, String[] lines);
|
public abstract void setSign(String world, int x, int y, int z, String[] lines);
|
||||||
|
|
||||||
@ -67,8 +89,7 @@ public abstract class WorldUtil {
|
|||||||
public abstract com.sk89q.worldedit.world.World getWeWorld(String world);
|
public abstract com.sk89q.worldedit.world.World getWeWorld(String world);
|
||||||
|
|
||||||
public void upload(@NotNull final Plot plot, UUID uuid, String file, RunnableVal<URL> whenDone) {
|
public void upload(@NotNull final Plot plot, UUID uuid, String file, RunnableVal<URL> whenDone) {
|
||||||
final Location home = plot.getHome();
|
plot.getHome(home -> MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
||||||
MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
|
||||||
@Override public void run(OutputStream output) {
|
@Override public void run(OutputStream output) {
|
||||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||||
File dat = getDat(plot.getWorldName());
|
File dat = getDat(plot.getWorldName());
|
||||||
@ -135,7 +156,7 @@ public abstract class WorldUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, whenDone);
|
}, whenDone));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDat(String world) {
|
public File getDat(String world) {
|
||||||
|
@ -13,9 +13,9 @@ import com.sk89q.worldedit.math.BlockVector2;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public abstract class LocalBlockQueue {
|
public abstract class LocalBlockQueue {
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public abstract class LocalBlockQueue {
|
|||||||
.equals(loc)) {
|
.equals(loc)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pLoc.setY(WorldUtil.IMP.getHighestBlock(getWorld(), pLoc.getX(), pLoc.getZ()));
|
pLoc.setY(WorldUtil.IMP.getHighestBlockSynchronous(getWorld(), pLoc.getX(), pLoc.getZ()));
|
||||||
pp.teleport(pLoc);
|
pp.teleport(pLoc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class ExpireManager {
|
|||||||
if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) {
|
if (!isExpired(new ArrayDeque<>(tasks), current).isEmpty()) {
|
||||||
TaskManager.runTask(() -> {
|
TaskManager.runTask(() -> {
|
||||||
pp.setMeta("ignoreExpireTask", true);
|
pp.setMeta("ignoreExpireTask", true);
|
||||||
pp.teleport(current.getCenter());
|
current.getCenter(pp::teleport);
|
||||||
pp.deleteMeta("ignoreExpireTask");
|
pp.deleteMeta("ignoreExpireTask");
|
||||||
PlotMessage msg = new PlotMessage()
|
PlotMessage msg = new PlotMessage()
|
||||||
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired: ")
|
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired: ")
|
||||||
|
Loading…
Reference in New Issue
Block a user