當前位置: 首頁>>代碼示例>>Java>>正文


Java Plugin.getDataFolder方法代碼示例

本文整理匯總了Java中org.bukkit.plugin.Plugin.getDataFolder方法的典型用法代碼示例。如果您正苦於以下問題:Java Plugin.getDataFolder方法的具體用法?Java Plugin.getDataFolder怎麽用?Java Plugin.getDataFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.plugin.Plugin的用法示例。


在下文中一共展示了Plugin.getDataFolder方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: BSBLocale

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
/**
 * Provides localization
 * Locale files are .yml and have the filename "bsb_[country and language tag].yml", e.g. bsb_en_GB.yml
 * @param plugin
 * @throws MalformedURLException
 */
public BSBLocale(Plugin plugin, String localeId) throws MalformedURLException {
    this.plugin = plugin;
    //this.localeId = localeId;
    // Check if the folder exists
    File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER);
    if (!localeDir.exists()) {
        localeDir.mkdirs();
    }
    // Check if this file does not exist
    File localeFile = new File(localeDir, localeId);
    if (!localeFile.exists()) {
        // Does not exist - look in JAR and save if possible
        plugin.saveResource(LOCALE_FOLDER + localeId, false);
    }
    languageTag = localeId.substring(4, localeId.length() - 4).replace('_', '-');
    URL[] urls = {localeDir.toURI().toURL()};
    ClassLoader loader = new URLClassLoader(urls);
    localeObject = Locale.forLanguageTag(languageTag);
    rb = ResourceBundle.getBundle("bsb", localeObject, loader, YamlResourceBundle.Control.INSTANCE);
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:27,代碼來源:BSBLocale.java

示例2: getYaml

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public static YamlConfiguration getYaml(Plugin p, String path, boolean create){
	path = fixPath(path);
	File temp = new File(p.getDataFolder(), path);
	if(!temp.exists()){
		copyFile(path, p);
		if(!temp.exists()){
			if(create)
			try {
				temp.createNewFile();
			} catch (IOException e) {
				ErrorLogger.addError("Can't create " + path + " IO Exception !");
				e.printStackTrace();
			}
			else
				return null;
		}
	}
	YamlConfiguration file = YamlConfiguration.loadConfiguration(temp);
	return file;
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:21,代碼來源:ConfigUtils.java

示例3: copyDefaultNode

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public static void copyDefaultNode(YamlConfiguration configFile, Plugin plugin, String path, String nodPath){
	configFile.createSection(nodPath);
	path = fixPath(path);
	InputStream file = plugin.getResource(path.replace(File.separatorChar, '/'));
	if(file!=null){
		YamlConfiguration defaultFile = YamlConfiguration.loadConfiguration(new InputStreamReader(file));
		if(defaultFile.contains(nodPath))
			configFile.set(nodPath, defaultFile.get(path));
		else
			configFile.set(nodPath, Error.MISSING_NODE.getMessage());
	}
	File temp = new File(plugin.getDataFolder(), path);
	try {
		configFile.save(temp);
	} catch (IOException e) {
		e.printStackTrace();
		ErrorLogger.addError("I/O Exception for file : " + temp.getAbsolutePath());
	}
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:20,代碼來源:ConfigUtils.java

示例4: Messaging

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public Messaging(Plugin plugin) {
    File storageFile = new File(plugin.getDataFolder(), "messages.yml");

    if (!storageFile.exists()) {
        plugin.saveResource("messages.yml", false);
    }

    copyDefaults(storageFile);
    storage = YamlConfiguration.loadConfiguration(storageFile);
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:11,代碼來源:Messaging.java

示例5: reload

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public static void reload(Class<?> cls) {
    final Plugin plugin = JavaPlugin.getPlugin(BlockBallPlugin.class);
    if (plugin == null)
        throw new IllegalArgumentException("Pluginloader failed to load " + SLanguage.class.getSimpleName() + '.');
    final File file = new File(plugin.getDataFolder(), "lang.yml");
    if (!file.exists())
        buildFile(cls, file);
    loadFile(cls, file);
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:10,代碼來源:SLanguage.java

示例6: ConfigFile

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public ConfigFile(Plugin plugin, String name) {
    this.file = new File(plugin.getDataFolder(), name + ".yml");

    if (!this.file.getParentFile().exists()) {
        this.file.getParentFile().mkdir();
    }

    if (!this.file.exists()) {
        plugin.saveResource(name + ".yml", false);
    }

    this.configuration = YamlConfiguration.loadConfiguration(file);
}
 
開發者ID:ijoeleoli,項目名稱:ServerCommons,代碼行數:14,代碼來源:ConfigFile.java

示例7: load

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public static MessageManager load(Plugin plugin, String fileName) {
    File file = new File(plugin.getDataFolder(), fileName);
    if (!file.exists())
        plugin.saveResource(fileName, false);
    return load(file);
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:7,代碼來源:MessageManager.java

示例8: Store

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public Store(Plugin plugin) {
    this.plugin = plugin;
    this.logger = plugin.getLogger();
    this.file = new File(plugin.getDataFolder(), "store.yml");
    load();
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:7,代碼來源:Store.java

示例9: Registry

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public Registry(Plugin plugin, String id) {
    this.plugin = plugin;
    this.logger = new RegistryLogger();
    this.id = id;
    this.folder = new File(plugin.getDataFolder(), id);
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:7,代碼來源:Registry.java

示例10: FlatFileDatabaseConnecter

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public FlatFileDatabaseConnecter(Plugin plugin, DatabaseConnectionSettingsImpl databaseConnectionSettingsImpl) {
    this.plugin = plugin;
    dataFolder = new File(plugin.getDataFolder(), DATABASE_FOLDER_NAME);
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:5,代碼來源:FlatFileDatabaseConnecter.java

示例11: pluginDataFile

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
@Provides @Named("pluginData")
File pluginDataFile(Plugin plugin) {
    return plugin.getDataFolder();
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:5,代碼來源:BukkitPluginManifest.java

示例12: write

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
public static void write(Gson gson, Plugin plugin, String fileName, Object obj) {
    File file = new File(plugin.getDataFolder(), fileName);
    write(gson, file, obj, ex -> Static.log("Error while write " + file.getName()));
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:5,代碼來源:GsonUtils.java

示例13: PluginLogger

import org.bukkit.plugin.Plugin; //導入方法依賴的package包/類
/**
 * @param plugin the plugin which the logger belongs to.
 */
public PluginLogger(Plugin plugin) {
    this.plugin = plugin;
    this.file = new File(plugin.getDataFolder() + "/default.log");
}
 
開發者ID:ImABradley,項目名稱:Peach,代碼行數:8,代碼來源:PluginLogger.java


注:本文中的org.bukkit.plugin.Plugin.getDataFolder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。