From 1dd695a14fb4698a2c5b4f01d03d784e66b48b1d Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 17 Dec 2012 23:19:06 +0800 Subject: [PATCH] Fix build --- .../citizensnpcs/command/command/NPCCommands.java | 4 ++-- .../command/command/TemplateCommands.java | 4 ++-- .../command/command/WaypointCommands.java | 2 +- .../java/net/citizensnpcs/npc/CitizensNPC.java | 3 +-- .../npc/ai/AStarNavigationStrategy.java | 12 +++++------- .../java/net/citizensnpcs/trait/Controllable.java | 14 +++++++------- .../waypoint/triggers/WaypointTriggerRegistry.java | 6 +++--- 7 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index 3c949a149..2a2a45cb5 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -190,7 +190,7 @@ public class NPCCommands { usage = "behaviour [scripts] (-r)", desc = "Sets the behaviour of a NPC", help = Messages.BEHAVIOUR_HELP, - modifiers = { "behaviour", "ai" }, + modifiers = { "behaviour", "behavior", "ai" }, flags = "r", min = 2, permission = "npc.behaviour") @@ -1002,7 +1002,7 @@ public class NPCCommands { @Command( aliases = { "npc" }, - usage = "type", + usage = "type [type]", desc = "Sets an NPC's entity type", modifiers = { "type" }, min = 2, diff --git a/src/main/java/net/citizensnpcs/command/command/TemplateCommands.java b/src/main/java/net/citizensnpcs/command/command/TemplateCommands.java index cbb642482..3bf21a373 100644 --- a/src/main/java/net/citizensnpcs/command/command/TemplateCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/TemplateCommands.java @@ -30,7 +30,7 @@ public class TemplateCommands { @Command( aliases = { "template", "tpl" }, - usage = "apply [name] (id id2...)", + usage = "apply [template name] (id id2...)", desc = "Applies a template to the selected NPC", modifiers = { "apply" }, min = 2, @@ -71,7 +71,7 @@ public class TemplateCommands { @Command( aliases = { "template", "tpl" }, - usage = "create [name] (-o)", + usage = "create [template name] (-o)", desc = "Creates a template from the selected NPC", modifiers = { "create" }, min = 2, diff --git a/src/main/java/net/citizensnpcs/command/command/WaypointCommands.java b/src/main/java/net/citizensnpcs/command/command/WaypointCommands.java index 08382662d..c48b7b00a 100644 --- a/src/main/java/net/citizensnpcs/command/command/WaypointCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/WaypointCommands.java @@ -34,7 +34,7 @@ public class WaypointCommands { @Command( aliases = { "waypoints", "waypoint", "wp" }, - usage = "provider (provider name) (-a)", + usage = "provider [provider name] (-a)", desc = "Sets the current waypoint provider", modifiers = { "provider" }, min = 1, diff --git a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java index e7bf6753a..e9b1801f5 100644 --- a/src/main/java/net/citizensnpcs/npc/CitizensNPC.java +++ b/src/main/java/net/citizensnpcs/npc/CitizensNPC.java @@ -11,7 +11,6 @@ import net.citizensnpcs.api.ai.Navigator; import net.citizensnpcs.api.event.DespawnReason; import net.citizensnpcs.api.event.NPCDespawnEvent; import net.citizensnpcs.api.event.NPCSpawnEvent; -import net.citizensnpcs.api.exception.NPCLoadException; import net.citizensnpcs.api.npc.AbstractNPC; import net.citizensnpcs.api.persistence.PersistenceLoader; import net.citizensnpcs.api.trait.Trait; @@ -135,7 +134,7 @@ public class CitizensNPC extends AbstractNPC { try { trait.load(traitKey); PersistenceLoader.load(trait, traitKey); - } catch (NPCLoadException ex) { + } catch (Throwable ex) { Messaging.logTr(Messages.TRAIT_LOAD_FAILED, traitKey.name(), getId()); } } diff --git a/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java index d0048360a..5f7b6debf 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java @@ -9,7 +9,6 @@ import net.citizensnpcs.api.astar.pathfinder.Path; import net.citizensnpcs.api.astar.pathfinder.VectorGoal; import net.citizensnpcs.api.astar.pathfinder.VectorNode; import net.citizensnpcs.api.npc.NPC; -import net.citizensnpcs.util.Messaging; import net.citizensnpcs.util.NMS; import net.minecraft.server.v1_4_5.EntityLiving; @@ -67,14 +66,13 @@ public class AStarNavigationStrategy extends AbstractPathStrategy { EntityLiving handle = NMS.getHandle(npc.getBukkitEntity()); double dX = vector.getBlockX() - handle.locX; double dZ = vector.getBlockZ() - handle.locZ; - double dY = vector.getY() - Math.floor(handle.boundingBox.b + 0.5D); - double dXdZ = dX * dX + dZ * dZ; - double distance = dXdZ + dY * dY; + double dY = vector.getY() - handle.locY; + double xzDistance = dX * dX + dZ * dZ; + 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()); - else - Messaging.log(distance >= 0.0001, dY > 0, dXdZ < 1, dXdZ); + } NMS.setDestination(npc.getBukkitEntity(), vector.getX(), vector.getY(), vector.getZ(), params.speed()); return false; } diff --git a/src/main/java/net/citizensnpcs/trait/Controllable.java b/src/main/java/net/citizensnpcs/trait/Controllable.java index c03887438..56ec5a1f1 100644 --- a/src/main/java/net/citizensnpcs/trait/Controllable.java +++ b/src/main/java/net/citizensnpcs/trait/Controllable.java @@ -29,7 +29,7 @@ import com.google.common.collect.Maps; //TODO: reduce reliance on CitizensNPC public class Controllable extends Trait implements Toggleable, CommandConfigurable { - private Controller controller = new GroundController(); + private MovementController controller = new GroundController(); @Persist private boolean enabled; private EntityType explicitType; @@ -80,12 +80,12 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab EntityType type = npc.getBukkitEntity().getType(); if (explicitType != null) type = explicitType; - Class clazz = controllerTypes.get(type); + Class clazz = controllerTypes.get(type); if (clazz == null) { controller = new GroundController(); return; } - Constructor innerConstructor = null; + Constructor innerConstructor = null; try { innerConstructor = clazz.getConstructor(Controllable.class); innerConstructor.setAccessible(true); @@ -169,7 +169,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab return enabled; } - public class AirController implements Controller { + public class AirController implements MovementController { boolean paused = false; @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 rightClick(PlayerInteractEvent event); @@ -212,7 +212,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab void run(Player rider); } - public class GroundController implements Controller { + public class GroundController implements MovementController { private void jump() { boolean allowed = getHandle().onGround; 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 Map> controllerTypes = Maps + private static final Map> controllerTypes = Maps .newEnumMap(EntityType.class); static { diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java index 15c138ea3..898e3f09a 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java @@ -11,16 +11,16 @@ import org.bukkit.conversations.Prompt; import com.google.common.base.Joiner; import com.google.common.collect.Maps; -public class WaypointTriggerRegistry implements Persister { +public class WaypointTriggerRegistry implements Persister { @Override - public Object create(DataKey root) { + public WaypointTrigger create(DataKey root) { String type = root.getString("type"); Class clazz = triggers.get(type); return clazz == null ? null : PersistenceLoader.load(clazz, root); } @Override - public void save(Object instance, DataKey root) { + public void save(WaypointTrigger instance, DataKey root) { PersistenceLoader.save(instance, root); }