mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
re-send block change for blocks with gravity if they're physicsed
fixes PS-159
This commit is contained in:
parent
5e88cabb4b
commit
de3ba9a25c
@ -187,17 +187,24 @@ public class BlockEventListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||||
switch (event.getChangedType()) {
|
|
||||||
case COMPARATOR: {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (location.isPlotArea()) {
|
PlotArea area = location.getPlotArea();
|
||||||
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = location.getOwnedPlotAbs();
|
Plot plot = area.getOwnedPlotAbs(location);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (event.getChangedType().hasGravity() && plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
sendBlockChange(event.getBlock().getLocation(), event.getBlock().getBlockData());
|
||||||
|
plot.debug("Prevented block physics and resent block change because disable-physics = true");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (event.getChangedType()) {
|
||||||
|
case COMPARATOR: {
|
||||||
if (!plot.getFlag(RedstoneFlag.class)) {
|
if (!plot.getFlag(RedstoneFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug("Prevented comparator update because redstone = false");
|
plot.debug("Prevented comparator update because redstone = false");
|
||||||
@ -211,16 +218,6 @@ public class BlockEventListener implements Listener {
|
|||||||
case TURTLE_EGG:
|
case TURTLE_EGG:
|
||||||
case TURTLE_HELMET:
|
case TURTLE_HELMET:
|
||||||
case TURTLE_SPAWN_EGG: {
|
case TURTLE_SPAWN_EGG: {
|
||||||
Block block = event.getBlock();
|
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
|
||||||
PlotArea area = location.getPlotArea();
|
|
||||||
if (area == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Plot plot = area.getOwnedPlotAbs(location);
|
|
||||||
if (plot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug("Prevented block physics because disable-physics = true");
|
plot.debug("Prevented block physics because disable-physics = true");
|
||||||
@ -229,21 +226,11 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
if (Settings.Redstone.DETECT_INVALID_EDGE_PISTONS) {
|
||||||
Block block = event.getBlock();
|
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case PISTON:
|
case PISTON:
|
||||||
case STICKY_PISTON:
|
case STICKY_PISTON:
|
||||||
org.bukkit.block.data.Directional piston =
|
org.bukkit.block.data.Directional piston =
|
||||||
(org.bukkit.block.data.Directional) block.getBlockData();
|
(org.bukkit.block.data.Directional) block.getBlockData();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
|
||||||
PlotArea area = location.getPlotArea();
|
|
||||||
if (area == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Plot plot = area.getOwnedPlotAbs(location);
|
|
||||||
if (plot == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (piston.getFacing()) {
|
switch (piston.getFacing()) {
|
||||||
case EAST:
|
case EAST:
|
||||||
location.setX(location.getX() + 1);
|
location.setX(location.getX() + 1);
|
||||||
@ -261,8 +248,7 @@ public class BlockEventListener implements Listener {
|
|||||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||||
if (!plot.equals(newPlot)) {
|
if (!plot.equals(newPlot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug(
|
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||||
"Prevented piston update because of invalid edge piston detection");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,9 @@ public class EntityEventListener implements Listener {
|
|||||||
if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
|
if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
|
if (block.getType().hasGravity()) {
|
||||||
|
BlockEventListener.sendBlockChange(block.getLocation(), block.getBlockData());
|
||||||
|
}
|
||||||
plot.debug("Falling block event was cancelled because disable-physics = true");
|
plot.debug("Falling block event was cancelled because disable-physics = true");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user