From 6439e4b780e9c4a4e14f6e3bda87541f2c803893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sat, 10 Mar 2018 12:13:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=E8=87=B3?= =?UTF-8?q?=EF=BC=9A3.75?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复:Language2Value 对象的 asString() 方法无法识别变量的问题 新增:Language2 工具新增方法 get(String, String...) 来快速添加变量 --- .../taboolib/string/language2/Language2.java | 15 +++++++++++++++ .../string/language2/Language2Value.java | 19 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/src/me/skymc/taboolib/string/language2/Language2.java b/src/main/src/me/skymc/taboolib/string/language2/Language2.java index a8ba3d4..4df7985 100644 --- a/src/main/src/me/skymc/taboolib/string/language2/Language2.java +++ b/src/main/src/me/skymc/taboolib/string/language2/Language2.java @@ -65,6 +65,21 @@ public class Language2 { return new Language2Value(this, key); } + /** + * ȡļ + * + * @param key + * @param placeholder 滻 @$0 ʼ + * @return {@link Language2Value} + */ + public Language2Value get(String key, String... placeholder) { + Language2Value value = new Language2Value(this, key); + for (int i = 0 ; i < placeholder.length ; i++) { + value.addPlaceholder("$" + i, placeholder[i]); + } + return value; + } + /** * ļ */ diff --git a/src/main/src/me/skymc/taboolib/string/language2/Language2Value.java b/src/main/src/me/skymc/taboolib/string/language2/Language2Value.java index e54da6b..74f20ed 100644 --- a/src/main/src/me/skymc/taboolib/string/language2/Language2Value.java +++ b/src/main/src/me/skymc/taboolib/string/language2/Language2Value.java @@ -129,7 +129,7 @@ public class Language2Value extends Object { Language2Format format = new Language2Format(null, this); if (format.getLanguage2Lines().get(0) instanceof Language2Text) { Language2Text text = (Language2Text) format.getLanguage2Lines().get(0); - return text.getText().get(0); + return setPlaceholder(text.getText().get(0), null); } else { return languageValue.size() == 0 ? ChatColor.DARK_RED + "[]" : setPlaceholder(languageValue.get(0), null); @@ -145,7 +145,7 @@ public class Language2Value extends Object { Language2Format format = new Language2Format(null, this); if (format.getLanguage2Lines().get(0) instanceof Language2Text) { Language2Text text = (Language2Text) format.getLanguage2Lines().get(0); - return text.getText(); + return setPlaceholder(text.getText(), null); } else { return Arrays.asList(languageValue.size() == 0 ? ChatColor.DARK_RED + "[]" : setPlaceholder(languageValue.get(0), null)); @@ -166,6 +166,21 @@ public class Language2Value extends Object { return isEnablePlaceholderAPI() ? this.language.setPlaceholderAPI(player, value) : value; } + /** + * 滻 + * + * @param list 滻 + * @param player + * @return {@link List} + */ + public List setPlaceholder(List list, Player player) { + List _list = new ArrayList<>(list); + for (int i = 0 ; i < _list.size() ; i++) { + _list.set(i, setPlaceholder(_list.get(i), player)); + } + return _list; + } + /** * 滻 *