More piston fixes, potential chunk send fix, home teleport fix

This commit is contained in:
boy0001 2015-03-17 19:17:15 +11:00
parent 271cc026d4
commit 20d64508a5
6 changed files with 30 additions and 12 deletions

View File

@ -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);

View File

@ -95,18 +95,33 @@ 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) {

View File

@ -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();

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}