mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-08 09:54:04 +01:00
More piston fixes, potential chunk send fix, home teleport fix
This commit is contained in:
parent
271cc026d4
commit
20d64508a5
@ -62,6 +62,7 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -522,8 +523,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot != null) {
|
||||
BlockFace face = event.getDirection();
|
||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||
for (final Block b : event.getBlocks()) {
|
||||
Location bloc = BukkitUtil.getLocation(b.getLocation());
|
||||
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
||||
Plot newPlot = MainUtil.getPlot(bloc);
|
||||
if (!plot.equals(newPlot)) {
|
||||
event.setCancelled(true);
|
||||
|
@ -96,17 +96,32 @@ public class MainUtil {
|
||||
return count;
|
||||
}
|
||||
|
||||
public static Location getPlotFront(Plot plot) {
|
||||
final Location top = getPlotTopLoc(plot.world, plot.id);
|
||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
||||
final int z = 0;
|
||||
PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
|
||||
final Plot bot = MainUtil.getBottomPlot(plot);
|
||||
|
||||
// TODO
|
||||
// boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot);
|
||||
|
||||
final boolean result = false;
|
||||
boolean result = EventUtil.manager.callTeleport(player, from, plot);
|
||||
// TOOD ^ remove that
|
||||
|
||||
if (!result) {
|
||||
final Location location = MainUtil.getPlotHome(bot.world, bot);
|
||||
if (result) {
|
||||
final Location location;
|
||||
if (plot.isAdded(player.getUUID())) {
|
||||
location = MainUtil.getPlotHome(bot.world, bot);
|
||||
}
|
||||
else {
|
||||
location = getPlotFront(plot);
|
||||
}
|
||||
if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location);
|
||||
@ -132,7 +147,7 @@ public class MainUtil {
|
||||
}, Settings.TELEPORT_DELAY * 20);
|
||||
return true;
|
||||
}
|
||||
return !result;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int getBorder(final String worldname) {
|
||||
|
@ -765,7 +765,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
if (plot.id.equals(id)) {
|
||||
if (entity instanceof Player) {
|
||||
final Player player = (Player) entity;
|
||||
MainUtil.teleportPlayer(BukkitUtil.getPlayer(player), BukkitUtil.getLocation(entity), plot);
|
||||
BukkitUtil.getPlayer(player).teleport(MainUtil.getPlotFront(plot));
|
||||
PlotListener.plotExit(player, plot);
|
||||
} else {
|
||||
entity.remove();
|
||||
|
@ -147,7 +147,7 @@ public class BukkitUtil extends BlockManager {
|
||||
|
||||
public static void refreshChunk(final String name, final int x, final int z) {
|
||||
World world = getWorld(name);
|
||||
world.unloadChunk(x, z);
|
||||
world.refreshChunk(x, z);
|
||||
world.loadChunk(x, z);
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ public class SetBlockFast extends BukkitSetBlockManager {
|
||||
if (!MainUtil.canSendChunk) {
|
||||
final World world = chunks.get(0).getWorld();
|
||||
for (final Chunk chunk : chunks) {
|
||||
world.unloadChunk(chunk);
|
||||
world.loadChunk(chunk);
|
||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.load(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -294,8 +294,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
|
||||
if (!MainUtil.canSendChunk) {
|
||||
final World world = chunks.get(0).getWorld();
|
||||
for (final Chunk chunk : chunks) {
|
||||
world.unloadChunk(chunk);
|
||||
world.loadChunk(chunk);
|
||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.load(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user