diff --git a/src/main/java/net/citizensnpcs/commands/NPCCommands.java b/src/main/java/net/citizensnpcs/commands/NPCCommands.java index e85e83847..e6dab35ad 100644 --- a/src/main/java/net/citizensnpcs/commands/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/commands/NPCCommands.java @@ -289,12 +289,12 @@ public class NPCCommands { permission = "citizens.npc.create") @Requirements public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException { - String name = Colorizer.parseColors(args.getJoinedStrings(1)); + String name = Colorizer.parseColors(args.getJoinedStrings(1).trim()); if (name.length() > 16) { Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG); name = name.substring(0, 16); } - if (name.length() <= 0) + if (name.length() == 0) throw new CommandException(); EntityType type = EntityType.PLAYER; diff --git a/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java b/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java index 5ae295b11..9fed0936b 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java +++ b/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java @@ -110,7 +110,6 @@ public class CitizensNavigator implements Navigator, Runnable { if (defaultParams.baseSpeed() == UNINITIALISED_SPEED) { defaultParams.baseSpeed(NMS.getSpeedFor(npc)); } - NMS.setSpeed(npc.getEntity(), defaultParams.speedModifier()); updatePathfindingRange(); } diff --git a/src/main/java/net/citizensnpcs/util/NMS.java b/src/main/java/net/citizensnpcs/util/NMS.java index 1beff34e0..9b76f33ae 100644 --- a/src/main/java/net/citizensnpcs/util/NMS.java +++ b/src/main/java/net/citizensnpcs/util/NMS.java @@ -213,12 +213,12 @@ public class NMS { } public static float getSpeedFor(NPC npc) { - if (!npc.isSpawned()) + if (!npc.isSpawned() || !(npc instanceof LivingEntity)) return DEFAULT_SPEED; // this is correct, but too slow. TODO: investigate - // return (float) - // NMS.getHandle(npc.getBukkitEntity()).getAttributeInstance(GenericAttributes.d).getValue(); - return DEFAULT_SPEED; + return (float) ((EntityLiving) NMS.getHandle(npc.getEntity())).getAttributeInstance(GenericAttributes.d) + .getValue(); + // return DEFAULT_SPEED; } public static void initNetworkManager(NetworkManager network) { @@ -381,13 +381,6 @@ public class NMS { } } - public static void setSpeed(org.bukkit.entity.Entity entity, float speedModifier) { - if (!(entity instanceof LivingEntity)) - return; - EntityLiving handle = NMS.getHandle((LivingEntity) entity); - handle.getAttributeInstance(GenericAttributes.d).setValue(speedModifier); - } - public static void setStepHeight(EntityLiving entity, float height) { entity.X = height; }