breakevent

This commit is contained in:
MidnightTale 2023-04-24 23:10:26 +07:00
commit f64315c638

View file

@ -10,6 +10,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
@ -100,11 +101,12 @@ public class FoliaFlow extends JavaPlugin implements Listener {
// } // }
// } // }
@EventHandler @EventHandler
public void onEntitySpawn(EntitySpawnEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if (event.getEntity() instanceof FallingBlock) { Block block = event.getBlock();
FallingBlock block = (FallingBlock) event.getEntity(); if (block.getWorld().getEnvironment() == World.Environment.THE_END) {
if (block.getWorld().getEnvironment() == World.Environment.THE_END) { // The block is in the End world
// The falling block is in the End world if (block.getBlockData() instanceof FallingBlock) {
// The block that was broken is a falling block
String message = "I found a falling block in the End!"; String message = "I found a falling block in the End!";
Bukkit.broadcastMessage(message); Bukkit.broadcastMessage(message);
} }
@ -115,6 +117,7 @@ public class FoliaFlow extends JavaPlugin implements Listener {
@EventHandler @EventHandler
public void onFallingBlockToBlock(EntityChangeBlockEvent e){ public void onFallingBlockToBlock(EntityChangeBlockEvent e){
if(e.getEntityType() == EntityType.FALLING_BLOCK){ if(e.getEntityType() == EntityType.FALLING_BLOCK){