diff --git a/README b/README index 6d6cf809b..3cd510898 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ Citizens is an NPC plugin for the Bukkit API. It was first released on March 5, provides an API itself, which developers can use to create their own NPC characters. Compatible With: --Bukkit 1.2.5-R1.0 --CitizensAPI 2.0 --CraftBukkit 1.2.5-R1.0 --Minecraft 1.2.5 \ No newline at end of file +-Bukkit 1.3.2 dev +-CitizensAPI 2.0.2 +-CraftBukkit 1.3.2 dev +-Minecraft 1.3.2 \ No newline at end of file diff --git a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java index 92ffe161e..2c6741cb8 100644 --- a/src/main/java/net/citizensnpcs/command/command/NPCCommands.java +++ b/src/main/java/net/citizensnpcs/command/command/NPCCommands.java @@ -34,11 +34,14 @@ import net.citizensnpcs.util.Paginator; import net.citizensnpcs.util.StringHelper; import net.citizensnpcs.util.Util; +import net.minecraft.server.EntityLiving; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; +import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.entity.Ageable; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; @@ -649,4 +652,38 @@ public class NPCCommands { Messaging.sendF(sender, ChatColor.GREEN + "%s is %s vulnerable.", StringHelper.wrap(npc.getName()), vulnerable ? "now" : "no longer"); } + + @Command( + aliases = { "npc" }, + usage = "position (-a)", + desc = "Changes NPC's head position", + flags = "a", + modifiers = { "position" }, + min = 1, + max = 2, + permission = "npc.position.assume") + @Requirements(selected = true, ownership = true, types = { EntityType.PLAYER }) + public void position(CommandContext args, CommandSender sender, NPC npc) throws CommandException { + + // Assume Player's position + if (args.hasFlag('a')) { + if (sender instanceof Player) { + if (!npc.isSpawned()) + npc.spawn(npc.getTrait(CurrentLocation.class).getLocation()); + + // Update entity with some NMS magic + EntityLiving handle = ((CraftLivingEntity) npc.getBukkitEntity()).getHandle(); + handle.yaw = (float) ((Player) sender).getLocation().getYaw(); + handle.pitch = (float) ((Player) sender).getLocation().getPitch(); + handle.as = handle.yaw; + + return; + } + + else + Messaging.sendF(sender, ChatColor.YELLOW + "This command can only be used by a Player in-game"); + } + + Messaging.sendF(sender, ChatColor.YELLOW + "Usage: '/npc position -a' to assume Player's head position"); + } } \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ac3d7b7a7..80d878c80 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -35,6 +35,7 @@ permissions: citizens.npc.*: children: citizens.npc.age: true + citizens.npc.position.assume: true citizens.npc.behaviour: true citizens.npc.create: true citizens.npc.controllable: true