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.ChunkLoadEvent;
import org.bukkit.event.world.StructureGrowEvent; import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
@ -522,8 +523,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
Plot plot = MainUtil.getPlot(loc); Plot plot = MainUtil.getPlot(loc);
if (plot != null) { if (plot != null) {
BlockFace face = event.getDirection();
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
for (final Block b : event.getBlocks()) { 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); Plot newPlot = MainUtil.getPlot(bloc);
if (!plot.equals(newPlot)) { if (!plot.equals(newPlot)) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -95,18 +95,33 @@ public class MainUtil {
} }
return count; 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) { public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
final Plot bot = MainUtil.getBottomPlot(plot); final Plot bot = MainUtil.getBottomPlot(plot);
// TODO // TODO
// boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot); // boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot);
boolean result = EventUtil.manager.callTeleport(player, from, plot);
final boolean result = false;
// TOOD ^ remove that // TOOD ^ remove that
if (!result) { if (result) {
final Location location = MainUtil.getPlotHome(bot.world, bot); 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")) { if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
sendMessage(player, C.TELEPORTED_TO_PLOT); sendMessage(player, C.TELEPORTED_TO_PLOT);
player.teleport(location); player.teleport(location);
@ -132,7 +147,7 @@ public class MainUtil {
}, Settings.TELEPORT_DELAY * 20); }, Settings.TELEPORT_DELAY * 20);
return true; return true;
} }
return !result; return result;
} }
public static int getBorder(final String worldname) { public static int getBorder(final String worldname) {

View File

@ -765,7 +765,7 @@ public class BukkitChunkManager extends ChunkManager {
if (plot.id.equals(id)) { if (plot.id.equals(id)) {
if (entity instanceof Player) { if (entity instanceof Player) {
final Player player = (Player) entity; 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); PlotListener.plotExit(player, plot);
} else { } else {
entity.remove(); 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) { public static void refreshChunk(final String name, final int x, final int z) {
World world = getWorld(name); World world = getWorld(name);
world.unloadChunk(x, z); world.refreshChunk(x, z);
world.loadChunk(x, z); world.loadChunk(x, z);
} }

View File

@ -90,8 +90,8 @@ public class SetBlockFast extends BukkitSetBlockManager {
if (!MainUtil.canSendChunk) { if (!MainUtil.canSendChunk) {
final World world = chunks.get(0).getWorld(); final World world = chunks.get(0).getWorld();
for (final Chunk chunk : chunks) { for (final Chunk chunk : chunks) {
world.unloadChunk(chunk); world.refreshChunk(chunk.getX(), chunk.getZ());
world.loadChunk(chunk); chunk.load(false);
} }
return; return;
} }

View File

@ -294,8 +294,8 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager {
if (!MainUtil.canSendChunk) { if (!MainUtil.canSendChunk) {
final World world = chunks.get(0).getWorld(); final World world = chunks.get(0).getWorld();
for (final Chunk chunk : chunks) { for (final Chunk chunk : chunks) {
world.unloadChunk(chunk); world.refreshChunk(chunk.getX(), chunk.getZ());
world.loadChunk(chunk); chunk.load(false);
} }
return; return;
} }