Switch to use new method

This commit is contained in:
fullwall 2022-12-18 13:50:19 +08:00
parent c6e7ce65f5
commit 5a82133200
6 changed files with 13 additions and 16 deletions

View File

@ -84,7 +84,6 @@ import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.api.trait.trait.Spawned;
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;
@ -608,7 +607,7 @@ public class NPCCommands {
@Flag(value = "type", defValue = "PLAYER") EntityType type, @Flag("trait") String traits,
@Flag("item") String item, @Flag("template") String templateName, @Flag("registry") String registryName)
throws CommandException {
String name = Colorizer.parseColors(args.getJoinedStrings(1).trim());
String name = args.getJoinedStrings(1).trim();
if (args.hasValueFlag("type")) {
if (type == null) {
throw new CommandException(Messaging.tr(Messages.NPC_CREATE_INVALID_MOBTYPE, args.getFlag("type")));
@ -2096,7 +2095,7 @@ public class NPCCommands {
permission = "citizens.npc.rename")
public void rename(CommandContext args, CommandSender sender, NPC npc) {
String oldName = npc.getName();
String newName = Colorizer.parseColors(args.getJoinedStrings(1));
String newName = args.getJoinedStrings(1);
int nameLength = SpigotUtil.getMaxNameLength(npc.getOrAddTrait(MobType.class).getType());
if (newName.length() > nameLength && Placeholders.replace(newName, sender, npc).length() > nameLength) {
Messaging.sendErrorTr(sender, Messages.NPC_NAME_TOO_LONG, nameLength);
@ -2620,7 +2619,7 @@ public class NPCCommands {
permission = "citizens.npc.speak")
public void speak(CommandContext args, CommandSender sender, NPC npc, @Flag("type") String type,
@Flag("target") String target, @Flag("range") Float range) throws CommandException {
String message = Colorizer.parseColors(args.getJoinedStrings(1));
String message = args.getJoinedStrings(1);
if (message.length() <= 0) {
Messaging.send(sender, "Default Vocal Chord for " + npc.getName() + ": "

View File

@ -24,8 +24,8 @@ import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.Placeholders;
import net.citizensnpcs.api.util.SpigotUtil;
import net.citizensnpcs.util.NMS;
@ -296,7 +296,7 @@ public class HologramTrait extends Trait {
text = null;
}
if (text != null && !ChatColor.stripColor(Colorizer.parseColors(text)).isEmpty()) {
if (text != null && !ChatColor.stripColor(Messaging.parseComponents(text)).isEmpty()) {
hologramNPC.setName(Placeholders.replace(text, null, npc));
hologramNPC.data().set(NPC.Metadata.NAMEPLATE_VISIBLE, true);
} else {

View File

@ -37,7 +37,6 @@ import net.citizensnpcs.api.gui.MenuSlot;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.Placeholders;
import net.citizensnpcs.trait.shop.CommandAction;
@ -420,8 +419,8 @@ public class ShopTrait extends Trait {
? Joiner.on("<br>").skipNulls().join(modified.display.getItemMeta().getLore())
: "", description -> {
ItemMeta meta = modified.display.getItemMeta();
meta.setLore(Lists
.newArrayList(Splitter.on("<br>").split(Colorizer.parseColors(description))));
meta.setLore(Lists.newArrayList(
Splitter.on("<br>").split(Messaging.parseComponents(description))));
modified.display.setItemMeta(meta);
}));
}
@ -433,7 +432,7 @@ public class ShopTrait extends Trait {
return;
ctx.getMenu().transition(InputMenus.stringSetter(modified.display.getItemMeta()::getDisplayName, name -> {
ItemMeta meta = modified.display.getItemMeta();
meta.setDisplayName(ChatColor.RESET + Colorizer.parseColors(name));
meta.setDisplayName(ChatColor.RESET + Messaging.parseComponents(name));
modified.display.setItemMeta(meta);
}));
}

View File

@ -29,7 +29,7 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.Placeholders;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
@ -215,7 +215,7 @@ public class BossBarTrait extends Trait {
trait.setTrackVariable(track);
}
if (title != null) {
trait.setTitle(Colorizer.parseColors(title));
trait.setTitle(Messaging.parseComponents(title));
}
if (visible != null) {
trait.setVisible(visible);

View File

@ -49,7 +49,7 @@ public class CamelTrait extends Trait {
@Command(
aliases = { "npc" },
usage = "camel (--pose pose) (--strength strength)",
usage = "camel (--pose pose)",
desc = "Sets camel modifiers",
modifiers = { "camel" },
min = 1,

View File

@ -36,7 +36,6 @@ import net.citizensnpcs.api.event.NPCCollisionEvent;
import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.api.util.Placeholders;
import net.citizensnpcs.api.util.SpigotUtil;
@ -100,9 +99,9 @@ public class Util {
public static ItemStack createItem(Material mat, String name, String description) {
ItemStack stack = new ItemStack(mat, 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(ChatColor.RESET + Colorizer.parseColors(name));
meta.setDisplayName(ChatColor.RESET + Messaging.parseComponents(name));
if (description != null) {
meta.setLore(Arrays.asList(Colorizer.parseColors(description).split("\n")));
meta.setLore(Arrays.asList(Messaging.parseComponents(description).split("\n")));
}
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
stack.setItemMeta(meta);