mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Passing events is bad.
This commit is contained in:
parent
0b6dfad7e5
commit
fe89c19969
@ -58,7 +58,6 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
|
|
||||||
List<Block> blocks = event.getBlocks();
|
List<Block> blocks = event.getBlocks();
|
||||||
BlockFace direction = event.getDirection();
|
BlockFace direction = event.getDirection();
|
||||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||||
@ -89,7 +88,7 @@ public class BlockListener implements Listener {
|
|||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
if (event.isSticky()) {
|
if (event.isSticky()) {
|
||||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||||
new StickyPistonTrackerTask(event).runTaskLater(plugin, 2);
|
new StickyPistonTrackerTask(event.getDirection(), event.getBlock()).runTaskLater(plugin, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,28 +2,26 @@ package com.gmail.nossr50.runnables;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class StickyPistonTrackerTask extends BukkitRunnable {
|
public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||||
BlockPistonRetractEvent event;
|
private BlockFace direction;
|
||||||
|
private Block block;
|
||||||
|
|
||||||
public StickyPistonTrackerTask(BlockPistonRetractEvent event) {
|
public StickyPistonTrackerTask(BlockFace direction, Block block) {
|
||||||
this.event = event;
|
this.direction = direction;
|
||||||
|
this.block = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Block newBlock = event.getBlock().getRelative(event.getDirection());
|
Block newBlock = block.getRelative(direction);
|
||||||
Block originalBlock = newBlock.getRelative(event.getDirection());
|
Block originalBlock = newBlock.getRelative(direction);
|
||||||
|
|
||||||
if (originalBlock.getType() != Material.AIR) {
|
if (originalBlock.getType() != Material.AIR || !mcMMO.placeStore.isTrue(originalBlock)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mcMMO.placeStore.isTrue(originalBlock)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user