mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 20:55:44 +01:00
disallow names greater than 16 characters in length as per vanilla spec
This commit is contained in:
parent
8a63d0950e
commit
97b6a74c68
@ -32,8 +32,13 @@ public class NPCCommands {
|
|||||||
this.characterManager = characterManager;
|
this.characterManager = characterManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "create [name] [type] (character)", desc = "Create a new NPC",
|
@Command(
|
||||||
modifiers = { "create" }, min = 3, max = 4)
|
aliases = { "npc" },
|
||||||
|
usage = "create [name] [type] (character)",
|
||||||
|
desc = "Create a new NPC",
|
||||||
|
modifiers = { "create" },
|
||||||
|
min = 3,
|
||||||
|
max = 4)
|
||||||
@Permission("npc.create")
|
@Permission("npc.create")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void createNPC(CommandContext args, Player player, NPC npc) {
|
public void createNPC(CommandContext args, Player player, NPC npc) {
|
||||||
@ -44,7 +49,12 @@ public class NPCCommands {
|
|||||||
Messaging.sendError(player, "'" + args.getString(2) + "' is not a valid mob type. Using default NPC.");
|
Messaging.sendError(player, "'" + args.getString(2) + "' is not a valid mob type. Using default NPC.");
|
||||||
}
|
}
|
||||||
|
|
||||||
NPC create = npcManager.createNPC(type, args.getString(1));
|
String name = args.getString(1);
|
||||||
|
if (args.getString(1).length() > 16) {
|
||||||
|
Messaging.sendError(player, "NPC names cannot be longer than 16 characters. The name has been shortened.");
|
||||||
|
name = name.substring(0, 15);
|
||||||
|
}
|
||||||
|
NPC create = npcManager.createNPC(type, name);
|
||||||
String successMsg = ChatColor.GREEN + "You created " + StringHelper.wrap(create.getName());
|
String successMsg = ChatColor.GREEN + "You created " + StringHelper.wrap(create.getName());
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
if (args.argsLength() == 4) {
|
if (args.argsLength() == 4) {
|
||||||
@ -72,7 +82,12 @@ public class NPCCommands {
|
|||||||
Messaging.send(player, successMsg);
|
Messaging.send(player, successMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "despawn", desc = "Despawn an NPC", modifiers = { "despawn" }, min = 1,
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "despawn",
|
||||||
|
desc = "Despawn an NPC",
|
||||||
|
modifiers = { "despawn" },
|
||||||
|
min = 1,
|
||||||
max = 1)
|
max = 1)
|
||||||
@Permission("npc.despawn")
|
@Permission("npc.despawn")
|
||||||
public void despawnNPC(CommandContext args, Player player, NPC npc) {
|
public void despawnNPC(CommandContext args, Player player, NPC npc) {
|
||||||
@ -81,7 +96,12 @@ public class NPCCommands {
|
|||||||
Messaging.send(player, ChatColor.GREEN + "You despawned " + StringHelper.wrap(npc.getName()) + ".");
|
Messaging.send(player, ChatColor.GREEN + "You despawned " + StringHelper.wrap(npc.getName()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "select [id]", desc = "Select an NPC", modifiers = { "select" }, min = 2,
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "select [id]",
|
||||||
|
desc = "Select an NPC",
|
||||||
|
modifiers = { "select" },
|
||||||
|
min = 2,
|
||||||
max = 2)
|
max = 2)
|
||||||
@Permission("npc.select")
|
@Permission("npc.select")
|
||||||
@Requirements(ownership = true)
|
@Requirements(ownership = true)
|
||||||
@ -99,8 +119,13 @@ public class NPCCommands {
|
|||||||
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), toSelect);
|
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), toSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "spawn [id]", desc = "Spawn an existing NPC", modifiers = { "spawn" },
|
@Command(
|
||||||
min = 2, max = 2)
|
aliases = { "npc" },
|
||||||
|
usage = "spawn [id]",
|
||||||
|
desc = "Spawn an existing NPC",
|
||||||
|
modifiers = { "spawn" },
|
||||||
|
min = 2,
|
||||||
|
max = 2)
|
||||||
@Permission("npc.spawn")
|
@Permission("npc.spawn")
|
||||||
@Requirements
|
@Requirements
|
||||||
public void spawnNPC(CommandContext args, Player player, NPC npc) {
|
public void spawnNPC(CommandContext args, Player player, NPC npc) {
|
||||||
@ -127,15 +152,25 @@ public class NPCCommands {
|
|||||||
+ " is already spawned at another location. Use '/npc tphere' to teleport the NPC to your location.");
|
+ " is already spawned at another location. Use '/npc tphere' to teleport the NPC to your location.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport an NPC to your location",
|
@Command(
|
||||||
modifiers = { "tphere" }, min = 1, max = 1)
|
aliases = { "npc" },
|
||||||
|
usage = "tphere",
|
||||||
|
desc = "Teleport an NPC to your location",
|
||||||
|
modifiers = { "tphere" },
|
||||||
|
min = 1,
|
||||||
|
max = 1)
|
||||||
@Permission("npc.tphere")
|
@Permission("npc.tphere")
|
||||||
public void teleportNPCToPlayer(CommandContext args, Player player, NPC npc) {
|
public void teleportNPCToPlayer(CommandContext args, Player player, NPC npc) {
|
||||||
npc.getBukkitEntity().teleport(player, TeleportCause.COMMAND);
|
npc.getBukkitEntity().teleport(player, TeleportCause.COMMAND);
|
||||||
Messaging.send(player, StringHelper.wrap(npc.getName()) + " was teleported to your location.");
|
Messaging.send(player, StringHelper.wrap(npc.getName()) + " was teleported to your location.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(aliases = { "npc" }, usage = "tp", desc = "Teleport to an NPC", modifiers = { "tp", "teleport" }, min = 1,
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "tp",
|
||||||
|
desc = "Teleport to an NPC",
|
||||||
|
modifiers = { "tp", "teleport" },
|
||||||
|
min = 1,
|
||||||
max = 1)
|
max = 1)
|
||||||
@Permission("npc.tp")
|
@Permission("npc.tp")
|
||||||
public void teleportToNPC(CommandContext args, Player player, NPC npc) {
|
public void teleportToNPC(CommandContext args, Player player, NPC npc) {
|
||||||
|
@ -12,11 +12,13 @@ import org.bukkit.inventory.Inventory;
|
|||||||
public class NPCInventory implements IInventory {
|
public class NPCInventory implements IInventory {
|
||||||
private final int size = 36;
|
private final int size = 36;
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
private final String name;
|
||||||
private final ItemStack[] contents;
|
private final ItemStack[] contents;
|
||||||
private final Inventory inventory = new CraftInventory(this);
|
private final Inventory inventory = new CraftInventory(this);
|
||||||
|
|
||||||
public NPCInventory(CitizensNPC npc) {
|
public NPCInventory(CitizensNPC npc) {
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
|
name = npc.getName();
|
||||||
contents = new ItemStack[size];
|
contents = new ItemStack[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ public class NPCInventory implements IInventory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Inventory";
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user