MCLang
Github Status
![[IMG]](//proxy.spigotmc.org/7d9630e2c89a1c05b03bbcdf81742f89d16c001f/68747470733a2f2f63616d6f2e67697468756275736572636f6e74656e742e636f6d2f646433353439396530326162303831393736633761636365663066633537333938646562613962643064626562313534336564306339356234323239633131382f36383734373437303733336132663266363936643637326537333638363936353663363437333265363936663266363736393734363837353632326637363266373236353663363536313733363532663330366636323732363936313665366633303266346434333463363136653637)
SpigotMC Status
![[IMG]](//proxy.spigotmc.org/3cc522d733c24ed36059ee50cf216aa7918fea54/68747470733a2f2f63616d6f2e67697468756275736572636f6e74656e742e636f6d2f656236356461393539646661646165383133333263653163356330343161386464326333363661616138366166656466646463646339303231323332656630332f36383734373437303733336132663266363936643637326537333638363936353663363437333265363936663266373337303639363736353734326636343666373736653663366636313634373332663331333233353338333833333366363336663663366637323364373936353663366336663737)
bStats Status
![[IMG]](//proxy.spigotmc.org/4818d0059a72e46b4d7e982f34d6c441ddd948f5/68747470733a2f2f63616d6f2e67697468756275736572636f6e74656e742e636f6d2f636638346233616264356238626431623234656534343861376536373633346165383434656634353864343839306339656433633832643031653466366461342f363837343734373037333361326632663639366436373265373336383639363536633634373332653639366632663632373337343631373437333266373036633631373936353732373332663332333633313334333932653733373636373366363336663663366637323364363737323635363536653236366336313632363536633364346636653663363936653635353036633631373936353732373332363733373437393663363533643730366336313733373436393633)
Lightweight API to load and use official Minecraft language pack translations.
*Tested Minecraft versions: 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21*
*Folia 1.19.4+ support (version 1.1.3 add)
Features
- Easy-to-use language pack management for Bukkit plugins
- Language packs for different Minecraft versions can be downloaded from GitHub
- Automatically downloads language packs from the official Minecraft resources if not present
- Hot-reload language files without server restart
- API for developers to integrate custom messages
Docs JDOC
Gradle
Code (Text):
repositories {
mavenCentral()
maven { url 'https://repo1.maven.org/maven2/' }
}
dependencies {
compileOnly 'org.tsob:MCLang-API:1.1.3'
}
Maven
Code (Text):
<repositories>
<repository>
<id>maven</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependency>
<groupId>org.tsob</groupId>
<artifactId>MCLang-API</artifactId>
<version>1.1.3</version>
<scope>provided</scope>
</dependency>
Full Example: link
Example
Code (Java):
import
org.tsob.MCLang.API.MCLang
;
import
org.bukkit.Material
;
import
org.bukkit.entity.EntityType
;
import
org.bukkit.inventory.ItemStack
;
public
class ExamplePlugin
extends JavaPlugin
{
@Override
public
void onEnable
(
)
{
MCLang lang
=
new MCLang
(
"en"
)
;
// Get translation for an ItemStack
ItemStack item
=
new ItemStack
(Material.
DIAMOND_SWORD
)
;
String itemTranslation
= lang.
getItemTranslate
(item
)
;
// Directly read the translation from the language pack.
String translation
= getString
(
"item.minecraft.diamond_sword"
)
;
// Get translation for an item name
String itemTranslationByName
= lang.
getItemTranslate
(
"DIAMOND_SWORD"
)
;
// Get translation for an EntityType
String entityTranslation
= lang.
getEntityTranslate
(EntityType.
CREEPER
)
;
// Get translation by entity instance (version 1.1.0 add)
Entity entity
= ...
;
// your Entity instance
String entityTranslationFromEntity
= lang.
getEntityTranslate
(entity
)
;
// Get translation for an entity name
String entityTranslationByName
= lang.
getEntityTranslate
(
"CREEPER"
)
;
// Get translation for an enchantment (version 1.0.8 add)
String enchantmentTranslationByName
= lang.
getEnchantmentTranslate
(Enchantment.
SILK_TOUCH
)
;
// Get translation for an enchantment name (version 1.0.8 add)
String enchantmentTranslationByName
= lang.
getEnchantmentTranslate
(
"SILK_TOUCH"
)
;
}
View updates and changelog here.
TODO
- Improve API documentation
- Add more usage examples