Skip to content

Commit

Permalink
Implement wander worldguard region change
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 2, 2023
1 parent eb1af71 commit 58655fc
Showing 1 changed file with 5 additions and 8 deletions.
Expand Up @@ -168,9 +168,6 @@ public void onPlayerChat(AsyncPlayerChatEvent event) {
return;
}
WanderWaypointProvider.this.worldguardRegion = regionId;
if (currentGoal != null) {
currentGoal.setWorldGuardRegion(region);
}
Messaging.sendErrorTr(sender, Messages.WANDER_WAYPOINTS_WORLDGUARD_REGION_SET, regionId);
});
} else if (message.startsWith("pathfind")) {
Expand Down Expand Up @@ -234,12 +231,12 @@ public List<Location> getRegionCentres() {
}

public Object getWorldGuardRegion() {
if (worldguardRegion == null) {
if (worldguardRegion == null)
return null;
}
if (worldguardRegionCache != null) {

if (worldguardRegionCache != null)
return worldguardRegionCache;
}

try {
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer()
.get(BukkitAdapter.adapt(npc.getStoredLocation().getWorld()));
Expand Down Expand Up @@ -270,7 +267,7 @@ public void onSpawn(NPC npc) {
this.npc = npc;
if (currentGoal == null) {
currentGoal = WanderGoal.builder(npc).xrange(xrange).yrange(yrange).fallback(this).tree(this).delay(delay)
.worldguardRegion(getWorldGuardRegion()).build();
.worldguardRegion(() -> getWorldGuardRegion()).build();
if (paused) {
currentGoal.pause();
}
Expand Down

0 comments on commit 58655fc

Please sign in to comment.