add /npc nameplate command

This commit is contained in:
fullwall 2013-03-16 15:06:04 +08:00
parent 482eb05766
commit 76b2bc3864
4 changed files with 20 additions and 6 deletions

View File

@ -647,10 +647,22 @@ public class NPCCommands {
}
npc.getBukkitEntity().teleport(to, TeleportCause.COMMAND);
Messaging.sendTr(sender, Messages.MOVETO_TELEPORTED, npc.getName(), to);
}
@Command(
aliases = { "npc" },
modifiers = "nameplate",
desc = "Toggle nameplate visibility",
min = 1,
max = 1,
permission = "citizens.npc.nameplate")
@Requirements(selected = true, ownership = true, excludedTypes = EntityType.PLAYER)
public void nameplate(CommandContext args, CommandSender sender, NPC npc) {
npc.getBukkitEntity().setCustomNameVisible(!npc.getBukkitEntity().isCustomNameVisible());
Messaging.sendTr(sender, Messages.NAMEPLATE_VISIBILITY_TOGGLED);
}
@Command(aliases = { "npc" }, desc = "Show basic NPC information", max = 0, permission = "citizens.npc.info")
public void npc(CommandContext args, CommandSender sender, NPC npc) {
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));

View File

@ -4,6 +4,7 @@ import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.Goal;
import net.citizensnpcs.api.ai.goals.WanderGoal;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.util.DataKey;
import org.bukkit.entity.Player;
@ -11,7 +12,10 @@ import org.bukkit.entity.Player;
public class WanderWaypointProvider implements WaypointProvider {
private Goal currentGoal;
private volatile boolean paused;
private int xrange = DEFAULT_XRANGE, yrange = DEFAULT_YRANGE;
@Persist
private final int xrange = DEFAULT_XRANGE;
@Persist
private final int yrange = DEFAULT_YRANGE;
@Override
public WaypointEditor createEditor(Player player) {
@ -37,8 +41,6 @@ public class WanderWaypointProvider implements WaypointProvider {
@Override
public void load(DataKey key) {
xrange = key.getInt("xrange", DEFAULT_XRANGE);
yrange = key.getInt("yrange", DEFAULT_YRANGE);
}
@Override
@ -52,8 +54,6 @@ public class WanderWaypointProvider implements WaypointProvider {
@Override
public void save(DataKey key) {
key.setInt("xrange", xrange);
key.setInt("yrange", yrange);
}
@Override

View File

@ -107,6 +107,7 @@ public class Messages {
public static final String MONEY_WITHDRAWN = "citizens.economy.money-withdrawn";
public static final String MOVETO_FORMAT = "citizens.commands.npc.moveto.format";
public static final String MOVETO_TELEPORTED = "citizens.commands.npc.moveto.teleported";
public static final String NAMEPLATE_VISIBILITY_TOGGLED = "citizens.commands.npc.nameplate.toggled";
public static final String NO_NPC_WITH_ID_FOUND = "citizens.commands.npc.spawn.missing-npc-id";
public static final String NO_STORED_SPAWN_LOCATION = "citizens.commands.npc.spawn.no-location";
public static final String NOT_LIVING_MOBTYPE = "citizens.commands.npc.create.not-living-mobtype";

View File

@ -45,6 +45,7 @@ citizens.commands.npc.lookclose.stopped=[[{0}]] will no longer rotate when playe
citizens.commands.npc.mount.failed=Couldn''t mount [[{0}]].
citizens.commands.npc.moveto.format=Format is x:y:z(:world) or x y z( world).
citizens.commands.npc.moveto.teleported=[[{0}]] teleported to {1}.
citizens.commands.npc.nameplate.toggled=Nameplate visibility toggled.
citizens.commands.npc.owner.already-owner={0} is already the owner of {1}.
citizens.commands.npc.owner.owner=[[{0}]]''s owner is [[{1}]].
citizens.commands.npc.owner.set-server=[[The server]] is now the owner of {0}.