Skip to content

Commit

Permalink
add /npc nameplate command
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 16, 2013
1 parent 781779a commit 5b8b49c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,22 @@ public void moveto(CommandContext args, CommandSender sender, NPC npc) throws Co
}

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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
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;

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) {
Expand All @@ -37,8 +41,6 @@ public boolean isPaused() {

@Override
public void load(DataKey key) {
xrange = key.getInt("xrange", DEFAULT_XRANGE);
yrange = key.getInt("yrange", DEFAULT_YRANGE);
}

@Override
Expand All @@ -52,8 +54,6 @@ public void onSpawn(NPC npc) {

@Override
public void save(DataKey key) {
key.setInt("xrange", xrange);
key.setInt("yrange", yrange);
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/citizensnpcs/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down

0 comments on commit 5b8b49c

Please sign in to comment.