Merge branch 'master' of github.com:CitizensDev/Citizens2

This commit is contained in:
fullwall 2012-09-28 17:56:47 +08:00
commit da723d47e8
3 changed files with 43 additions and 4 deletions

8
README
View File

@ -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
-Bukkit 1.3.2 dev
-CitizensAPI 2.0.2
-CraftBukkit 1.3.2 dev
-Minecraft 1.3.2

View File

@ -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,39 @@ 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) {
// Spawn the NPC if it isn't spawned to prevent NPEs
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");
}
}

View File

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