Pushing placed blocks with pistons no longer makes them give exp again

This commit is contained in:
Aria Sangarin 2020-02-06 08:32:14 +01:00
parent a438c3978c
commit d9f0444df0

View File

@ -11,6 +11,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
@ -123,6 +125,32 @@ public class BlockListener implements Listener {
event.getBlock().setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
}
@EventHandler
public void c1(BlockPistonExtendEvent event) {
Block movedBlock = event.getBlock();
if(!movedBlock.hasMetadata("player_placed")) return;
BlockFace direction = event.getDirection();
movedBlock = movedBlock.getRelative(direction, 2);
for (Block b : event.getBlocks()) {
if (b.hasMetadata("player_placed")) {
movedBlock = b.getRelative(direction);
movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
}
}
}
@EventHandler
public void c2(BlockPistonRetractEvent event) {
BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock().getRelative(direction);
movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
for (Block block : event.getBlocks()) {
movedBlock = block.getRelative(direction);
movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
}
}
private Location getSafeDropLocation(Block block, boolean self) {
if (block.getType() == Material.AIR && self)
return block.getLocation();