mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Implement getters and setters in wander waypoint goal
This commit is contained in:
parent
0e9dcf210f
commit
d0abea6dd5
@ -41,10 +41,10 @@ import net.citizensnpcs.util.Util;
|
||||
public class WanderWaypointProvider implements WaypointProvider {
|
||||
private WanderGoal currentGoal;
|
||||
@Persist
|
||||
public int delay = -1;
|
||||
private int delay = -1;
|
||||
private NPC npc;
|
||||
@Persist
|
||||
public boolean pathfind = true;
|
||||
private boolean pathfind = true;
|
||||
private boolean paused;
|
||||
@Persist
|
||||
private final List<Location> regionCentres = Lists.newArrayList();
|
||||
@ -53,9 +53,9 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
private String worldguardRegion;
|
||||
private Object worldguardRegionCache;
|
||||
@Persist
|
||||
public int xrange = DEFAULT_XRANGE;
|
||||
private int xrange = DEFAULT_XRANGE;
|
||||
@Persist
|
||||
public int yrange = DEFAULT_YRANGE;
|
||||
private int yrange = DEFAULT_YRANGE;
|
||||
|
||||
public void addRegionCentre(Location centre) {
|
||||
regionCentres.add(centre);
|
||||
@ -106,15 +106,12 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
range = 0;
|
||||
}
|
||||
if (message.startsWith("xrange")) {
|
||||
xrange = range;
|
||||
setXYRange(range, yrange);
|
||||
} else {
|
||||
yrange = range;
|
||||
}
|
||||
if (currentGoal != null) {
|
||||
currentGoal.setXYRange(xrange, yrange);
|
||||
setXYRange(xrange, range);
|
||||
}
|
||||
recalculateTree();
|
||||
} catch (Exception ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||
() -> Messaging.sendTr(sender, Messages.WANDER_WAYPOINTS_RANGE_SET, xrange, yrange));
|
||||
@ -136,17 +133,14 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
});
|
||||
} else if (message.startsWith("delay")) {
|
||||
event.setCancelled(true);
|
||||
delay = Util.parseTicks(message.split(" ")[1]);
|
||||
if (currentGoal != null) {
|
||||
currentGoal.setDelay(delay);
|
||||
}
|
||||
setDelay(Util.parseTicks(message.split(" ")[1]));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||
() -> Messaging.sendTr(sender, Messages.WANDER_WAYPOINTS_DELAY_SET, delay));
|
||||
} else if (message.startsWith("worldguardregion")) {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||
Object region = null;
|
||||
String regionId = message.replace("worldguardregion ", "");
|
||||
String regionId = message.replace("worldguardregion", "").trim();
|
||||
try {
|
||||
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer()
|
||||
.get(BukkitAdapter.adapt(npc.getStoredLocation().getWorld()));
|
||||
@ -158,7 +152,7 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
Messaging.sendErrorTr(sender, Messages.WANDER_WAYPOINTS_WORLDGUARD_REGION_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
WanderWaypointProvider.this.worldguardRegion = regionId;
|
||||
setWorldGuardRegion(regionId);
|
||||
Messaging.sendErrorTr(sender, Messages.WANDER_WAYPOINTS_WORLDGUARD_REGION_SET, regionId);
|
||||
});
|
||||
} else if (message.startsWith("pathfind")) {
|
||||
@ -212,6 +206,10 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
};
|
||||
}
|
||||
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
public List<Location> getRegionCentres() {
|
||||
return new RecalculateList();
|
||||
}
|
||||
@ -233,6 +231,18 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public int getXRange() {
|
||||
return xrange;
|
||||
}
|
||||
|
||||
public int getYRange() {
|
||||
return yrange;
|
||||
}
|
||||
|
||||
public boolean isPathfind() {
|
||||
return pathfind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
return paused;
|
||||
@ -298,6 +308,20 @@ public class WanderWaypointProvider implements WaypointProvider {
|
||||
public void save(DataKey key) {
|
||||
}
|
||||
|
||||
public void setDelay(int delay) {
|
||||
this.delay = delay;
|
||||
if (currentGoal != null) {
|
||||
currentGoal.setDelay(delay);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPathfind(boolean pathfind) {
|
||||
this.pathfind = pathfind;
|
||||
if (currentGoal != null) {
|
||||
currentGoal.setPathfind(pathfind);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaused(boolean paused) {
|
||||
this.paused = paused;
|
||||
|
@ -16,6 +16,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -55,7 +56,6 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -541,12 +541,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input -> input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -609,19 +604,11 @@ public class NMSImpl implements NMSBridge {
|
||||
@Override
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
final PathEntity path = new PathEntity(
|
||||
Iterables.toArray(Iterables.transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}), PathPoint.class));
|
||||
return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(NavigationAbstract input) {
|
||||
return input.a(path, params.speed());
|
||||
}
|
||||
});
|
||||
final PathEntity path = new PathEntity(Iterables.toArray(
|
||||
Iterables.transform(dest,
|
||||
input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())),
|
||||
PathPoint.class));
|
||||
return getTargetNavigator(entity, params, input -> input.a(path, params.speed()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +55,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -561,12 +561,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -630,12 +625,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
final PathEntity path = new PathEntity(
|
||||
Iterables.toArray(Iterables.transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}), PathPoint.class));
|
||||
Iterables.toArray(Iterables.transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), PathPoint.class));
|
||||
return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(NavigationAbstract input) {
|
||||
|
@ -55,7 +55,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -630,12 +630,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
final PathEntity path = new PathEntity(
|
||||
Iterables.toArray(Iterables.transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}), PathPoint.class));
|
||||
Iterables.toArray(Iterables.transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), PathPoint.class));
|
||||
return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(NavigationAbstract input) {
|
||||
|
@ -56,7 +56,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -589,12 +589,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -658,12 +653,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
final PathEntity path = new PathEntity(
|
||||
Iterables.toArray(Iterables.transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}), PathPoint.class));
|
||||
Iterables.toArray(Iterables.transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), PathPoint.class));
|
||||
return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(NavigationAbstract input) {
|
||||
|
@ -54,7 +54,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -626,12 +626,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -693,12 +688,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
List<PathPoint> list = Lists.<PathPoint> newArrayList(
|
||||
Iterables.<Vector, PathPoint> transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}));
|
||||
Iterables.<Vector, PathPoint> transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
|
||||
PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
|
||||
final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null,
|
||||
true);
|
||||
|
@ -54,7 +54,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -641,12 +641,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -708,12 +703,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
List<PathPoint> list = Lists.<PathPoint> newArrayList(
|
||||
Iterables.<Vector, PathPoint> transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}));
|
||||
Iterables.<Vector, PathPoint> transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
|
||||
PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
|
||||
final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null,
|
||||
true);
|
||||
|
@ -55,7 +55,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
@ -657,12 +657,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -732,12 +727,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
List<PathPoint> list = Lists.<PathPoint> newArrayList(
|
||||
Iterables.<Vector, PathPoint> transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}));
|
||||
Iterables.<Vector, PathPoint> transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())));
|
||||
PathPoint last = list.size() > 0 ? list.get(list.size() - 1) : null;
|
||||
final PathEntity path = new PathEntity(list, last != null ? new BlockPosition(last.a, last.b, last.c) : null,
|
||||
true);
|
||||
|
@ -52,7 +52,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
@ -666,12 +666,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
@ -672,12 +672,7 @@ public class NMSImpl implements NMSBridge {
|
||||
Entity handle = NMSImpl.getHandle(entity);
|
||||
if (handle == null || handle.passengers == null)
|
||||
return Lists.newArrayList();
|
||||
return Lists.transform(handle.passengers, new Function<Entity, org.bukkit.entity.Entity>() {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity apply(Entity input) {
|
||||
return input.getBukkitEntity();
|
||||
}
|
||||
});
|
||||
return Lists.transform(handle.passengers, input->input.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import java.util.function.Function;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
@ -558,12 +558,7 @@ public class NMSImpl implements NMSBridge {
|
||||
public MCNavigator getTargetNavigator(org.bukkit.entity.Entity entity, Iterable<Vector> dest,
|
||||
final NavigatorParameters params) {
|
||||
final PathEntity path = new PathEntity(
|
||||
Iterables.toArray(Iterables.transform(dest, new Function<Vector, PathPoint>() {
|
||||
@Override
|
||||
public PathPoint apply(Vector input) {
|
||||
return new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ());
|
||||
}
|
||||
}), PathPoint.class));
|
||||
Iterables.toArray(Iterables.transform(dest, input -> new PathPoint(input.getBlockX(), input.getBlockY(), input.getBlockZ())), PathPoint.class));
|
||||
return getTargetNavigator(entity, params, new Function<NavigationAbstract, Boolean>() {
|
||||
@Override
|
||||
public Boolean apply(NavigationAbstract input) {
|
||||
|
Loading…
Reference in New Issue
Block a user