forked from kaboomserver/extras
Mitigate command block bugs
This commit is contained in:
parent
b5046d8325
commit
ddd6fa76f4
3 changed files with 12 additions and 32 deletions
|
@ -1,16 +1,11 @@
|
|||
package pw.kaboom.extras;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
class BlockCheck implements Listener {
|
||||
@EventHandler
|
||||
void onBlockPlace(BlockPlaceEvent event) {
|
||||
|
@ -25,24 +20,6 @@ class BlockCheck implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onChunkLoad(final ChunkLoadEvent event) {
|
||||
if (!event.isNewChunk()) {
|
||||
try {
|
||||
for (BlockState block : event.getChunk().getTileEntities()) {
|
||||
if (block instanceof CommandBlock) {
|
||||
block.update();
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
event.getChunk().getWorld().regenerateChunk(
|
||||
event.getChunk().getX(),
|
||||
event.getChunk().getZ()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onSignChange(SignChangeEvent event) {
|
||||
try {
|
||||
|
|
|
@ -9,6 +9,8 @@ import org.bukkit.World;
|
|||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
|
||||
import org.bukkit.block.data.Levelled;
|
||||
|
||||
|
@ -74,6 +76,10 @@ class BlockPhysics implements Listener {
|
|||
|
||||
if (material == Material.FARMLAND) {
|
||||
event.setCancelled(true);
|
||||
} else if (event.getSourceBlock().getState() instanceof CommandBlock) {
|
||||
event.getSourceBlock().getState().update();
|
||||
} else if (event.getBlock().getState() instanceof CommandBlock) {
|
||||
event.getBlock().getState().update();
|
||||
} else if (event.getBlock().isLiquid()) {
|
||||
final Block block = event.getBlock();
|
||||
final World world = block.getWorld();
|
||||
|
|
|
@ -69,21 +69,18 @@ class EntitySpawn implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onBlockDispense(BlockDispenseEvent event) {
|
||||
System.out.println("lol");
|
||||
try {
|
||||
/*BlockStateMeta stateMeta = (BlockStateMeta) event.getItem().getItemMeta();
|
||||
|
||||
/*if (stateMeta.getBlockState() instanceof ShulkerBox) {
|
||||
ShulkerBox shulkerBox = (ShulkerBox) stateMeta.getBlockState();
|
||||
}
|
||||
stateMeta.getBlockState();*/
|
||||
event.getBlock().getState();
|
||||
event.getItem().getItemMeta();
|
||||
} catch (Exception exception) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*try {
|
||||
BlockStateMeta state = (BlockStateMeta) event.getItem().getItemMeta();
|
||||
state.getBlockState();
|
||||
} catch (UnsupportedOperationException exception) {
|
||||
System.out.println("I caught: " + exception);
|
||||
event.setCancelled(true);
|
||||
}*/
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
Loading…
Reference in a new issue