本文整理汇总了Java中org.bukkit.plugin.java.JavaPlugin.getDataFolder方法的典型用法代码示例。如果您正苦于以下问题:Java JavaPlugin.getDataFolder方法的具体用法?Java JavaPlugin.getDataFolder怎么用?Java JavaPlugin.getDataFolder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.plugin.java.JavaPlugin
的用法示例。
在下文中一共展示了JavaPlugin.getDataFolder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ConfigFile
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
public ConfigFile(JavaPlugin plugin, String name) {
super(plugin.getDataFolder(), name + ".yml");
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
if (!exists()) {
try {
if (plugin.getResource(name + ".yml") != null) {
plugin.saveResource(name + ".yml", true);
} else {
createNewFile();
}
} catch (IOException e) {
e.printStackTrace();
}
}
config = YamlConfiguration.loadConfiguration(this);
}
示例2: load
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
private void load(JavaPlugin plugin) {
try {
final FileConfiguration configuration = new YamlConfiguration();
final File file = new File(plugin.getDataFolder(), "bungeecord_signs.yml");
if (!file.exists()) {
if (!file.createNewFile()) {
Bukkit.getLogger().log(Level.WARNING, "File cannot get created.");
}
}
configuration.load(file);
if (configuration.getConfigurationSection("signs") != null) {
final Map<String, Object> data = configuration.getConfigurationSection("signs").getValues(false);
for (final String s : data.keySet()) {
this.signs.add(new BungeeCordSignInfo.Container(((ConfigurationSection) data.get(s)).getValues(true)));
}
}
} catch (IOException | InvalidConfigurationException e) {
Bukkit.getLogger().log(Level.WARNING, "Save load location.", e);
}
}
示例3: ConfigAPI
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
public ConfigAPI(String name, JavaPlugin plugin) {
File file = new File(plugin.getDataFolder(), name);
if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
this.config = YamlConfiguration.loadConfiguration(file);
}
示例4: loadLocalMap
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
private static void loadLocalMap(JavaPlugin plugin, String codeName,
Map<String, String> targetMap, boolean ignoreInternal, boolean ignoreNormal) {
if (plugin == null || codeName == null || targetMap == null) throw new IllegalArgumentException();
if (Boolean.parseBoolean(System.getProperty("nyaautils.i18n.refreshLangFiles", "false"))) return;
File langFile = new File(plugin.getDataFolder(), codeName + ".yml");
if (langFile.exists() && langFile.isFile()) {
YamlConfiguration section = YamlConfiguration.loadConfiguration(langFile);
loadLanguageSection(targetMap, section, "", ignoreInternal, ignoreNormal);
}
}
示例5: load
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
/**
* Reset then load per-plugin language map
* Based on {@link this#getPlugin()} and {@link this#getLanguage()}
*/
public void load() {
String codeName = getLanguage();
JavaPlugin plugin = getPlugin();
if (codeName == null) codeName = DEFAULT_LANGUAGE;
map.clear();
// load languages
loadResourceMap(corePlugin, DEFAULT_LANGUAGE, map, true, false);
loadLocalMap(corePlugin, DEFAULT_LANGUAGE, map, true, false);
loadResourceMap(corePlugin, codeName, map, true, false);
loadLocalMap(corePlugin, codeName, map, true, false);
loadResourceMap(getPlugin(), DEFAULT_LANGUAGE, map, false, false);
loadLocalMap(getPlugin(), DEFAULT_LANGUAGE, map, false, false);
loadResourceMap(getPlugin(), codeName, map, false, false);
loadLocalMap(getPlugin(), codeName, map, false, false);
// save (probably) modified language file back to disk
File localLangFile = new File(plugin.getDataFolder(), codeName + ".yml");
try {
YamlConfiguration yaml = new YamlConfiguration();
for (String key : map.keySet()) {
yaml.set(key, map.get(key));
}
yaml.save(localLangFile);
} catch (IOException ex) {
plugin.getLogger().warning("Cannot save language file: " + codeName + ".yml");
}
plugin.getLogger().info(getFormatted("internal.info.using_language", codeName));
}
示例6: Config
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
/**
* Creates new PluginFile, with defaults
* @param plugin - Your plugin
* @param fileName - Name of the file
* @param defaultsName - Name of the defaults
*/
public Config(JavaPlugin plugin, String fileName, String defaultsName) {
this.plugin = plugin;
this.defaults = defaultsName;
this.file = new File(plugin.getDataFolder(), fileName);
reload();
}
示例7: DataFile
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
public DataFile(JavaPlugin plugin, String name) {
file = new File(plugin.getDataFolder(), name + ".yml");
if (!file.getParentFile().exists()) {
file.getParentFile().mkdir();
}
plugin.saveResource(name + ".yml", false);
configuration = YamlConfiguration.loadConfiguration(file);
}
示例8: LobbyPopulator
import org.bukkit.plugin.java.JavaPlugin; //导入方法依赖的package包/类
/**
* Constructor
*
* @param plugin Parent plugin
*/
public LobbyPopulator(JavaPlugin plugin)
{
this.logger = plugin.getLogger();
this.file = new File(plugin.getDataFolder(), "lobby.schematic");
}