@@ -22,8 +22,7 @@ public class BlockEnvironmentListener implements Listener{
22
22
// Prevent explosion break block
23
23
@ EventHandler (priority = EventPriority .HIGH )
24
24
public void onEntityExplode (EntityExplodeEvent event ){
25
- if (Config .isProtectionExempted ("explosion" )) return ;
26
- if (event .getLocation () != null && Config .isDisabledWorld (event .getLocation ().getWorld ().getName ())) return ;
25
+ if (Config .isProtectionExempted ("explosion" ) || Config .isDisabledWorld (event .getLocation ())) return ;
27
26
Iterator <Block > it = event .blockList ().iterator ();
28
27
while (it .hasNext ()) {
29
28
Block block = it .next ();
@@ -34,8 +33,7 @@ public void onEntityExplode(EntityExplodeEvent event){
34
33
// Prevent bed break block
35
34
@ EventHandler (priority = EventPriority .HIGH )
36
35
public void onBlockExplode (BlockExplodeEvent event ){
37
- if (Config .isProtectionExempted ("explosion" )) return ;
38
- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
36
+ if (Config .isProtectionExempted ("explosion" ) || Config .isDisabledWorld (event .getBlock ())) return ;
39
37
Iterator <Block > it = event .blockList ().iterator ();
40
38
while (it .hasNext ()) {
41
39
Block block = it .next ();
@@ -46,8 +44,7 @@ public void onBlockExplode(BlockExplodeEvent event){
46
44
// Prevent tree break block
47
45
@ EventHandler (priority = EventPriority .HIGH )
48
46
public void onStructureGrow (StructureGrowEvent event ){
49
- if (Config .isProtectionExempted ("growth" )) return ;
50
- if (event .getWorld () != null && Config .isDisabledWorld (event .getWorld ().getName ())) return ;
47
+ if (Config .isProtectionExempted ("growth" ) || Config .isDisabledWorld (event .getWorld ().getName ())) return ;
51
48
for (BlockState blockstate : event .getBlocks ()){
52
49
if (LocketteProAPI .isProtected (blockstate .getBlock ())){
53
50
event .setCancelled (true );
@@ -59,8 +56,7 @@ public void onStructureGrow(StructureGrowEvent event){
59
56
// Prevent piston extend break lock
60
57
@ EventHandler (priority = EventPriority .HIGH )
61
58
public void onPistonExtend (BlockPistonExtendEvent event ){
62
- if (Config .isProtectionExempted ("piston" )) return ;
63
- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
59
+ if (Config .isProtectionExempted ("piston" ) || Config .isDisabledWorld (event .getBlock ())) return ;
64
60
for (Block block : event .getBlocks ()){
65
61
if (LocketteProAPI .isProtected (block )){
66
62
event .setCancelled (true );
@@ -72,8 +68,7 @@ public void onPistonExtend(BlockPistonExtendEvent event){
72
68
// Prevent piston retract break lock
73
69
@ EventHandler (priority = EventPriority .HIGH )
74
70
public void onPistonRetract (BlockPistonRetractEvent event ){
75
- if (Config .isProtectionExempted ("piston" )) return ;
76
- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
71
+ if (Config .isProtectionExempted ("piston" ) || Config .isDisabledWorld (event .getBlock ())) return ;
77
72
for (Block block : event .getBlocks ()){
78
73
if (LocketteProAPI .isProtected (block )){
79
74
event .setCancelled (true );
@@ -85,8 +80,7 @@ public void onPistonRetract(BlockPistonRetractEvent event){
85
80
// Prevent redstone current open doors
86
81
@ EventHandler (priority = EventPriority .HIGH )
87
82
public void onBlockRedstoneChange (BlockRedstoneEvent event ){
88
- if (Config .isProtectionExempted ("redstone" )) return ;
89
- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
83
+ if (Config .isProtectionExempted ("redstone" ) || Config .isDisabledWorld (event .getBlock ())) return ;
90
84
if (LocketteProAPI .isProtected (event .getBlock ())){
91
85
event .setNewCurrent (event .getOldCurrent ());
92
86
}
@@ -95,8 +89,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event){
95
89
// Prevent villager open door
96
90
@ EventHandler (priority = EventPriority .HIGH )
97
91
public void onVillagerOpenDoor (EntityInteractEvent event ){
98
- if (Config .isProtectionExempted ("villager" )) return ;
99
- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
92
+ if (Config .isProtectionExempted ("villager" ) || Config .isDisabledWorld (event .getBlock ())) return ;
100
93
// Explicitly to villager vs all doors
101
94
if (event .getEntity () instanceof Villager &&
102
95
(LocketteProAPI .isSingleDoorBlock (event .getBlock ()) || LocketteProAPI .isDoubleDoorBlock (event .getBlock ())) &&
@@ -108,8 +101,7 @@ public void onVillagerOpenDoor(EntityInteractEvent event){
108
101
// Prevent Enderman take block
109
102
@ EventHandler (priority = EventPriority .HIGH )
110
103
public void onEndermanGreif (EntityInteractEvent event ){
111
- if (Config .isProtectionExempted ("enderman" )) return ;
112
- if (event .getBlock () != null && Config .isDisabledWorld (event .getBlock ().getWorld ().getName ())) return ;
104
+ if (Config .isProtectionExempted ("enderman" ) || Config .isDisabledWorld (event .getBlock ())) return ;
113
105
if (event .getEntity () instanceof Enderman && LocketteProAPI .isProtected (event .getBlock ())){
114
106
event .setCancelled (true );
115
107
}
0 commit comments