Fix build

This commit is contained in:
fullwall 2012-12-17 23:19:06 +08:00
parent 910f806763
commit 1dd695a14f
7 changed files with 21 additions and 24 deletions

View File

@ -190,7 +190,7 @@ public class NPCCommands {
usage = "behaviour [scripts] (-r)", usage = "behaviour [scripts] (-r)",
desc = "Sets the behaviour of a NPC", desc = "Sets the behaviour of a NPC",
help = Messages.BEHAVIOUR_HELP, help = Messages.BEHAVIOUR_HELP,
modifiers = { "behaviour", "ai" }, modifiers = { "behaviour", "behavior", "ai" },
flags = "r", flags = "r",
min = 2, min = 2,
permission = "npc.behaviour") permission = "npc.behaviour")
@ -1002,7 +1002,7 @@ public class NPCCommands {
@Command( @Command(
aliases = { "npc" }, aliases = { "npc" },
usage = "type", usage = "type [type]",
desc = "Sets an NPC's entity type", desc = "Sets an NPC's entity type",
modifiers = { "type" }, modifiers = { "type" },
min = 2, min = 2,

View File

@ -30,7 +30,7 @@ public class TemplateCommands {
@Command( @Command(
aliases = { "template", "tpl" }, aliases = { "template", "tpl" },
usage = "apply [name] (id id2...)", usage = "apply [template name] (id id2...)",
desc = "Applies a template to the selected NPC", desc = "Applies a template to the selected NPC",
modifiers = { "apply" }, modifiers = { "apply" },
min = 2, min = 2,
@ -71,7 +71,7 @@ public class TemplateCommands {
@Command( @Command(
aliases = { "template", "tpl" }, aliases = { "template", "tpl" },
usage = "create [name] (-o)", usage = "create [template name] (-o)",
desc = "Creates a template from the selected NPC", desc = "Creates a template from the selected NPC",
modifiers = { "create" }, modifiers = { "create" },
min = 2, min = 2,

View File

@ -34,7 +34,7 @@ public class WaypointCommands {
@Command( @Command(
aliases = { "waypoints", "waypoint", "wp" }, aliases = { "waypoints", "waypoint", "wp" },
usage = "provider (provider name) (-a)", usage = "provider [provider name] (-a)",
desc = "Sets the current waypoint provider", desc = "Sets the current waypoint provider",
modifiers = { "provider" }, modifiers = { "provider" },
min = 1, min = 1,

View File

@ -11,7 +11,6 @@ import net.citizensnpcs.api.ai.Navigator;
import net.citizensnpcs.api.event.DespawnReason; import net.citizensnpcs.api.event.DespawnReason;
import net.citizensnpcs.api.event.NPCDespawnEvent; import net.citizensnpcs.api.event.NPCDespawnEvent;
import net.citizensnpcs.api.event.NPCSpawnEvent; import net.citizensnpcs.api.event.NPCSpawnEvent;
import net.citizensnpcs.api.exception.NPCLoadException;
import net.citizensnpcs.api.npc.AbstractNPC; import net.citizensnpcs.api.npc.AbstractNPC;
import net.citizensnpcs.api.persistence.PersistenceLoader; import net.citizensnpcs.api.persistence.PersistenceLoader;
import net.citizensnpcs.api.trait.Trait; import net.citizensnpcs.api.trait.Trait;
@ -135,7 +134,7 @@ public class CitizensNPC extends AbstractNPC {
try { try {
trait.load(traitKey); trait.load(traitKey);
PersistenceLoader.load(trait, traitKey); PersistenceLoader.load(trait, traitKey);
} catch (NPCLoadException ex) { } catch (Throwable ex) {
Messaging.logTr(Messages.TRAIT_LOAD_FAILED, traitKey.name(), getId()); Messaging.logTr(Messages.TRAIT_LOAD_FAILED, traitKey.name(), getId());
} }
} }

View File

@ -9,7 +9,6 @@ import net.citizensnpcs.api.astar.pathfinder.Path;
import net.citizensnpcs.api.astar.pathfinder.VectorGoal; import net.citizensnpcs.api.astar.pathfinder.VectorGoal;
import net.citizensnpcs.api.astar.pathfinder.VectorNode; import net.citizensnpcs.api.astar.pathfinder.VectorNode;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.util.Messaging;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.server.v1_4_5.EntityLiving; import net.minecraft.server.v1_4_5.EntityLiving;
@ -67,14 +66,13 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
EntityLiving handle = NMS.getHandle(npc.getBukkitEntity()); EntityLiving handle = NMS.getHandle(npc.getBukkitEntity());
double dX = vector.getBlockX() - handle.locX; double dX = vector.getBlockX() - handle.locX;
double dZ = vector.getBlockZ() - handle.locZ; double dZ = vector.getBlockZ() - handle.locZ;
double dY = vector.getY() - Math.floor(handle.boundingBox.b + 0.5D); double dY = vector.getY() - handle.locY;
double dXdZ = dX * dX + dZ * dZ; double xzDistance = dX * dX + dZ * dZ;
double distance = dXdZ + dY * dY; double distance = xzDistance + dY * dY;
if (distance >= 0.00001 && (dY > 0 && dXdZ <= 2.75)) if (distance >= 0.00001 && (dY > 0 && xzDistance <= 2.75)) {
NMS.setShouldJump(npc.getBukkitEntity()); NMS.setShouldJump(npc.getBukkitEntity());
else }
Messaging.log(distance >= 0.0001, dY > 0, dXdZ < 1, dXdZ);
NMS.setDestination(npc.getBukkitEntity(), vector.getX(), vector.getY(), vector.getZ(), params.speed()); NMS.setDestination(npc.getBukkitEntity(), vector.getX(), vector.getY(), vector.getZ(), params.speed());
return false; return false;
} }

View File

@ -29,7 +29,7 @@ import com.google.common.collect.Maps;
//TODO: reduce reliance on CitizensNPC //TODO: reduce reliance on CitizensNPC
public class Controllable extends Trait implements Toggleable, CommandConfigurable { public class Controllable extends Trait implements Toggleable, CommandConfigurable {
private Controller controller = new GroundController(); private MovementController controller = new GroundController();
@Persist @Persist
private boolean enabled; private boolean enabled;
private EntityType explicitType; private EntityType explicitType;
@ -80,12 +80,12 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
EntityType type = npc.getBukkitEntity().getType(); EntityType type = npc.getBukkitEntity().getType();
if (explicitType != null) if (explicitType != null)
type = explicitType; type = explicitType;
Class<? extends Controller> clazz = controllerTypes.get(type); Class<? extends MovementController> clazz = controllerTypes.get(type);
if (clazz == null) { if (clazz == null) {
controller = new GroundController(); controller = new GroundController();
return; return;
} }
Constructor<? extends Controller> innerConstructor = null; Constructor<? extends MovementController> innerConstructor = null;
try { try {
innerConstructor = clazz.getConstructor(Controllable.class); innerConstructor = clazz.getConstructor(Controllable.class);
innerConstructor.setAccessible(true); innerConstructor.setAccessible(true);
@ -169,7 +169,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
return enabled; return enabled;
} }
public class AirController implements Controller { public class AirController implements MovementController {
boolean paused = false; boolean paused = false;
@Override @Override
@ -202,7 +202,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
} }
} }
public static interface Controller { public static interface MovementController {
void leftClick(PlayerInteractEvent event); void leftClick(PlayerInteractEvent event);
void rightClick(PlayerInteractEvent event); void rightClick(PlayerInteractEvent event);
@ -212,7 +212,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
void run(Player rider); void run(Player rider);
} }
public class GroundController implements Controller { public class GroundController implements MovementController {
private void jump() { private void jump() {
boolean allowed = getHandle().onGround; boolean allowed = getHandle().onGround;
if (!allowed) if (!allowed)
@ -249,7 +249,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
private static final float JUMP_VELOCITY = 0.6F; private static final float JUMP_VELOCITY = 0.6F;
} }
private static final Map<EntityType, Class<? extends Controller>> controllerTypes = Maps private static final Map<EntityType, Class<? extends MovementController>> controllerTypes = Maps
.newEnumMap(EntityType.class); .newEnumMap(EntityType.class);
static { static {

View File

@ -11,16 +11,16 @@ import org.bukkit.conversations.Prompt;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
public class WaypointTriggerRegistry implements Persister { public class WaypointTriggerRegistry implements Persister<WaypointTrigger> {
@Override @Override
public Object create(DataKey root) { public WaypointTrigger create(DataKey root) {
String type = root.getString("type"); String type = root.getString("type");
Class<? extends WaypointTrigger> clazz = triggers.get(type); Class<? extends WaypointTrigger> clazz = triggers.get(type);
return clazz == null ? null : PersistenceLoader.load(clazz, root); return clazz == null ? null : PersistenceLoader.load(clazz, root);
} }
@Override @Override
public void save(Object instance, DataKey root) { public void save(WaypointTrigger instance, DataKey root) {
PersistenceLoader.save(instance, root); PersistenceLoader.save(instance, root);
} }