本文整理汇总了Java中me.mrCookieSlime.CSCoreLibPlugin.Configuration.Localization类的典型用法代码示例。如果您正苦于以下问题:Java Localization类的具体用法?Java Localization怎么用?Java Localization使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Localization类属于me.mrCookieSlime.CSCoreLibPlugin.Configuration包,在下文中一共展示了Localization类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupLocalization
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Localization; //导入依赖的package包/类
/**
* Automatically sets up the messages.yml for you
*/
public void setupLocalization() {
local = new Localization(plugin);
}
示例2: onEnable
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Localization; //导入依赖的package包/类
@Override
public void onEnable() {
// Now to make sure your Plugin auto-installs CS-CoreLib if it was not found, create a new Instance of your CSCoreLibLoader
// You need to specify an Instance of your main class for that, but as you do this in your onEnable() method, simply specify this
CSCoreLibLoader loader = new CSCoreLibLoader(this);
// Now to check whether CS-CoreLib was properly installed, do the following statement:
if (loader.load()) {
// Now you can start enabling your Plugin right here as CSCoreLib was properly installed.
// The first thing you will most likely do is setting up the basics of your Plugin like a Config
// To do that you will need an Instance of PluginUtils for your Plugin
PluginUtils utils = new PluginUtils(this);
// Now setting up the config is as easy as the following
// This will take care of copying your default config.yml in your src folder and loading it
utils.setupConfig();
// To access your Config at any time, you can do this
Config cfg = utils.getConfig();
// This Config Object also has some useful methods which come along with it, you can play around with those for yourself
cfg.getLocation("path");
cfg.setDefaultValue("path", "value");
cfg.getRandomStringfromList("path");
cfg.getFloat("path");
cfg.save();
cfg.reload();
cfg.getString("path");
// And a lot more...
// Now your PluginUtils can do way more than that though
// For example you can setup your own Auto-Updater
int id = 0;
utils.setupUpdater(id, getFile());
// You can find your id here https://api.curseforge.com/servermods/projects?search=<Name of your Plugin>
// But there is also Metrics embedded if you want to monitor the Usage of your Plugins
utils.setupMetrics();
// And since a lot of people nowadays want more customization, there is also a Localization provided
utils.setupLocalization();
// And to access it:
Localization local = utils.getLocalization();
// And this Localization Object is a stripped down Version of the Config Object and has some of its Methods
local.setDefault("key", "You", "can", "specify", "multiple", "messages", "if", "you", "want");
// This will return the List of strings that are found under this key
local.getTranslation("key");
// You can also specify a Prefix if you want, also Color Codes are supported in all of these methods
local.setDefault("prefix", "&7[Awesome Plugin]");
// The following will send the Messages to the specified Player (null in this case)
// The boolean at the end represents whether a Prefix will be attached or not.
// Note here that you need to specify a Prefix first
local.sendTranslation(null, "path.to.message", true);
// Now if your localized Messages contains placeholders like %player%
// No problem, you can make use of those as well
local.sendTranslation(null, "path.to.message", true, new Variable("%player%", "replaced text"));
}
}
示例3: getLocalization
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Localization; //导入依赖的package包/类
/**
* Returns the previously setup Localization
*
* @return Localization for this Plugin
*/
public Localization getLocalization() {
return local;
}