Improve message sending

This commit is contained in:
libraryaddict
2020-07-03 17:36:29 +12:00
parent 3ced8ae9e4
commit e74df537bb
26 changed files with 109 additions and 97 deletions

View File

@@ -372,16 +372,20 @@ public enum LibsMsg {
}
public String get(Object... strings) {
if (StringUtils.countMatches(getRaw(), "%s") != strings.length) {
int matches = StringUtils.countMatches(getRaw(), "%s");
if (matches != strings.length) {
DisguiseUtilities.getLogger().severe("Mismatch in messages, incorrect parameters supplied for " + name() +
". Please inform plugin author.");
". Please inform plugin author if not using translations.");
}
if (strings.length == 0) {
return TranslateType.MESSAGES.get(getRaw());
String trans = TranslateType.MESSAGES.get(getRaw());
if (trans.isEmpty() || strings.length == 0) {
return trans;
}
return String.format(TranslateType.MESSAGES.get(getRaw()), strings);
return String.format(trans, strings);
}
public String toString() {