本文整理了Java中org.bukkit.plugin.Plugin.getDataFolder()
方法的一些代码示例,展示了Plugin.getDataFolder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Plugin.getDataFolder()
方法的具体详情如下:
包路径:org.bukkit.plugin.Plugin
类名称:Plugin
方法名:getDataFolder
[英]Returns the folder that the plugin data's files are located in. The folder may not yet exist.
[中]返回插件数据文件所在的文件夹。该文件夹可能尚不存在。
代码示例来源:origin: aadnk/ProtocolLib
/**
* Retrieve the file that is used to store the update time stamp.
*
* @return File storing the update time stamp.
*/
private File getLastUpdateFile() {
return new File(plugin.getDataFolder(), LAST_UPDATE_FILE);
}
代码示例来源:origin: aadnk/ProtocolLib
/**
* Retrieve a reference to the configuration file.
*
* @return Configuration file on disk.
*/
public File getFile() {
return new File(plugin.getDataFolder(), "config.yml");
}
代码示例来源:origin: zDevelopers/ImageOnMap
/**
* Returns the former images directory of a given plugin
* @param plugin The plugin.
* @return the corresponding 'Image' directory
*/
static public File getOldImagesDirectory(Plugin plugin)
{
return new File(plugin.getDataFolder(), OLD_IMAGES_DIRECTORY_NAME);
}
代码示例来源:origin: Bkm016/TabooLib
private File getLanguageDir() {
File dir = new File(plugin.getDataFolder(), "Language");
if (!dir.exists()) {
dir.mkdirs();
}
return dir;
}
}
代码示例来源:origin: Bkm016/TabooLib
private void createFolder(Plugin plugin) {
languageFolder = new File(plugin.getDataFolder(), "Language2");
if (!languageFolder.exists()) {
languageFolder.mkdir();
}
}
}
代码示例来源:origin: dzikoysk/WildSkript
public File getConfigFile() {
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
// is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/
// pluginsFolder => base/plugins/
// The base is not necessarily relative to the startup directory.
File pluginsFolder = plugin.getDataFolder().getParentFile();
// return => base/plugins/PluginMetrics/config.yml
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
}
代码示例来源:origin: FunnyGuilds/FunnyGuilds
public File getConfigFile() {
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
// is to abuse the plugin object we already have
// plugin.getDataFolder() => base/plugins/PluginA/
// pluginsFolder => base/plugins/
// The base is not necessarily relative to the startup directory.
File pluginsFolder = plugin.getDataFolder().getParentFile();
// return => base/plugins/PluginMetrics/config.yml
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
}
代码示例来源:origin: filoghost/HolographicDisplays
public static void loadYamlFile(Plugin plugin) {
file = new File(plugin.getDataFolder(), "database.yml");
if (!file.exists()) {
plugin.getDataFolder().mkdirs();
plugin.saveResource("database.yml", true);
}
config = YamlConfiguration.loadConfiguration(file);
}
代码示例来源:origin: Slikey/EffectLib
public EffectManager(Plugin owningPlugin) {
imageCacheFolder = owningPlugin == null ? null : new File(owningPlugin.getDataFolder(), "imagecache");
this.owningPlugin = owningPlugin;
Transforms.setEffectManager(this);
effects = new HashMap<Effect, BukkitTask>();
disposed = false;
disposeOnTermination = false;
}
代码示例来源:origin: games647/ScoreboardStats
private String replaceUrlString(String input) {
//Replace the windows separators ('\') with a '/'; \\ escape regEx --> \\\\ escape java
String result = input.replaceAll("\\{DIR\\}", plugin.getDataFolder().getPath().replaceAll("\\\\", "/") + '/');
result = result.replaceAll("\\{NAME\\}", plugin.getDescription().getName().replaceAll("[^\\w-]", ""));
return result;
}
}
代码示例来源:origin: sgtcaze/NametagEdit
private List<String> getLines(CommandSender commandSender, Plugin plugin, String oldFileName) throws IOException {
File oldFile = new File(plugin.getDataFolder(), oldFileName);
if (!oldFile.exists()) {
NametagMessages.FILE_DOESNT_EXIST.send(commandSender, oldFileName);
return new ArrayList<>();
}
return getLines(oldFile);
}
代码示例来源:origin: elBukkit/MagicPlugin
@Override
public void initialize(MageController controller, ConfigurationSection configuration) {
super.initialize(controller, configuration);
Plugin plugin = controller.getPlugin();
String playerFolder = configuration.getString("folder", "players");
String migrateFolder = configuration.getString("migration_folder", "migrated");
playerDataFolder = new File(plugin.getDataFolder(), playerFolder);
playerDataFolder.mkdirs();
migratedDataFolder = new File(plugin.getDataFolder(), migrateFolder);
}
代码示例来源:origin: Bkm016/TabooLib
public static void saveLanguageFile(String name, Plugin plugin) {
if (!new File(new File(plugin.getDataFolder(), "Languages"), name + ".yml").exists()) {
plugin.saveResource("Languages/" + name + ".yml", true);
MsgUtils.Console("&8[" + plugin.getName() + "]&7 生成语言文件&f: " + name + ".yml");
}
}
}
代码示例来源:origin: Bkm016/TabooLib
public static void reloadItemCache() {
itemCaches.clear();
itemCachesFinal.clear();
loadItemsFile(getItemCacheFile(), false);
finalItemsFolder = new File(Main.getInst().getDataFolder(), "FinalItems");
if (!finalItemsFolder.exists()) {
finalItemsFolder.mkdir();
}
Arrays.stream(finalItemsFolder.listFiles()).forEach(file -> loadItemsFile(file, true));
TabooLib.debug("Loaded " + (itemCaches.size() + itemCachesFinal.size()) + " items.");
// TLocale.Logger.info("ITEM-UTILS.SUCCESS-LOAD-CACHES", String.valueOf(itemCaches.size() + itemCachesFinal.size()));
}
代码示例来源:origin: Bkm016/TabooLib
public static File getItemCacheFile() {
File itemCacheFile = new File(Main.getInst().getDataFolder(), "items.yml");
if (!itemCacheFile.exists()) {
Main.getInst().saveResource("items.yml", true);
}
return itemCacheFile;
}
代码示例来源:origin: Bkm016/TabooLib
private TLib() {
libsFolder = new File(Main.getInst().getDataFolder(), "/libs");
if (!libsFolder.exists()) {
libsFolder.mkdirs();
}
try {
String yamlText = new String(IO.readFully(FileUtils.getResource("lang/internal.yml")), Charset.forName("utf-8"));
internalLanguage = new YamlConfiguration();
internalLanguage.loadFromString(yamlText);
} catch (IOException | InvalidConfigurationException ignored) {
}
}
代码示例来源:origin: elBukkit/MagicPlugin
public RegisterTask(Plugin plugin, Player player, String code) {
logger = plugin.getLogger();
File dataFolder = new File(plugin.getDataFolder(), "data");
registerFile = new File(dataFolder, "registered.yml");
playerId = player.getUniqueId().toString();
playerName = player.getName();
skinURL = SkinUtils.getOnlineSkinURL(playerName);
this.code = code;
}
代码示例来源:origin: elBukkit/MagicPlugin
public static EffectLibManager initialize(Plugin plugin) {
if (effectManager == null) {
effectManager = new EffectManager(plugin);
effectManager.setImageCacheFolder(new File(plugin.getDataFolder(), "data/imagemapcache"));
}
return new EffectLibManager(plugin);
}
代码示例来源:origin: aikar/commands
/**
* Loads a file out of the plugins data folder by the given name
* @param file
* @param locale
* @return If any language keys were added
* @throws IOException
* @throws InvalidConfigurationException
*/
public boolean loadYamlLanguageFile(String file, Locale locale) throws IOException, InvalidConfigurationException {
YamlConfiguration yamlConfiguration = new YamlConfiguration();
yamlConfiguration.load(new File(this.manager.plugin.getDataFolder(), file));
return loadLanguage(yamlConfiguration, locale);
}
代码示例来源:origin: aadnk/ProtocolLib
private void saveTimings(TimedListenerManager manager) {
try {
File destination = new File(plugin.getDataFolder(), "Timings - " + System.currentTimeMillis() + ".txt");
TimingReportGenerator generator = new TimingReportGenerator();
// Print to a text file
generator.saveTo(destination, manager);
manager.clear();
} catch (IOException e) {
reporter.reportMinimal(plugin, "saveTimings()", e);
}
}
内容来源于网络,如有侵权,请联系作者删除!