Implement wander worldguard region change
This commit is contained in:
parent
eb1af71429
commit
58655fc45e
|
@ -168,9 +168,6 @@ public class WanderWaypointProvider
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WanderWaypointProvider.this.worldguardRegion = regionId;
|
WanderWaypointProvider.this.worldguardRegion = regionId;
|
||||||
if (currentGoal != null) {
|
|
||||||
currentGoal.setWorldGuardRegion(region);
|
|
||||||
}
|
|
||||||
Messaging.sendErrorTr(sender, Messages.WANDER_WAYPOINTS_WORLDGUARD_REGION_SET, regionId);
|
Messaging.sendErrorTr(sender, Messages.WANDER_WAYPOINTS_WORLDGUARD_REGION_SET, regionId);
|
||||||
});
|
});
|
||||||
} else if (message.startsWith("pathfind")) {
|
} else if (message.startsWith("pathfind")) {
|
||||||
|
@ -234,12 +231,12 @@ public class WanderWaypointProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getWorldGuardRegion() {
|
public Object getWorldGuardRegion() {
|
||||||
if (worldguardRegion == null) {
|
if (worldguardRegion == null)
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
if (worldguardRegionCache != null) {
|
if (worldguardRegionCache != null)
|
||||||
return worldguardRegionCache;
|
return worldguardRegionCache;
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer()
|
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer()
|
||||||
.get(BukkitAdapter.adapt(npc.getStoredLocation().getWorld()));
|
.get(BukkitAdapter.adapt(npc.getStoredLocation().getWorld()));
|
||||||
|
@ -270,7 +267,7 @@ public class WanderWaypointProvider
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
if (currentGoal == null) {
|
if (currentGoal == null) {
|
||||||
currentGoal = WanderGoal.builder(npc).xrange(xrange).yrange(yrange).fallback(this).tree(this).delay(delay)
|
currentGoal = WanderGoal.builder(npc).xrange(xrange).yrange(yrange).fallback(this).tree(this).delay(delay)
|
||||||
.worldguardRegion(getWorldGuardRegion()).build();
|
.worldguardRegion(() -> getWorldGuardRegion()).build();
|
||||||
if (paused) {
|
if (paused) {
|
||||||
currentGoal.pause();
|
currentGoal.pause();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue