mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixed piston event
This commit is contained in:
parent
a79f3d9e54
commit
a6cd41fcb8
@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -286,11 +287,11 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onBigBoom(final EntityExplodeEvent event) {
|
public static void onBigBoom(final EntityExplodeEvent event) {
|
||||||
final String world = event.getLocation().getWorld().getName();
|
Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||||
|
final String world = loc.getWorld();
|
||||||
if (!isPlotWorld(world)) {
|
if (!isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
|
||||||
final Plot plot = getCurrentPlot(loc);
|
final Plot plot = getCurrentPlot(loc);
|
||||||
if ((plot != null) && plot.hasOwner()) {
|
if ((plot != null) && plot.hasOwner()) {
|
||||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||||
@ -511,27 +512,45 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public static void onBlockPistonExtend(final BlockPistonExtendEvent e) {
|
public static void onBlockPistonExtend(final BlockPistonExtendEvent event) {
|
||||||
if (isInPlot(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
final Block block = event.getBlock();
|
||||||
for (final Block block : e.getBlocks()) {
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
final Plot plot = getCurrentPlot(BukkitUtil.getLocation(block.getLocation()));
|
String world = loc.getWorld();
|
||||||
if (plot != null) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
return;
|
||||||
e.setCancelled(true);
|
}
|
||||||
}
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot != null) {
|
||||||
|
for (final Block b : event.getBlocks()) {
|
||||||
|
Location bloc = BukkitUtil.getLocation(b.getLocation());
|
||||||
|
Plot newPlot = MainUtil.getPlot(bloc);
|
||||||
|
if (!plot.equals(newPlot)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public static void onBlockPistonRetract(final BlockPistonRetractEvent e) {
|
public static void onBlockPistonRetract(final BlockPistonRetractEvent event) {
|
||||||
final Block b = e.getRetractLocation().getBlock();
|
final Block block = event.getBlock();
|
||||||
final Location loc = BukkitUtil.getLocation(b.getLocation());
|
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||||
if (isPlotWorld(loc) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
|
String world = loc.getWorld();
|
||||||
if (!isInPlot(loc)) {
|
if (!PlotSquared.isPlotWorld(world)) {
|
||||||
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) {
|
return;
|
||||||
e.setCancelled(true);
|
}
|
||||||
|
if (block.getType() != Material.PISTON_STICKY_BASE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot != null) {
|
||||||
|
for (final Block b : event.getBlocks()) {
|
||||||
|
Location bloc = BukkitUtil.getLocation(b.getLocation());
|
||||||
|
Plot newPlot = MainUtil.getPlot(bloc);
|
||||||
|
if (!plot.equals(newPlot)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user