mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Add experimental json support in formats
This commit is contained in:
1 parent
7124585602
commit
0c724b330c
2 files changed
+17
No files matched your search
@@ -26,6 +26,10 @@ public class AdventureManager {
|
||||
switch (carbonChat.getLanguage().getString("formatting.type", "minimessage").toLowerCase()) {
|
||||
case "minedown":
|
||||
return processMineDown(input, placeholders);
|
||||
case "mojang":
|
||||
case "mojangson":
|
||||
case "json":
|
||||
return processMojang(input, placeholders);
|
||||
case "minimessage-markdown":
|
||||
return MiniMessage.markdown().parse(input, placeholders);
|
||||
case "minimessage":
|
||||
@@ -34,6 +38,17 @@ public class AdventureManager {
|
||||
}
|
||||
}
|
||||
|
||||
private Component processMojang(String input, String... placeholders) {
|
||||
for (int i = 0; i < placeholders.length; i += 2) {
|
||||
String placeholder = placeholders[i];
|
||||
String replacement = placeholders[i+1];
|
||||
|
||||
input = input.replace("<" + placeholder + ">", replacement);
|
||||
}
|
||||
|
||||
return getAudiences().gsonSerializer().deserialize(input);
|
||||
}
|
||||
|
||||
private Component processMineDown(String input, String... placeholders) {
|
||||
return MineDown.parse(input, placeholders);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
# 'MiniMessage': https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#the-components
|
||||
# 'MiniMessage-Markdown': https://github.com/KyoriPowered/adventure-docs/blob/feature/minimessage/source/minimessage.rst#markdown
|
||||
# 'MineDown': https://github.com/Phoenix616/MineDown#syntax
|
||||
# 'JSON': https://minecraft.gamepedia.com/Raw_JSON_text_format
|
||||
# Note that the messages provided in the default config utilise MiniMessage, and need to be changed if you're using MineDown
|
||||
# Please DO NOT use JSON formatting unless you really know what you're doing
|
||||
formatting:
|
||||
type: 'MiniMessage'
|
||||
|
||||
|
||||
Reference in new issue
Block a user