mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
commit
5aa5ca1aed
@ -38,10 +38,11 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|||||||
/**
|
/**
|
||||||
* The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent}
|
* The {@link BlockListener} is responsible for listening to the {@link BlockPlaceEvent}
|
||||||
* and {@link BlockBreakEvent}.
|
* and {@link BlockBreakEvent}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
* @author Linox
|
* @author Linox
|
||||||
*
|
* @author Patbox
|
||||||
|
*
|
||||||
* @see BlockPlaceHandler
|
* @see BlockPlaceHandler
|
||||||
* @see BlockBreakHandler
|
* @see BlockBreakHandler
|
||||||
* @see ToolUseHandler
|
* @see ToolUseHandler
|
||||||
@ -58,7 +59,20 @@ public class BlockListener implements Listener {
|
|||||||
// This prevents Players from placing a block where another block already exists
|
// This prevents Players from placing a block where another block already exists
|
||||||
// While this can cause ghost blocks it also prevents them from replacing grass
|
// While this can cause ghost blocks it also prevents them from replacing grass
|
||||||
// or saplings etc...
|
// or saplings etc...
|
||||||
if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
Block block = e.getBlock();
|
||||||
|
|
||||||
|
if (e.getBlockReplacedState().getType().isAir()) {
|
||||||
|
SlimefunItem sfItem = BlockStorage.check(block);
|
||||||
|
|
||||||
|
if (sfItem != null) {
|
||||||
|
for (ItemStack item : sfItem.getDrops()) {
|
||||||
|
if (item != null && !item.getType().isAir()) {
|
||||||
|
block.getWorld().dropItemNaturally(block.getLocation(), item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BlockStorage.clearBlockInfo(block);
|
||||||
|
}
|
||||||
|
} else if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +184,7 @@ public class BlockListener implements Listener {
|
|||||||
* This method checks for a sensitive {@link Block}.
|
* This method checks for a sensitive {@link Block}.
|
||||||
* Sensitive {@link Block Blocks} are pressure plates or saplings, which should be broken
|
* Sensitive {@link Block Blocks} are pressure plates or saplings, which should be broken
|
||||||
* when the block beneath is broken as well.
|
* when the block beneath is broken as well.
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p
|
||||||
* The {@link Player} who broke this {@link Block}
|
* The {@link Player} who broke this {@link Block}
|
||||||
* @param b
|
* @param b
|
||||||
|
Loading…
Reference in New Issue
Block a user