mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-05 02:10:10 +01:00
Bugfix (may need changing later)
This commit is contained in:
parent
59ec5c4154
commit
517736403b
@ -52,7 +52,6 @@ public class LinearWaypointProvider implements WaypointProvider {
|
||||
|
||||
@Override
|
||||
public void load(DataKey key) {
|
||||
waypoints.clear();
|
||||
for (DataKey root : key.getRelative("waypoints").getIntegerSubKeys()) {
|
||||
waypoints.add(new Waypoint(StorageUtils.loadLocation(root)));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
public class Waypoints extends Trait {
|
||||
private final NPC npc;
|
||||
private String providerName;
|
||||
private WaypointProvider provider;
|
||||
private WaypointProvider provider = new LinearWaypointProvider();
|
||||
|
||||
public Waypoints(NPC npc) {
|
||||
this.npc = npc;
|
||||
@ -23,12 +23,10 @@ public class Waypoints extends Trait {
|
||||
|
||||
@Override
|
||||
public void load(DataKey key) throws NPCLoadException {
|
||||
if (provider == null) {
|
||||
providerName = key.getString("provider", "linear");
|
||||
provider = providers.getInstance(providerName);
|
||||
if (provider == null)
|
||||
return;
|
||||
}
|
||||
providerName = key.getString("provider", "linear");
|
||||
provider = providers.getInstance(providerName);
|
||||
if (provider == null)
|
||||
return;
|
||||
provider.load(key.getRelative(providerName));
|
||||
npc.getAI().registerNavigationCallback(provider.getCallback());
|
||||
}
|
||||
@ -45,6 +43,11 @@ public class Waypoints extends Trait {
|
||||
return provider.createEditor(player);
|
||||
}
|
||||
|
||||
public void setWaypointProvider(WaypointProvider provider, String name) {
|
||||
this.provider = provider;
|
||||
providerName = name;
|
||||
}
|
||||
|
||||
public static void registerWaypointProvider(Class<? extends WaypointProvider> clazz, String name) {
|
||||
providers.register(clazz, name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user