To use this library, either add the LocaleLib jar to your Java build path or as a Maven dependency via CodeMC:
Code (XML):
<repositories>
<repository>
<id>codemc-repo
</id>
<url>https://repo.codemc.io/repository/maven-public/
</url>
</repository>
</repositories>
Code (XML):
<dependency>
<groupId>me.pikamug.localelib
</groupId>
<artifactId>LocaleLib
</artifactId>
<version>4.0.0
</version>
</dependency>
Then, add LocaleLib as a dependency (or soft-dependency, if you can live without it) to your plugin.yml file:
Code (YAML):
depend
:
[LocaleLib
]
Next, you'll need a reference to LocaleManager. If you intend to bundle or require LocaleLib be downloaded alongside your plugin, add the following in your onEnable() method:
Code (Java):
private LocaleManager localeManager
;
@Override
public
void onEnable
(
)
{
LocaleLib localeLib
=
(LocaleLib
) getServer
(
).
getPluginManager
(
).
getPlugin
(
"LocaleLib"
)
;
if
(localeLib
!=
null
)
{ localeManager
= localeLib.
getLocaleManager
(
)
;
}
}
If you are shading LocaleLib into your resource (taking the license into account), you may instantiate LocaleManager directly as necessary:
Code (Java):
private LocaleManager localeManager
=
new LocaleManager
(
)
;
Lastly, you'll want to get your Player and decide which message command to use (here's an example):
Code (Java):
org.
bukkit.
entity.
Player p
= Bukkit.
getPlayer
(
"PikaMug"
)
;
localeManager.
sendMessage
(p,
"I make "
+ ChatColor.
GREEN
+
"<item>"
+ ChatColor.
RESET
+
" look good",
Material.
DIRT,
(
short
)
0,
null
)
;
For more examples, visit the
official wiki on Github.