mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-30 00:56:45 +01:00
Try and teleport players above plot after clearing
This commit is contained in:
parent
3aa7a74626
commit
5b56b6786e
@ -37,6 +37,8 @@ public abstract class ChunkManager {
|
|||||||
|
|
||||||
public abstract List<ChunkLoc> getChunkChunks(String world);
|
public abstract List<ChunkLoc> getChunkChunks(String world);
|
||||||
|
|
||||||
|
public abstract void regenerateChunk(String world, ChunkLoc loc);
|
||||||
|
|
||||||
public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
|
public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
|
||||||
|
|
||||||
public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks);
|
public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks);
|
||||||
|
@ -286,8 +286,9 @@ public class ClusterManager {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if ((populator == null) || (plotworld.TYPE == 0)) {
|
if ((populator == null) || (plotworld.TYPE == 0)) {
|
||||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
ChunkLoc loc = new ChunkLoc(chunk.getX(), chunk.getZ());
|
||||||
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
ChunkManager.manager.regenerateChunk(world.getName(), loc);
|
||||||
|
MainUtil.update(world.getName(), loc);
|
||||||
} else {
|
} else {
|
||||||
populator.populate(world, rand, chunk);
|
populator.populate(world, rand, chunk);
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ public class MainUtil {
|
|||||||
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
||||||
}
|
}
|
||||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||||
return new Location(plot.world, x, y, z);
|
return new Location(plot.world, x, y + 1, z);
|
||||||
}
|
}
|
||||||
final Location top = getPlotTopLoc(plot.world, plot.id);
|
final Location top = getPlotTopLoc(plot.world, plot.id);
|
||||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||||
@ -280,7 +280,7 @@ public class MainUtil {
|
|||||||
final int z = bot.getZ();
|
final int z = bot.getZ();
|
||||||
PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||||
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||||
return new Location(plot.world, x, y, z);
|
return new Location(plot.world, x, y + 1, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
|
public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
|
||||||
|
@ -94,6 +94,22 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void regenerateChunk(String world, ChunkLoc loc) {
|
||||||
|
World worldObj = Bukkit.getWorld(world);
|
||||||
|
worldObj.regenerateChunk(loc.x, loc.z);
|
||||||
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
Location playerLoc = BukkitUtil.getLocation(player.getLocation());
|
||||||
|
if (playerLoc.getX() >> 4 == loc.x && playerLoc.getZ() >> 4 == loc.z) {
|
||||||
|
final Plot plot = MainUtil.getPlot(playerLoc);
|
||||||
|
if (plot != null) {
|
||||||
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
|
pp.teleport(MainUtil.getDefaultHome(plot));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteRegionFile(final String world, final ChunkLoc loc) {
|
public void deleteRegionFile(final String world, final ChunkLoc loc) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@ -360,12 +376,13 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (save) {
|
if (save) {
|
||||||
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
||||||
}
|
}
|
||||||
world.regenerateChunk(x, z);
|
ChunkLoc loc = new ChunkLoc(chunk.getX(), chunk.getZ());
|
||||||
|
regenerateChunk(world.getName(), loc);
|
||||||
if (save) {
|
if (save) {
|
||||||
restoreBlocks(world, 0, 0);
|
restoreBlocks(world, 0, 0);
|
||||||
restoreEntities(world, 0, 0);
|
restoreEntities(world, 0, 0);
|
||||||
}
|
}
|
||||||
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
MainUtil.update(world.getName(), loc);
|
||||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||||
}
|
}
|
||||||
CURRENT_PLOT_CLEAR = null;
|
CURRENT_PLOT_CLEAR = null;
|
||||||
@ -1092,12 +1109,13 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (save) {
|
if (save) {
|
||||||
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
saveEntitiesOut(chunk, CURRENT_PLOT_CLEAR);
|
||||||
}
|
}
|
||||||
world.regenerateChunk(cx, cz);
|
ChunkLoc chunkLoc = new ChunkLoc(chunk.getX(), chunk.getZ());
|
||||||
|
regenerateChunk(world.getName(), chunkLoc);
|
||||||
if (save) {
|
if (save) {
|
||||||
restoreBlocks(world, 0, 0);
|
restoreBlocks(world, 0, 0);
|
||||||
restoreEntities(world, 0, 0);
|
restoreEntities(world, 0, 0);
|
||||||
}
|
}
|
||||||
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
MainUtil.update(world.getName(), chunkLoc);
|
||||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||||
CURRENT_PLOT_CLEAR = null;
|
CURRENT_PLOT_CLEAR = null;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,13 @@ import org.bukkit.inventory.InventoryHolder;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
|
||||||
public class BukkitUtil extends BlockManager {
|
public class BukkitUtil extends BlockManager {
|
||||||
private static HashMap<String, World> worlds = new HashMap<>();
|
private static HashMap<String, World> worlds = new HashMap<>();
|
||||||
@ -157,7 +159,7 @@ public class BukkitUtil extends BlockManager {
|
|||||||
World worldObj = getWorld(world);
|
World worldObj = getWorld(world);
|
||||||
Chunk chunk = worldObj.getChunkAt(x, z);
|
Chunk chunk = worldObj.getChunkAt(x, z);
|
||||||
if (chunk.isLoaded() || chunk.load(false)) {
|
if (chunk.isLoaded() || chunk.load(false)) {
|
||||||
worldObj.regenerateChunk(x, z);
|
ChunkManager.manager.regenerateChunk(world, new ChunkLoc(x, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user