mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
fix: Don't teleport shulkers on the road
This commit is contained in:
parent
b21d12fd52
commit
2f5e6665f7
@ -36,6 +36,7 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
|||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -191,8 +192,32 @@ public class EntitySpawnListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTeleport(EntityTeleportEvent event) {
|
public void onTeleport(EntityTeleportEvent event) {
|
||||||
Entity ent = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (ent instanceof Vehicle || ent instanceof ArmorStand) {
|
Entity fromLocation = event.getEntity();
|
||||||
|
Block toLocation = event.getTo().getBlock();
|
||||||
|
final Location fromLocLocation = BukkitUtil.adapt(fromLocation.getLocation());
|
||||||
|
final PlotArea fromArea = fromLocLocation.getPlotArea();
|
||||||
|
Location toLocLocation = BukkitUtil.adapt(toLocation.getLocation());
|
||||||
|
PlotArea area = toLocLocation.getPlotArea();
|
||||||
|
|
||||||
|
if (area == null) {
|
||||||
|
if (fromLocation.getType() == EntityType.SHULKER && fromArea != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = area.getOwnedPlot(toLocLocation);
|
||||||
|
if (fromLocation.getType() == EntityType.SHULKER && fromArea != null) {
|
||||||
|
final Plot fromPlot = fromArea.getOwnedPlot(fromLocLocation);
|
||||||
|
|
||||||
|
if (fromPlot != null || plot != null) {
|
||||||
|
if ((fromPlot == null || !fromPlot.equals(plot)) && (plot == null || !plot.equals(fromPlot))) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entity instanceof Vehicle || entity instanceof ArmorStand) {
|
||||||
testNether(event.getEntity());
|
testNether(event.getEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user