mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-20 00:13:21 +02:00
otterlib language system
This commit is contained in:
parent
c8902c5138
commit
85cc76a022
9 changed files with 69 additions and 172 deletions
|
@ -281,35 +281,14 @@ public class Utl {
|
|||
|
||||
// send a message if needed
|
||||
if (message) {
|
||||
player.sendMessage(messageTag()
|
||||
.append(lang("sit!.chat.purged",lang("sit!.chat.purged.total",count).color(Color.gray).b()).color(Color.GREEN)).b());
|
||||
player.sendMessage(Chat.tag()
|
||||
.append(Chat.lang("sit!.chat.purged",
|
||||
Chat.lang("sit!.chat.purged.total",count).color(Color.gray).b()
|
||||
).color(Color.GREEN)).b());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CTxT messageTag() {
|
||||
return new CTxT("Sit!").btn(true).color(Color.decode("#c400ff")).append(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a MutableText using the language key, if on server, using the custom lang reader
|
||||
*/
|
||||
public static CTxT lang(String key, Object... args) {
|
||||
if (Data.isClient()) {
|
||||
// we have to first convert all the CTxT's to the built version because minecraft lang reader doesn't know how to process it
|
||||
// make a array with the same size of the args
|
||||
Object[] fixedArgs = new Object[args.length];
|
||||
// for every arg, build & add if CTxT or just add if not
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
if (args[i] instanceof CTxT) fixedArgs[i] = ((CTxT) args[i]).b();
|
||||
else fixedArgs[i] = args[i];
|
||||
}
|
||||
// return the translated text
|
||||
return new CTxT(Text.translatable(key,fixedArgs));
|
||||
}
|
||||
else return LangReader.of(key, args).getTxT();
|
||||
}
|
||||
|
||||
/**
|
||||
* sends the settings packets to the server, if client & in game
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue