mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Update waypoints for new AI
This commit is contained in:
parent
13c7e20514
commit
4ed5089030
@ -72,6 +72,23 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void enableSubPlugins() {
|
||||
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
|
||||
if (!root.exists() || !root.isDirectory())
|
||||
return;
|
||||
Plugin[] plugins = Bukkit.getPluginManager().loadPlugins(root);
|
||||
// code beneath modified from CraftServer
|
||||
for (Plugin plugin : plugins) {
|
||||
try {
|
||||
Messaging.logF("Loading %s", plugin.getDescription().getFullName());
|
||||
plugin.onLoad();
|
||||
} catch (Throwable ex) {
|
||||
Messaging.severe(ex.getMessage() + " initializing " + plugin.getDescription().getFullName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Iterable<net.citizensnpcs.command.Command> getCommands(String base) {
|
||||
return commands.getCommands(base);
|
||||
}
|
||||
@ -203,48 +220,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
}
|
||||
|
||||
private void enableSubPlugins() {
|
||||
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
|
||||
if (!root.exists() || !root.isDirectory())
|
||||
return;
|
||||
Plugin[] plugins = Bukkit.getPluginManager().loadPlugins(root);
|
||||
// code beneath modified from CraftServer
|
||||
for (Plugin plugin : plugins) {
|
||||
try {
|
||||
Messaging.logF("Loading %s", plugin.getDescription().getFullName());
|
||||
plugin.onLoad();
|
||||
} catch (Throwable ex) {
|
||||
Messaging.severe(ex.getMessage() + " initializing " + plugin.getDescription().getFullName());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startMetrics() {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(Citizens.this);
|
||||
if (metrics.isOptOut())
|
||||
return;
|
||||
metrics.addCustomData(new Metrics.Plotter("Total NPCs") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return Iterables.size(npcRegistry);
|
||||
}
|
||||
});
|
||||
|
||||
traitFactory.addPlotters(metrics.createGraph("traits"));
|
||||
metrics.start();
|
||||
Messaging.log("Metrics started.");
|
||||
} catch (IOException e) {
|
||||
Messaging.logF("Unable to start metrics: %s.", e.getMessage());
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
commands.setInjector(new Injector(this));
|
||||
|
||||
@ -340,6 +315,31 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
Messaging.logF("Save method set to %s.", saves.toString());
|
||||
}
|
||||
|
||||
private void startMetrics() {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(Citizens.this);
|
||||
if (metrics.isOptOut())
|
||||
return;
|
||||
metrics.addCustomData(new Metrics.Plotter("Total NPCs") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return Iterables.size(npcRegistry);
|
||||
}
|
||||
});
|
||||
|
||||
traitFactory.addPlotters(metrics.createGraph("traits"));
|
||||
metrics.start();
|
||||
Messaging.log("Metrics started.");
|
||||
} catch (IOException e) {
|
||||
Messaging.logF("Unable to start metrics: %s.", e.getMessage());
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private boolean suggestClosestModifier(CommandSender sender, String command, String modifier) {
|
||||
int minDist = Integer.MAX_VALUE;
|
||||
String closest = "";
|
||||
|
@ -69,10 +69,10 @@ public class Settings {
|
||||
SERVER_OWNS_NPCS("npc.server-ownership", false),
|
||||
STORAGE_FILE("storage.file", "saves.yml"),
|
||||
STORAGE_TYPE("storage.type", "yaml"),
|
||||
SUBPLUGIN_FOLDER("subplugins.folder", "plugins"),
|
||||
TALK_CLOSE_MAXIMUM_COOLDOWN("npc.text.max-talk-cooldown", 60),
|
||||
TALK_CLOSE_MINIMUM_COOLDOWN("npc.text.min-talk-cooldown", 30),
|
||||
TALK_ITEM("npc.text.talk-item", "340"),
|
||||
SUBPLUGIN_FOLDER("subplugins.folder", "plugins");
|
||||
TALK_ITEM("npc.text.talk-item", "340");
|
||||
|
||||
protected String path;
|
||||
protected Object value;
|
||||
|
@ -140,6 +140,7 @@ public abstract class CitizensNPC extends AbstractNPC {
|
||||
public void update() {
|
||||
try {
|
||||
super.update();
|
||||
if (isSpawned())
|
||||
navigator.update();
|
||||
} catch (Exception ex) {
|
||||
Messaging.logF("Exception while updating %d: %s.", getId(), ex.getMessage());
|
||||
|
@ -20,25 +20,15 @@ import org.bukkit.entity.LivingEntity;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class CitizensNavigator implements Navigator {
|
||||
private PathStrategy executing;
|
||||
private final CitizensNPC npc;
|
||||
private float speed;
|
||||
private PathStrategy executing;
|
||||
|
||||
public CitizensNavigator(CitizensNPC npc) {
|
||||
this.npc = npc;
|
||||
this.speed = getSpeedFor(npc.getHandle());
|
||||
}
|
||||
|
||||
public void update() {
|
||||
if (executing == null)
|
||||
return;
|
||||
boolean finished = executing.update();
|
||||
if (finished) {
|
||||
Bukkit.getPluginManager().callEvent(new NavigationCompleteEvent(this));
|
||||
executing = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelNavigation() {
|
||||
if (executing != null) {
|
||||
@ -47,14 +37,33 @@ public class CitizensNavigator implements Navigator {
|
||||
executing = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTarget getEntityTarget() {
|
||||
return executing instanceof EntityTarget ? (EntityTarget) executing : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityTarget getEntityTarget() {
|
||||
return executing instanceof EntityTarget ? (EntityTarget) executing : null;
|
||||
private float getSpeedFor(EntityLiving from) {
|
||||
EntityType entityType = from.getBukkitEntity().getType();
|
||||
Float cached = MOVEMENT_SPEEDS.get(entityType);
|
||||
if (cached != null)
|
||||
return cached;
|
||||
if (SPEED_FIELD == null) {
|
||||
MOVEMENT_SPEEDS.put(entityType, DEFAULT_SPEED);
|
||||
return DEFAULT_SPEED;
|
||||
}
|
||||
try {
|
||||
float speed = SPEED_FIELD.getFloat(from);
|
||||
MOVEMENT_SPEEDS.put(entityType, speed);
|
||||
return speed;
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
return DEFAULT_SPEED;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,6 +92,12 @@ public class CitizensNavigator implements Navigator {
|
||||
switchStrategyTo(newStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(Location target) {
|
||||
PathStrategy newStrategy = new MCNavigationStrategy(npc, target, speed);
|
||||
switchStrategyTo(newStrategy);
|
||||
}
|
||||
|
||||
private void switchStrategyTo(PathStrategy newStrategy) {
|
||||
if (executing != null)
|
||||
Bukkit.getPluginManager().callEvent(new NavigationReplaceEvent(this));
|
||||
@ -92,28 +107,13 @@ public class CitizensNavigator implements Navigator {
|
||||
Bukkit.getPluginManager().callEvent(new NavigationBeginEvent(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTarget(Location target) {
|
||||
PathStrategy newStrategy = new MCNavigationStrategy(npc, target, speed);
|
||||
switchStrategyTo(newStrategy);
|
||||
}
|
||||
|
||||
private float getSpeedFor(EntityLiving from) {
|
||||
EntityType entityType = from.getBukkitEntity().getType();
|
||||
Float cached = MOVEMENT_SPEEDS.get(entityType);
|
||||
if (cached != null)
|
||||
return cached;
|
||||
if (SPEED_FIELD == null) {
|
||||
MOVEMENT_SPEEDS.put(entityType, DEFAULT_SPEED);
|
||||
return DEFAULT_SPEED;
|
||||
}
|
||||
try {
|
||||
float speed = SPEED_FIELD.getFloat(from);
|
||||
MOVEMENT_SPEEDS.put(entityType, speed);
|
||||
return speed;
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
return DEFAULT_SPEED;
|
||||
public void update() {
|
||||
if (executing == null)
|
||||
return;
|
||||
boolean finished = executing.update();
|
||||
if (finished) {
|
||||
Bukkit.getPluginManager().callEvent(new NavigationCompleteEvent(this));
|
||||
executing = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,6 @@ public class MCNavigationStrategy implements PathStrategy {
|
||||
navigation = entity.al();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return navigation.e();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getTargetAsLocation() {
|
||||
return target;
|
||||
@ -48,4 +43,9 @@ public class MCNavigationStrategy implements PathStrategy {
|
||||
public TargetType getTargetType() {
|
||||
return TargetType.LOCATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
return navigation.e();
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,26 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
return handle.getBukkitEntity().getLocation().distanceSquared(target.getBukkitEntity().getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getTarget() {
|
||||
return (LivingEntity) target.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getTargetAsLocation() {
|
||||
return getTarget().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetType getTargetType() {
|
||||
return TargetType.ENTITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAggressive() {
|
||||
return aggro;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update() {
|
||||
if (target == null || target.dead)
|
||||
@ -57,24 +77,4 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
}
|
||||
|
||||
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
|
||||
|
||||
@Override
|
||||
public LivingEntity getTarget() {
|
||||
return (LivingEntity) target.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAggressive() {
|
||||
return aggro;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getTargetAsLocation() {
|
||||
return getTarget().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetType getTargetType() {
|
||||
return TargetType.ENTITY;
|
||||
}
|
||||
}
|
@ -5,9 +5,9 @@ import net.citizensnpcs.api.ai.TargetType;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public interface PathStrategy {
|
||||
boolean update();
|
||||
|
||||
Location getTargetAsLocation();
|
||||
|
||||
TargetType getTargetType();
|
||||
|
||||
boolean update();
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
@ -49,11 +55,5 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,12 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -43,11 +49,5 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
|
||||
super.z_();
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensChickenNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensChickenNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensCowNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensCowNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,12 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
|
||||
super.a(entityweatherlighting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -55,11 +61,5 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,12 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
@ -51,11 +57,5 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -75,6 +75,12 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc == null)
|
||||
@ -93,11 +99,5 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensGhastNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
@ -49,11 +55,5 @@ public class CitizensGhastNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,12 @@ public class CitizensGiantNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
npc.update();
|
||||
@ -42,11 +48,5 @@ public class CitizensGiantNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,12 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -44,11 +50,5 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -38,6 +38,12 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
@ -50,11 +56,5 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -70,6 +70,12 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
|
||||
super.a(entityweatherlighting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -81,11 +87,5 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
@ -49,11 +55,5 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -75,6 +75,12 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -86,11 +92,5 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -38,6 +38,12 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -49,11 +55,5 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,12 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -43,11 +49,5 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
|
||||
super.z_();
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensSquidNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d_() {
|
||||
if (npc != null)
|
||||
@ -49,11 +55,5 @@ public class CitizensSquidNPC extends CitizensMobNPC {
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensWolfNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensWolfNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -37,6 +37,12 @@ public class CitizensZombieNPC extends CitizensMobNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
@ -48,11 +54,5 @@ public class CitizensZombieNPC extends CitizensMobNPC {
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
||||
}
|
@ -42,6 +42,12 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void F_() {
|
||||
super.F_();
|
||||
@ -81,10 +87,4 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
a(aW, aX);
|
||||
X = yaw; // TODO: this looks jerky
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b_(double x, double y, double z) {
|
||||
// when another entity collides, b_ is called to push the NPC
|
||||
// so we prevent b_ from doing anything.
|
||||
}
|
||||
}
|
@ -56,6 +56,11 @@ public class Behaviour extends Trait {
|
||||
addScripts(Splitter.on(",").split(scripts));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove() {
|
||||
removeGoals();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
for (Entry<Goal, Integer> entry : addedGoals.entrySet()) {
|
||||
@ -63,11 +68,6 @@ public class Behaviour extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove() {
|
||||
removeGoals();
|
||||
}
|
||||
|
||||
private void removeGoals() {
|
||||
for (Goal entry : addedGoals.keySet()) {
|
||||
npc.getDefaultGoalController().removeGoal(entry);
|
||||
|
@ -22,6 +22,12 @@ public class Saddle extends Trait implements Toggleable {
|
||||
saddle = key.getBoolean("");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (pig && npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked())))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (npc.getBukkitEntity() instanceof Pig) {
|
||||
@ -31,12 +37,6 @@ public class Saddle extends Trait implements Toggleable {
|
||||
pig = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (pig && npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getRightClicked())))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DataKey key) {
|
||||
key.setBoolean("", saddle);
|
||||
|
@ -21,17 +21,17 @@ public class Sheared extends Trait implements Toggleable {
|
||||
sheared = key.getBoolean("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
((Sheep) npc.getBukkitEntity()).setSheared(sheared);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShearEntityEvent(PlayerShearEntityEvent event) {
|
||||
if (npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getEntity())))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
((Sheep) npc.getBukkitEntity()).setSheared(sheared);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DataKey key) {
|
||||
key.setBoolean("", sheared);
|
||||
|
@ -27,6 +27,12 @@ public class WoolColor extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSheepDyeWool(SheepDyeWoolEvent event) {
|
||||
if (npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getEntity())))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (npc.getBukkitEntity() instanceof Sheep) {
|
||||
@ -36,12 +42,6 @@ public class WoolColor extends Trait {
|
||||
sheep = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSheepDyeWool(SheepDyeWoolEvent event) {
|
||||
if (npc.equals(CitizensAPI.getNPCRegistry().getNPC(event.getEntity())))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DataKey key) {
|
||||
key.setString("", color.name());
|
||||
|
@ -95,12 +95,6 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
||||
randomTalker = key.getBoolean("random-talker");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (text.isEmpty())
|
||||
populateDefaultText();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRightClick(NPCRightClickEvent event) {
|
||||
if (!event.getNPC().equals(npc))
|
||||
@ -109,6 +103,12 @@ public class Text extends Trait implements Runnable, Toggleable, Listener, Conve
|
||||
sendText(event.getClicker());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (text.isEmpty())
|
||||
populateDefaultText();
|
||||
}
|
||||
|
||||
private void populateDefaultText() {
|
||||
text.addAll(Setting.DEFAULT_TEXT.asList());
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package net.citizensnpcs.trait.waypoint;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.citizensnpcs.api.ai.Goal;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
import net.citizensnpcs.editor.Editor;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
@ -20,7 +22,7 @@ import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoint> {
|
||||
private final PassiveWaypointCycler cycler = new PassiveWaypointCycler(this);
|
||||
private WaypointGoal currentGoal;
|
||||
private final List<Waypoint> waypoints = Lists.newArrayList();
|
||||
|
||||
@Override
|
||||
@ -67,7 +69,7 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
|
||||
"<e>Removed<a> a waypoint (<e>%d<a> remaining) (<e>%d<a>)", waypoints.size(),
|
||||
editingSlot + 1));
|
||||
}
|
||||
cycler.onProviderChanged();
|
||||
currentGoal.onProviderChanged();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -98,6 +100,13 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Goal getGoal(NPC npc) {
|
||||
if (currentGoal == null)
|
||||
currentGoal = new WaypointGoal(this, npc.getNavigator());
|
||||
return currentGoal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Waypoint> iterator() {
|
||||
return waypoints.iterator();
|
||||
@ -113,11 +122,6 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
cycler.onProviderChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(DataKey key) {
|
||||
key.removeKey("points");
|
||||
|
@ -1,75 +0,0 @@
|
||||
package net.citizensnpcs.trait.waypoint;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class PassiveWaypointCycler {
|
||||
private Location dest;
|
||||
private boolean executing;
|
||||
private Iterator<Waypoint> itr;
|
||||
|
||||
private final Iterable<Waypoint> provider;
|
||||
|
||||
public PassiveWaypointCycler(Iterable<Waypoint> provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
private void ensureItr() {
|
||||
if (itr == null || !itr.hasNext()) {
|
||||
itr = provider.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public boolean onCancel(AI ai, CancelReason reason) {
|
||||
if (hackfix) {
|
||||
hackfix = false;
|
||||
return false;
|
||||
}
|
||||
hackfix = false;
|
||||
if (executing && reason == CancelReason.REPLACE) {
|
||||
executing = false;
|
||||
return false;
|
||||
}
|
||||
executing = true;
|
||||
ensureItr();
|
||||
if (dest == null && itr.hasNext())
|
||||
dest = itr.next().getLocation();
|
||||
if (dest != null) {
|
||||
hackfix = true;
|
||||
ai.setDestination(dest);
|
||||
hackfix = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCompletion(AI ai) {
|
||||
if (executing) { // if we're executing, we need to get the next waypoint
|
||||
ensureItr();
|
||||
dest = itr.hasNext() ? itr.next().getLocation() : null;
|
||||
} else {
|
||||
executing = true;
|
||||
// we're free to return to our waypoints!
|
||||
// if we had a destination, we will return to it.
|
||||
}
|
||||
if (dest != null) {
|
||||
ai.setDestination(dest);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onProviderChanged() {
|
||||
itr = provider.iterator();
|
||||
if (ai == null)
|
||||
return;
|
||||
dest = itr.hasNext() ? itr.next().getLocation() : null;
|
||||
if (dest != null) {
|
||||
ai.setDestination(dest);
|
||||
}
|
||||
}*/
|
||||
|
||||
public void onProviderChanged() {
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package net.citizensnpcs.trait.waypoint;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.citizensnpcs.api.ai.Goal;
|
||||
import net.citizensnpcs.api.ai.GoalSelector;
|
||||
import net.citizensnpcs.api.ai.Navigator;
|
||||
import net.citizensnpcs.api.ai.event.NavigationCancelEvent;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class WaypointGoal implements Goal {
|
||||
private Location currentDestination;
|
||||
private Iterator<Waypoint> itr;
|
||||
private final Navigator navigator;
|
||||
private final Iterable<Waypoint> provider;
|
||||
private GoalSelector selector;
|
||||
|
||||
public WaypointGoal(Iterable<Waypoint> provider, Navigator navigator) {
|
||||
this.provider = provider;
|
||||
this.navigator = navigator;
|
||||
}
|
||||
|
||||
private void ensureItr() {
|
||||
if (itr == null || !itr.hasNext()) {
|
||||
itr = provider.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNavigationCancel(NavigationCancelEvent event) {
|
||||
if (!event.getNavigator().equals(navigator) || currentDestination == null)
|
||||
return;
|
||||
if (currentDestination.equals(event.getNavigator().getTargetAsLocation()))
|
||||
selector.finish();
|
||||
}
|
||||
|
||||
public void onProviderChanged() {
|
||||
itr = provider.iterator();
|
||||
if (currentDestination != null)
|
||||
selector.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
currentDestination = null;
|
||||
selector = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute(GoalSelector selector) {
|
||||
ensureItr();
|
||||
boolean shouldExecute = itr.hasNext();
|
||||
if (shouldExecute) {
|
||||
this.selector = selector;
|
||||
currentDestination = itr.next().getLocation();
|
||||
navigator.setTarget(currentDestination);
|
||||
}
|
||||
return shouldExecute;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package net.citizensnpcs.trait.waypoint;
|
||||
|
||||
import net.citizensnpcs.api.ai.Goal;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
import net.citizensnpcs.editor.Editor;
|
||||
|
||||
@ -16,6 +18,14 @@ public interface WaypointProvider {
|
||||
*/
|
||||
public Editor createEditor(Player player);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param npc
|
||||
* The attached {@link NPC} the goal is for.
|
||||
* @return The {@link Goal} to attach to the NPC.
|
||||
*/
|
||||
public Goal getGoal(NPC npc);
|
||||
|
||||
/**
|
||||
* Loads from the specified {@link DataKey}.
|
||||
*
|
||||
@ -24,12 +34,6 @@ public interface WaypointProvider {
|
||||
*/
|
||||
public void load(DataKey key);
|
||||
|
||||
/**
|
||||
* Called when the NPC attached to this provider's {@link Waypoints} is
|
||||
* spawned.
|
||||
*/
|
||||
public void onSpawn();
|
||||
|
||||
/**
|
||||
* Saves to the specified {@link DataKey}.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.citizensnpcs.api.ai.Goal;
|
||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
@ -50,8 +51,10 @@ public class Waypoints extends Trait {
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (provider != null)
|
||||
provider.onSpawn();
|
||||
if (provider != null) {
|
||||
Goal goal = provider.getGoal(getNPC());
|
||||
getNPC().getDefaultGoalController().addGoal(goal, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user