1515import org .bukkit .event .EventPriority ;
1616import org .bukkit .event .Listener ;
1717import org .bukkit .event .block .Action ;
18- import org .bukkit .event .block .BlockDamageEvent ;
1918import org .bukkit .event .block .BlockPistonExtendEvent ;
2019import org .bukkit .event .block .BlockPistonRetractEvent ;
2120import org .bukkit .event .entity .EntityChangeBlockEvent ;
2221import org .bukkit .event .entity .EntityExplodeEvent ;
2322import org .bukkit .event .entity .EntitySpawnEvent ;
24- import org .bukkit .event .inventory .ClickType ;
2523import org .bukkit .event .player .PlayerInteractEvent ;
2624import org .bukkit .util .Vector ;
2725
@@ -43,35 +41,18 @@ public BlockProtect(AOneBlock addon) {
4341 this .addon = addon ;
4442 }
4543
46- /**
47- * Show particles when block is hit
48- * @param e - event
49- */
50- @ EventHandler (priority = EventPriority .NORMAL , ignoreCancelled = true )
51- public void onBlockDamage (BlockDamageEvent e ) {
52- if (!addon .inWorld (e .getBlock ().getWorld ())
53- && addon .getSettings ().getClickType ().equals (ClickType .LEFT .name ())) {
54- return ;
55- }
56- Block block = e .getBlock ();
57- Location l = block .getLocation ();
58- addon .getIslands ().getIslandAt (l ).map (Island ::getCenter ).filter (l ::equals ).ifPresent (this ::showSparkles );
59-
60- }
61-
6244 /**
6345 * Show particles when block is hit
6446 * @param e - event
6547 */
6648 @ EventHandler (priority = EventPriority .NORMAL , ignoreCancelled = true )
6749 public void onBlockDamage (PlayerInteractEvent e ) {
68- if (!addon .inWorld (e .getPlayer ().getWorld ())) {
50+ if (!addon .inWorld (e .getPlayer ().getWorld ()) || e . getClickedBlock () == null ) {
6951 return ;
7052 }
7153
7254 Action action = e .getAction ();
7355 String clickType = addon .getSettings ().getClickType ();
74-
7556 if ((action == Action .LEFT_CLICK_BLOCK && clickType .equalsIgnoreCase ("LEFT" ))
7657 || (action == Action .RIGHT_CLICK_BLOCK && clickType .equalsIgnoreCase ("RIGHT" ))) {
7758
0 commit comments