mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-27 09:42:37 +01:00
More sane highlight colour handling, be flexible with name length if placeholder immediately replaces
This commit is contained in:
parent
891b480bea
commit
372d209be1
@ -114,7 +114,7 @@ public class Settings {
|
||||
ENTITY_SPAWN_WAIT_TICKS("general.entity-spawn-wait-ticks", 20),
|
||||
ERROR_COLOUR("general.color-scheme.message-error", "<red>"),
|
||||
FOLLOW_ACROSS_WORLDS("npc.follow.teleport-across-worlds", true),
|
||||
HIGHLIGHT_COLOUR("general.color-scheme.message-highlight", "<yellow>"),
|
||||
HIGHLIGHT_COLOUR("general.color-scheme.message-highlight", "yellow"),
|
||||
INITIAL_PLAYER_JOIN_SKIN_PACKET_DELAY_TICKS("npc.skins.player-join-update-delay-ticks", 3 * 20),
|
||||
KEEP_CHUNKS_LOADED("npc.chunks.always-keep-loaded", false),
|
||||
LOCALE("general.translation.locale", ""),
|
||||
|
@ -89,6 +89,7 @@ import net.citizensnpcs.api.trait.trait.Speech;
|
||||
import net.citizensnpcs.api.util.Colorizer;
|
||||
import net.citizensnpcs.api.util.Messaging;
|
||||
import net.citizensnpcs.api.util.Paginator;
|
||||
import net.citizensnpcs.api.util.Placeholders;
|
||||
import net.citizensnpcs.api.util.SpigotUtil;
|
||||
import net.citizensnpcs.commands.gui.NPCConfigurator;
|
||||
import net.citizensnpcs.commands.history.CommandHistory;
|
||||
@ -606,7 +607,7 @@ public class NPCCommands {
|
||||
}
|
||||
|
||||
int nameLength = SpigotUtil.getMaxNameLength(type);
|
||||
if (name.length() > nameLength) {
|
||||
if (name.length() > nameLength && Placeholders.replace(name, sender, npc).length() > nameLength) {
|
||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
|
||||
name = name.substring(0, nameLength);
|
||||
}
|
||||
@ -2051,7 +2052,7 @@ public class NPCCommands {
|
||||
String oldName = npc.getName();
|
||||
String newName = Colorizer.parseColors(args.getJoinedStrings(1));
|
||||
int nameLength = SpigotUtil.getMaxNameLength(npc.getOrAddTrait(MobType.class).getType());
|
||||
if (newName.length() > nameLength) {
|
||||
if (newName.length() > nameLength && Placeholders.replace(newName, sender, npc).length() > nameLength) {
|
||||
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
|
||||
newName = newName.substring(0, nameLength);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user