修复 TLocaleBook 类型的颜色无法使用问题。
This commit is contained in:
parent
3314158f09
commit
11ecab1242
@ -71,7 +71,7 @@ public class TLocaleBook extends TLocaleSerialize {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
BookBuilder bookBuilder = BookFormatter.writtenBook();
|
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() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -82,6 +82,10 @@ public class TLocaleBook extends TLocaleSerialize {
|
|||||||
}.runTaskAsynchronously(Main.getInst());
|
}.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<String, Object> map) {
|
public static TLocaleBook valueOf(Map<String, Object> map) {
|
||||||
Map<String, Object> pages = map.containsKey("pages") ? (Map<String, Object>) map.get("pages") : new HashMap<>();
|
Map<String, Object> pages = map.containsKey("pages") ? (Map<String, Object>) map.get("pages") : new HashMap<>();
|
||||||
Map<String, Object> section = map.containsKey("args") ? (Map<String, Object>) map.get("args") : new HashMap<>();
|
Map<String, Object> section = map.containsKey("args") ? (Map<String, Object>) map.get("args") : new HashMap<>();
|
||||||
|
@ -171,7 +171,7 @@ public class TLocaleJson extends TLocaleSerialize {
|
|||||||
// 遍历本页文本
|
// 遍历本页文本
|
||||||
for (int i = 0; i < textList.size(); i++) {
|
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()) {
|
if (variable.isVariable()) {
|
||||||
String[] split = variable.getText().split("@");
|
String[] split = variable.getText().split("@");
|
||||||
|
Loading…
Reference in New Issue
Block a user