-
Notifications
You must be signed in to change notification settings - Fork 16
Getting started
PikaMug edited this page Aug 11, 2024
·
11 revisions
To use this library, either add the LocaleLib jar to your Java build path or as a Maven dependency via CodeMC:
<repositories>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
</repositories>
<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:
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:
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:
private LocaleManager localeManager = new LocaleManager();
Lastly, you'll want to get your Player and decide which message command to use (here's an example):
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);