Fix build

This commit is contained in:
fullwall 2012-12-17 23:19:06 +08:00
parent abe81c3e16
commit 8615b515c8
7 changed files with 21 additions and 24 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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());
}
}

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.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;
}

View File

@ -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<? extends Controller> clazz = controllerTypes.get(type);
Class<? extends MovementController> clazz = controllerTypes.get(type);
if (clazz == null) {
controller = new GroundController();
return;
}
Constructor<? extends Controller> innerConstructor = null;
Constructor<? extends MovementController> 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<EntityType, Class<? extends Controller>> controllerTypes = Maps
private static final Map<EntityType, Class<? extends MovementController>> controllerTypes = Maps
.newEnumMap(EntityType.class);
static {

View File

@ -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<WaypointTrigger> {
@Override
public Object create(DataKey root) {
public WaypointTrigger create(DataKey root) {
String type = root.getString("type");
Class<? extends WaypointTrigger> 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);
}