mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-27 13:15:33 +01:00
Allow mobs to have name length 64
This commit is contained in:
parent
22759739f1
commit
4b5100b9ce
@ -265,7 +265,7 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
|
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
|
||||||
: new CommandSenderCreateNPCEvent(sender, copy);
|
: new CommandSenderCreateNPCEvent(sender, copy);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.getNPC().destroy();
|
event.getNPC().destroy();
|
||||||
@ -290,9 +290,10 @@ public class NPCCommands {
|
|||||||
@Requirements
|
@Requirements
|
||||||
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void create(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
String name = Colorizer.parseColors(args.getJoinedStrings(1).trim());
|
String name = Colorizer.parseColors(args.getJoinedStrings(1).trim());
|
||||||
if (name.length() > 16) {
|
int nameLength = npc.getTrait(MobType.class).getType() == EntityType.PLAYER ? 16 : 64;
|
||||||
|
if (name.length() > nameLength) {
|
||||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
|
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
|
||||||
name = name.substring(0, 16);
|
name = name.substring(0, nameLength);
|
||||||
}
|
}
|
||||||
if (name.length() == 0)
|
if (name.length() == 0)
|
||||||
throw new CommandException();
|
throw new CommandException();
|
||||||
@ -337,7 +338,7 @@ public class NPCCommands {
|
|||||||
spawnLoc = args.getSenderLocation();
|
spawnLoc = args.getSenderLocation();
|
||||||
}
|
}
|
||||||
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
|
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
|
||||||
: new CommandSenderCreateNPCEvent(sender, npc);
|
: new CommandSenderCreateNPCEvent(sender, npc);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
npc.destroy();
|
npc.destroy();
|
||||||
@ -1009,7 +1010,7 @@ public class NPCCommands {
|
|||||||
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
|
||||||
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
public void power(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
Messaging
|
Messaging
|
||||||
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -1069,9 +1070,10 @@ public class NPCCommands {
|
|||||||
public void rename(CommandContext args, CommandSender sender, NPC npc) {
|
public void rename(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
String oldName = npc.getName();
|
String oldName = npc.getName();
|
||||||
String newName = Colorizer.parseColors(args.getJoinedStrings(1));
|
String newName = Colorizer.parseColors(args.getJoinedStrings(1));
|
||||||
if (newName.length() > 16) {
|
int nameLength = npc.getTrait(MobType.class).getType() == EntityType.PLAYER ? 16 : 64;
|
||||||
|
if (newName.length() > nameLength) {
|
||||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
|
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG);
|
||||||
newName = newName.substring(0, 15);
|
newName = newName.substring(0, nameLength);
|
||||||
}
|
}
|
||||||
Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
|
Location prev = npc.isSpawned() ? npc.getEntity().getLocation() : null;
|
||||||
npc.despawn(DespawnReason.PENDING_RESPAWN);
|
npc.despawn(DespawnReason.PENDING_RESPAWN);
|
||||||
|
Loading…
Reference in New Issue
Block a user