From 11ecab124283c154ee4034a641da79a81392bbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Mon, 2 Jul 2018 23:40:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20TLocaleBook=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84=E9=A2=9C=E8=89=B2=E6=97=A0=E6=B3=95=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ilummc/tlib/resources/type/TLocaleBook.java | 6 +++++- .../java/com/ilummc/tlib/resources/type/TLocaleJson.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) 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("@");