mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
fixed some really weird bugs...
like WTF, how does checking event.getTo() cause the player spawns to change!?
This commit is contained in:
parent
3796f41be3
commit
a79a3adcba
@ -770,23 +770,38 @@ public class PlotHelper {
|
||||
PlotMain.updatePlot(plot);
|
||||
refreshPlotChunks(world, plot);
|
||||
}
|
||||
public static int getHeighestBlock(World world, int x, int z) {
|
||||
boolean safe = false;
|
||||
for (int i = 1; i<world.getMaxHeight(); i++) {
|
||||
int id = world.getBlockAt(x,i,z).getTypeId();
|
||||
if (id==0) {
|
||||
if (safe) {
|
||||
return i-1;
|
||||
}
|
||||
safe = true;
|
||||
}
|
||||
}
|
||||
return 64;
|
||||
}
|
||||
|
||||
public static Location getPlotHome(World w, PlotId plotid) {
|
||||
Location
|
||||
bot = getPlotBottomLoc(w, plotid),
|
||||
top = getPlotTopLoc(w, plotid);
|
||||
|
||||
if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) {
|
||||
int x = bot.getBlockX() + (top.getBlockX() - bot.getBlockX());
|
||||
|
||||
Location bot = getPlotBottomLoc(w, plotid);
|
||||
|
||||
int x = bot.getBlockX();
|
||||
int z = bot.getBlockZ() - 2;
|
||||
int y = w.getHighestBlockYAt(x, z);
|
||||
int y = getHeighestBlock(w, x, z);
|
||||
return new Location(w, x, y, z);
|
||||
}
|
||||
else {
|
||||
|
||||
Location
|
||||
bot = getPlotBottomLoc(w, plotid),
|
||||
top = getPlotTopLoc(w, plotid);
|
||||
int x = top.getBlockX() - bot.getBlockX();
|
||||
int z = top.getBlockZ() - bot.getBlockZ();
|
||||
int y = w.getHighestBlockYAt(x, z);
|
||||
int y = getHeighestBlock(w, x, z);
|
||||
return new Location(w, bot.getBlockX() + x/2, y, bot.getBlockZ() + z/2);
|
||||
}
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ public class PlayerEvents implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void MobSpawn(CreatureSpawnEvent event) {
|
||||
World world = event.getLocation().getWorld();
|
||||
if (!isPlotWorld(world)) {
|
||||
@ -589,9 +589,10 @@ public class PlayerEvents implements Listener {
|
||||
} else if (reason == CreatureSpawnEvent.SpawnReason.CUSTOM && pW.SPAWN_CUSTOM) {
|
||||
return;
|
||||
}
|
||||
if (event.getEntity().getType() == EntityType.PLAYER) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
return;
|
||||
}
|
||||
System.out.print(event.getEntityType().getName());
|
||||
if (!isInPlot(event.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -634,15 +635,15 @@ public class PlayerEvents implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(
|
||||
priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
|
||||
Location f = event.getFrom();
|
||||
Location t = event.getTo();
|
||||
Location q = new Location(t.getWorld(),t.getBlockX(), 64, t.getZ());
|
||||
|
||||
if (isPlotWorld(event.getTo())) {
|
||||
if (isInPlot(event.getTo())) {
|
||||
|
||||
if (isPlotWorld(q)) {
|
||||
if (isInPlot(q)) {
|
||||
Plot plot = getCurrentPlot(event.getTo());
|
||||
if (plot.deny_entry(event.getPlayer())) {
|
||||
PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED);
|
||||
|
@ -148,8 +148,7 @@ public class WorldEditListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(
|
||||
priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onTeleport(final PlayerTeleportEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user