1
0
mirror of https://github.com/CitizensDev/Citizens2.git synced 2025-03-11 14:20:06 +01:00

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