This commit is contained in:
fullwall 2012-10-29 21:36:27 +08:00
parent b4373ccaa9
commit 5f15f0146d
4 changed files with 26 additions and 26 deletions

View File

@ -820,21 +820,6 @@ public class NPCCommands {
Messaging.sendTr(sender, Messages.NPC_RENAMED, oldName, newName);
}
@Command(
aliases = { "npc" },
usage = "skeletontype [type]",
desc = "Sets the NPC's skeleton type",
modifiers = { "skeletontype", "sktype" },
min = 2,
max = 2,
permission = "npc.skeletontype")
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) {
int type = args.getInteger(1);
npc.getTrait(SkeletonType.class).setType(type);
Messaging.sendTr(sender, Messages.SKELETON_TYPE_SET, npc.getName(), type);
}
@Command(
aliases = { "npc" },
usage = "select|sel [id|name] (--r range)",
@ -895,6 +880,21 @@ public class NPCCommands {
Messaging.sendWithNPC(sender, Setting.SELECTION_MESSAGE.asString(), toSelect);
}
@Command(
aliases = { "npc" },
usage = "skeletontype [type]",
desc = "Sets the NPC's skeleton type",
modifiers = { "skeletontype", "sktype" },
min = 2,
max = 2,
permission = "npc.skeletontype")
@Requirements(selected = true, ownership = true, types = EntityType.SKELETON)
public void skeletonType(CommandContext args, CommandSender sender, NPC npc) {
int type = args.getInteger(1);
npc.getTrait(SkeletonType.class).setType(type);
Messaging.sendTr(sender, Messages.SKELETON_TYPE_SET, npc.getName(), type);
}
@Command(
aliases = { "npc" },
usage = "size [size]",

View File

@ -6,18 +6,14 @@ import net.citizensnpcs.api.trait.Trait;
import org.bukkit.craftbukkit.entity.CraftSkeleton;
public class SkeletonType extends Trait {
private boolean skeleton;
@Persist
private int type = 0;
private boolean skeleton;
public SkeletonType() {
super("skeletontype");
}
public void setType(int type) {
this.type = Math.max(0, Math.min(1, type));
}
@Override
public void onSpawn() {
skeleton = npc.getBukkitEntity() instanceof CraftSkeleton;
@ -28,4 +24,8 @@ public class SkeletonType extends Trait {
if (skeleton)
((CraftSkeleton) npc.getBukkitEntity()).getHandle().setSkeletonType(type);
}
public void setType(int type) {
this.type = Math.max(0, Math.min(1, type));
}
}

View File

@ -125,6 +125,7 @@ public class Messages {
public static final String OWNER_SET = "citizens.commands.npc.owner.set";
public static final String OWNER_SET_SERVER = "citizens.commands.npc.owner.set-server";
public static final String PATHFINDING_RANGE_SET = "citizens.commands.npc.pathfindingrange.set";
public static final String PLAYER_NOT_FOUND_FOR_SPAWN = "citizens.commands.npc.create.no-player-for-spawn";
public static final String POSE_ADDED = "citizens.commands.npc.pose.added";
public static final String POSE_ALREADY_EXISTS = "citizens.commands.npc.pose.already-exists";
public static final String POSE_MISSING = "citizens.commands.npc.pose.missing";
@ -147,6 +148,7 @@ public class Messages {
public static final String SHEARED_STOPPED = "citizens.editors.equipment.sheared-stopped";
public static final String SIZE_DESCRIPTION = "citizens.commands.npc.size.description";
public static final String SIZE_SET = "citizens.commands.npc.size.set";
public static final String SKELETON_TYPE_SET = "citizens.commands.npc.skeletontype.set";
public static final String SKIPPING_BROKEN_TRAIT = "citizens.notifications.skipping-broken-trait";
public static final String SKIPPING_INVALID_ANCHOR = "citizens.notifications.skipping-invalid-anchor";
public static final String SKIPPING_INVALID_POSE = "citizens.notifications.skipping-invalid-pose";
@ -202,6 +204,4 @@ public class Messages {
public static final String WAYPOINT_TRIGGER_TELEPORT_PROMPT = "citizens.editors.waypoints.triggers.teleport.prompt";
public static final String WORLD_NOT_FOUND = "citizens.commands.errors.missing-world";
public static final String WRITING_DEFAULT_SETTING = "citizens.settings.writing-default";
public static final String SKELETON_TYPE_SET = "citizens.commands.npc.skeletontype.set";
public static final String PLAYER_NOT_FOUND_FOR_SPAWN = "citizens.commands.npc.create.no-player-for-spawn";
}

View File

@ -156,6 +156,10 @@ public class NMS {
throw new IllegalArgumentException("unable to find valid entity superclass");
}
public static void setHeadYaw(EntityLiving handle, float yaw) {
handle.ay = yaw;
}
public static void setLandSpeedModifier(EntityLiving handle, float speed) {
if (LAND_SPEED_MODIFIER_FIELD == null)
return;
@ -275,8 +279,4 @@ public class NMS {
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
}
}
public static void setHeadYaw(EntityLiving handle, float yaw) {
handle.ay = yaw;
}
}