Prevent dragon eggs from leaving or entering plot bounds (#3075)

* Negate mob-place flag debug message

* fixed a little typo :)

* Added check for dragon egg teleportation event
https://github.com/IntellectualSites/PlotSquared/issues/3074

* Basic dragon egg interact bugfix (Left-click interaction)

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
Patrick "IPat" Hein 2021-05-28 10:57:48 +02:00 committed by GitHub
parent dc7e6010cb
commit 2045a4988d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -751,7 +751,7 @@ public class BlockEventListener implements Listener {
if (plot != null && plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event
.getBlock()
.isLiquid()) {
plot.debug("Liquid could now flow because liquid-flow = disabled");
plot.debug("Liquid could not flow because liquid-flow = disabled");
event.setCancelled(true);
return;
}
@ -761,9 +761,24 @@ public class BlockEventListener implements Listener {
Location tLocation = BukkitUtil.adapt(to.getLocation());
PlotArea area = tLocation.getPlotArea();
if (area == null) {
if (from.getType() == Material.DRAGON_EGG && fromArea != null) {
event.setCancelled(true);
}
return;
}
Plot plot = area.getOwnedPlot(tLocation);
if (from.getType() == Material.DRAGON_EGG && fromArea != null) {
final Plot fromPlot = fromArea.getOwnedPlot(fLocation);
if (fromPlot != null || plot != null) {
if ((fromPlot == null || !fromPlot.equals(plot)) && (plot == null || !plot.equals(fromPlot))) {
event.setCancelled(true);
return;
}
}
}
if (plot != null) {
if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);

View File

@ -1103,6 +1103,17 @@ public class PlayerEventListener extends PlotListener implements Listener {
}
break;
}
case LEFT_CLICK_BLOCK: {
Material blockType = block.getType();
// todo: when the code above is rearranged, it would be great to beautify this as well.
// will code this as a temporary, specific bug fix (for dragon eggs)
if (blockType != Material.DRAGON_EGG) return;
eventType = PlayerBlockEventType.INTERACT_BLOCK;
blocktype1 = BukkitAdapter.asBlockType(block.getType());
break;
}
default:
return;
}