@@ -75,12 +75,14 @@ private void updateRegions(Player player, Location locationFrom, Location locati
75
75
}
76
76
77
77
// Detecting __global__ region Enter event
78
- futureRegions .add (globalTo );
79
- if (!currentPlayerRegions .contains (globalTo )) {
80
- currentPlayerRegions .add (globalTo );
81
-
82
- RegionBorderEvent enterEvent = new RegionBorderEvent (globalTo , CrossType .ENTER , player , locationFrom , locationTo );
83
- Bukkit .getPluginManager ().callEvent (enterEvent );
78
+ if (globalTo != null ) {
79
+ futureRegions .add (globalTo );
80
+ if (!currentPlayerRegions .contains (globalTo )) {
81
+ currentPlayerRegions .add (globalTo );
82
+
83
+ RegionBorderEvent enterEvent = new RegionBorderEvent (globalTo , CrossType .ENTER , player , locationFrom , locationTo );
84
+ Bukkit .getPluginManager ().callEvent (enterEvent );
85
+ }
84
86
}
85
87
86
88
// Detecting Leave event in non-global regions
@@ -97,11 +99,13 @@ private void updateRegions(Player player, Location locationFrom, Location locati
97
99
}
98
100
99
101
// Detecting __global__ region Leave event
100
- if (!futureRegions .contains (globalFrom )) {
101
- currentPlayerRegions .remove (globalFrom );
102
-
103
- RegionBorderEvent leaveEvent = new RegionBorderEvent (globalFrom , CrossType .LEAVE , player , locationFrom , locationTo );
104
- Bukkit .getPluginManager ().callEvent (leaveEvent );
102
+ if (globalFrom != null ) {
103
+ if (!futureRegions .contains (globalFrom )) {
104
+ currentPlayerRegions .remove (globalFrom );
105
+
106
+ RegionBorderEvent leaveEvent = new RegionBorderEvent (globalFrom , CrossType .LEAVE , player , locationFrom , locationTo );
107
+ Bukkit .getPluginManager ().callEvent (leaveEvent );
108
+ }
105
109
}
106
110
}
107
111
0 commit comments