-
Notifications
You must be signed in to change notification settings - Fork 2
API Usage
BloodyTim3 edited this page Dec 16, 2024
·
6 revisions
Example:
public class MyPlugin extends PluginBase {
@Override
public void onLoad() {
FuturePlots.getInstance().getProvider().setDataClient(new DataClient(
ClientType.MONGODB, new MongoDBDetails(
"uri",
"database"
)));
}
}
Example:
public class MyPlugin extends PluginBase {
@Override
public void onLoad() {
LanguageManager.setHandler(new CustomLanguageHandler());
}
}
public class CustomLanguageHandler implements LanguageProvider {
private final Map<String, Map<String, String>> translations = new HashMap<>();
@Override
public void init() {
Map<String, String> enTranslations = new HashMap<>();
enTranslations.put("greeting", "Hello, %s!");
Map<String, String> deTranslations = new HashMap<>();
deTranslations.put("greeting", "Hallo, %s!");
translations.put("en_US", enTranslations);
translations.put("de_DE", deTranslations);
}
@Override
public String message(String locale, String key, Object... replacements) {
Map<String, String> localeTranslations = translations.getOrDefault(locale, translations.get("en_US"));
String template = localeTranslations.getOrDefault(key, key);
return String.format(template, replacements);
}
}