mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixed piston from unowned
This commit is contained in:
parent
41bb2c0284
commit
5c6bc8b1ba
@ -665,36 +665,34 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = MainUtil.getPlot(loc);
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
if (plot != null) {
|
BlockFace face = event.getDirection();
|
||||||
BlockFace face = event.getDirection();
|
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
List<Block> blocks = event.getBlocks();
|
||||||
List<Block> blocks = event.getBlocks();
|
for (final Block b : blocks) {
|
||||||
for (final Block b : blocks) {
|
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
||||||
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
Plot newPlot = MainUtil.getPlot(bloc);
|
||||||
Plot newPlot = MainUtil.getPlot(bloc);
|
if (MainUtil.equals(plot, newPlot)) {
|
||||||
if (!plot.equals(newPlot)) {
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Settings.PISTON_FALLING_BLOCK_CHECK) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
org.bukkit.Location lastLoc;
|
}
|
||||||
if (blocks.size() > 0) {
|
if (!Settings.PISTON_FALLING_BLOCK_CHECK) {
|
||||||
lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative);
|
return;
|
||||||
}
|
}
|
||||||
else {
|
org.bukkit.Location lastLoc;
|
||||||
lastLoc = event.getBlock().getLocation().add(relative);
|
if (blocks.size() > 0) {
|
||||||
}
|
lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative);
|
||||||
Entity[] ents = lastLoc.getChunk().getEntities();
|
}
|
||||||
for (Entity entity : ents) {
|
else {
|
||||||
if (entity instanceof FallingBlock) {
|
lastLoc = event.getBlock().getLocation().add(relative);
|
||||||
org.bukkit.Location eloc = entity.getLocation();
|
}
|
||||||
if (eloc.distanceSquared(lastLoc) < 2) {
|
Entity[] ents = lastLoc.getChunk().getEntities();
|
||||||
event.setCancelled(true);
|
for (Entity entity : ents) {
|
||||||
return;
|
if (entity instanceof FallingBlock) {
|
||||||
}
|
org.bukkit.Location eloc = entity.getLocation();
|
||||||
|
if (eloc.distanceSquared(lastLoc) < 2) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -729,15 +727,20 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<BlockState> blocks = e.getBlocks();
|
final List<BlockState> blocks = e.getBlocks();
|
||||||
|
if (blocks.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot origin = MainUtil.getPlot(BukkitUtil.getLocation(blocks.get(0).getLocation()));
|
||||||
|
BlockState start = blocks.get(0);
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = getCurrentPlot(loc);
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if (MainUtil.equals(plot, origin)) {
|
||||||
e.getBlocks().remove(i);
|
e.getBlocks().remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onInteract(final PlayerInteractEvent event) {
|
public static void onInteract(final PlayerInteractEvent event) {
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
|
@ -79,6 +79,16 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
return myplots;
|
return myplots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean equals(Object a, Object b) {
|
||||||
|
if (a == b) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (a == null ^ b == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return a.equals(b);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of plots for a player
|
* Get the number of plots for a player
|
||||||
|
Loading…
Reference in New Issue
Block a user