Change waypoints to onAttach

This commit is contained in:
fullwall 2019-12-21 19:09:50 +09:00
parent 3e708f0d80
commit 3186f6de5e

View File

@ -20,7 +20,7 @@ import net.citizensnpcs.util.StringHelper;
@TraitName("waypoints")
public class Waypoints extends Trait {
private WaypointProvider provider = new LinearWaypointProvider(npc);
private WaypointProvider provider;
private String providerName = "linear";
public Waypoints() {
@ -36,6 +36,10 @@ public class Waypoints extends Trait {
}
}
public void onAttach() {
provider = new LinearWaypointProvider(npc);
}
public void describeProviders(CommandSender sender) {
Messaging.sendTr(sender, Messages.AVAILABLE_WAYPOINT_PROVIDERS);
for (String name : PROVIDERS.keySet()) {
@ -44,7 +48,8 @@ public class Waypoints extends Trait {
}
/**
* Returns the current {@link WaypointProvider}. May be null during initialisation.
* Returns the current {@link WaypointProvider}. May be null during
* initialisation.
*
* @return The current provider
*/
@ -99,8 +104,8 @@ public class Waypoints extends Trait {
/**
* Sets the current {@link WaypointProvider} using the given name.
*
* @param name
* The name of the waypoint provider, registered using {@link #registerWaypointProvider(Class, String)}
* @param name The name of the waypoint provider, registered using
* {@link #registerWaypointProvider(Class, String)}
* @return Whether the operation succeeded
*/
public boolean setWaypointProvider(String name) {
@ -121,10 +126,8 @@ public class Waypoints extends Trait {
/**
* Registers a {@link WaypointProvider}, which can be subsequently used by NPCs.
*
* @param clazz
* The class of the waypoint provider
* @param name
* The name of the waypoint provider
* @param clazz The class of the waypoint provider
* @param name The name of the waypoint provider
*/
public static void registerWaypointProvider(Class<? extends WaypointProvider> clazz, String name) {
PROVIDERS.put(name, clazz);