2727import org .bukkit .entity .Entity ;
2828import org .bukkit .entity .EntityType ;
2929import org .bukkit .entity .Player ;
30- import org .bukkit .event .block .BlockDamageEvent ;
30+ import org .bukkit .event .block .Action ;
3131import org .bukkit .event .block .BlockPistonExtendEvent ;
3232import org .bukkit .event .block .BlockPistonRetractEvent ;
3333import org .bukkit .event .entity .EntityChangeBlockEvent ;
3434import org .bukkit .event .entity .EntityExplodeEvent ;
3535import org .bukkit .event .entity .EntitySpawnEvent ;
36+ import org .bukkit .event .player .PlayerInteractEvent ;
3637import org .bukkit .inventory .ItemStack ;
3738import org .junit .After ;
3839import org .junit .Before ;
@@ -74,6 +75,8 @@ public class BlockProtectTest {
7475 */
7576 @ Before
7677 public void setUp () throws Exception {
78+
79+ when (p .getWorld ()).thenReturn (world );
7780 // In World
7881 when (addon .inWorld (world )).thenReturn (true );
7982
@@ -118,11 +121,12 @@ public void testBlockProtect() {
118121 @ Test
119122 public void testOnBlockDamage () {
120123 ItemStack item = new ItemStack (Material .DIAMOND_PICKAXE );
121- BlockDamageEvent blockDamageEvent = new BlockDamageEvent (p , block , item , false );
124+ PlayerInteractEvent blockDamageEvent = new PlayerInteractEvent (p , Action .LEFT_CLICK_BLOCK , item , block ,
125+ BlockFace .UP );
122126 bp .onBlockDamage (blockDamageEvent );
123127 verify (addon ).inWorld (world );
124128 verify (im ).getIslandAt (location );
125- verify (world , times (80 )).spawnParticle (eq (Particle .REDSTONE ), eq (null ), eq (5 ),
129+ verify (world , times (48 )).spawnParticle (eq (Particle .REDSTONE ), eq (null ), eq (5 ),
126130 eq (0.1D ), eq (0D ), eq (0.1D ), eq (1D ), any (Particle .DustOptions .class ));
127131 }
128132
@@ -131,9 +135,10 @@ public void testOnBlockDamage() {
131135 */
132136 @ Test
133137 public void testOnBlockDamageWrongWorld () {
134- when (block .getWorld ()).thenReturn (mock (World .class ));
138+ when (p .getWorld ()).thenReturn (mock (World .class ));
135139 ItemStack item = new ItemStack (Material .DIAMOND_PICKAXE );
136- BlockDamageEvent blockDamageEvent = new BlockDamageEvent (p , block , item , false );
140+ PlayerInteractEvent blockDamageEvent = new PlayerInteractEvent (p , Action .LEFT_CLICK_BLOCK , item , block ,
141+ BlockFace .UP );
137142 bp .onBlockDamage (blockDamageEvent );
138143 verify (im , never ()).getIslandAt (location );
139144 verify (world , never ()).spawnParticle (any (Particle .class ), any (Location .class ),anyInt (),
@@ -147,7 +152,8 @@ public void testOnBlockDamageWrongWorld() {
147152 public void testOnBlockDamageNotCenterMagicBlock () {
148153 when (block .getLocation ()).thenReturn (mock (Location .class ));
149154 ItemStack item = new ItemStack (Material .DIAMOND_PICKAXE );
150- BlockDamageEvent blockDamageEvent = new BlockDamageEvent (p , block , item , false );
155+ PlayerInteractEvent blockDamageEvent = new PlayerInteractEvent (p , Action .LEFT_CLICK_BLOCK , item , block ,
156+ BlockFace .UP );
151157 bp .onBlockDamage (blockDamageEvent );
152158 verify (addon ).inWorld (world );
153159 verify (im ).getIslandAt (any (Location .class ));
0 commit comments