diff --git a/src/main/java/com/ilummc/tlib/resources/type/TLocaleBook.java b/src/main/java/com/ilummc/tlib/resources/type/TLocaleBook.java index 978eb27..24c8008 100644 --- a/src/main/java/com/ilummc/tlib/resources/type/TLocaleBook.java +++ b/src/main/java/com/ilummc/tlib/resources/type/TLocaleBook.java @@ -71,7 +71,7 @@ public class TLocaleBook extends TLocaleSerialize { @Override public void run() { BookBuilder bookBuilder = BookFormatter.writtenBook(); - pages.stream().map(jsonPage -> papi ? TLocale.Translate.setPlaceholders(sender, Strings.replaceWithOrder(jsonPage.toRawMessage(), args)) : TLocale.Translate.setColored(Strings.replaceWithOrder(jsonPage.toRawMessage(), args))).map(ComponentSerializer::parse).forEach(bookBuilder::addPages); + pages.stream().map(jsonPage -> format(jsonPage, sender, args)).map(ComponentSerializer::parse).forEach(bookBuilder::addPages); new BukkitRunnable() { @Override public void run() { @@ -82,6 +82,10 @@ public class TLocaleBook extends TLocaleSerialize { }.runTaskAsynchronously(Main.getInst()); } + private String format(TellrawJson jsonPage, CommandSender sender, String[] args) { + return papi ? TLocale.Translate.setPlaceholders(sender, Strings.replaceWithOrder(jsonPage.toRawMessage(), args)) : Strings.replaceWithOrder(jsonPage.toRawMessage(), args); + } + public static TLocaleBook valueOf(Map map) { Map pages = map.containsKey("pages") ? (Map) map.get("pages") : new HashMap<>(); Map section = map.containsKey("args") ? (Map) map.get("args") : new HashMap<>(); diff --git a/src/main/java/com/ilummc/tlib/resources/type/TLocaleJson.java b/src/main/java/com/ilummc/tlib/resources/type/TLocaleJson.java index 2a14974..456f862 100644 --- a/src/main/java/com/ilummc/tlib/resources/type/TLocaleJson.java +++ b/src/main/java/com/ilummc/tlib/resources/type/TLocaleJson.java @@ -171,7 +171,7 @@ public class TLocaleJson extends TLocaleSerialize { // 遍历本页文本 for (int i = 0; i < textList.size(); i++) { // 捕捉变量 - for (VariableFormatter.Variable variable : new VariableFormatter(textList.get(i), pattern).find().getVariableList()) { + for (VariableFormatter.Variable variable : new VariableFormatter(TLocale.Translate.setColored(textList.get(i)), pattern).find().getVariableList()) { // 如果是变量 if (variable.isVariable()) { String[] split = variable.getText().split("@");