mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-07 03:19:47 +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.Sender;
|
||||||
import me.lucko.luckperms.commands.Util;
|
import me.lucko.luckperms.commands.Util;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
|
|
||||||
@SuppressWarnings("SpellCheckingInspection")
|
@SuppressWarnings("SpellCheckingInspection")
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum Message {
|
public enum Message {
|
||||||
@ -367,15 +365,18 @@ public enum Message {
|
|||||||
s = s.replace("{PREFIX}", PREFIX.getMessage()).replace("\\n", "\n");
|
s = s.replace("{PREFIX}", PREFIX.getMessage()).replace("\\n", "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (showPrefix) {
|
||||||
if (showPrefix) {
|
sender.sendMessage(Util.color(PREFIX + format(s, objects)));
|
||||||
sender.sendMessage(Util.color(PREFIX + MessageFormat.format(s, objects)));
|
} else {
|
||||||
} else {
|
sender.sendMessage(Util.color(format(s, objects)));
|
||||||
sender.sendMessage(Util.color(MessageFormat.format(s, objects)));
|
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
System.out.println("Could not format message: " + this);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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