mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Fix messages not being formatted correctly
This commit is contained in:
parent
462bea2a09
commit
d8221f466a
@ -27,8 +27,6 @@ import lombok.Getter;
|
||||
import me.lucko.luckperms.commands.Sender;
|
||||
import me.lucko.luckperms.commands.Util;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@AllArgsConstructor
|
||||
public enum Message {
|
||||
@ -367,15 +365,18 @@ public enum Message {
|
||||
s = s.replace("{PREFIX}", PREFIX.getMessage()).replace("\\n", "\n");
|
||||
}
|
||||
|
||||
try {
|
||||
if (showPrefix) {
|
||||
sender.sendMessage(Util.color(PREFIX + MessageFormat.format(s, objects)));
|
||||
sender.sendMessage(Util.color(PREFIX + format(s, objects)));
|
||||
} else {
|
||||
sender.sendMessage(Util.color(MessageFormat.format(s, objects)));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Could not format message: " + this);
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(Util.color(format(s, objects)));
|
||||
}
|
||||
}
|
||||
|
||||
private static String format(String s, Object... objects) {
|
||||
for (int i = 0, objsLength = objects.length; i < objsLength; i++) {
|
||||
Object o = objects[i];
|
||||
s = s.replace("{" + i + "}", o.toString());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user