Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Fix NPE when global regions do not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Arzio committed Jan 1, 2020
1 parent 061c8d3 commit 920ce15
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ private void updateRegions(Player player, Location locationFrom, Location locati
}

// Detecting __global__ region Enter event
futureRegions.add(globalTo);
if (!currentPlayerRegions.contains(globalTo)) {
currentPlayerRegions.add(globalTo);

RegionBorderEvent enterEvent = new RegionBorderEvent(globalTo, CrossType.ENTER, player, locationFrom, locationTo);
Bukkit.getPluginManager().callEvent(enterEvent);
if (globalTo != null) {
futureRegions.add(globalTo);
if (!currentPlayerRegions.contains(globalTo)) {
currentPlayerRegions.add(globalTo);

RegionBorderEvent enterEvent = new RegionBorderEvent(globalTo, CrossType.ENTER, player, locationFrom, locationTo);
Bukkit.getPluginManager().callEvent(enterEvent);
}
}

// Detecting Leave event in non-global regions
Expand All @@ -97,11 +99,13 @@ private void updateRegions(Player player, Location locationFrom, Location locati
}

// Detecting __global__ region Leave event
if (!futureRegions.contains(globalFrom)) {
currentPlayerRegions.remove(globalFrom);

RegionBorderEvent leaveEvent = new RegionBorderEvent(globalFrom, CrossType.LEAVE, player, locationFrom, locationTo);
Bukkit.getPluginManager().callEvent(leaveEvent);
if (globalFrom != null) {
if (!futureRegions.contains(globalFrom)) {
currentPlayerRegions.remove(globalFrom);

RegionBorderEvent leaveEvent = new RegionBorderEvent(globalFrom, CrossType.LEAVE, player, locationFrom, locationTo);
Bukkit.getPluginManager().callEvent(leaveEvent);
}
}
}

Expand Down

0 comments on commit 920ce15

Please sign in to comment.