Search in sources :

Example 1 with PluginLogger

use of org.bukkit.plugin.PluginLogger in project Bukkit by Bukkit.

the class JavaPlugin method init.

final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
    this.loader = loader;
    this.server = server;
    this.file = file;
    this.description = description;
    this.dataFolder = dataFolder;
    this.classLoader = classLoader;
    this.configFile = new File(dataFolder, "config.yml");
    this.logger = new PluginLogger(this);
    if (description.isDatabaseEnabled()) {
        ServerConfig db = new ServerConfig();
        db.setDefaultServer(false);
        db.setRegister(false);
        db.setClasses(getDatabaseClasses());
        db.setName(description.getName());
        server.configureDbConfig(db);
        DataSourceConfig ds = db.getDataSourceConfig();
        ds.setUrl(replaceDatabaseString(ds.getUrl()));
        dataFolder.mkdirs();
        ClassLoader previous = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        ebean = EbeanServerFactory.create(db);
        Thread.currentThread().setContextClassLoader(previous);
    }
}
Also used : ServerConfig(com.avaje.ebean.config.ServerConfig) DataSourceConfig(com.avaje.ebean.config.DataSourceConfig) File(java.io.File) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) PluginLogger(org.bukkit.plugin.PluginLogger)

Example 2 with PluginLogger

use of org.bukkit.plugin.PluginLogger in project Dragonet-Legacy by DragonetMC.

the class PluginAdapter method initialize.

public void initialize(String name) {
    if (initialized)
        return;
    this.name = name;
    dataFolder = new File(server.getDragonetServer().getPluginFolder(), this.getName().replace(".", "_").concat("-data"));
    if (dataFolder.isFile()) {
        server.getLogger().warning("Faild to load plugin [" + getName() + "] due to plugin folder is occupied by a regular file. ");
        throw new IllegalStateException("Plugin folder for [" + getName() + "] is occupied by a regular file. ");
    }
    config = new YamlConfiguration();
    try {
        config.load(new File(dataFolder, "config.yml"));
    } catch (IOException | InvalidConfigurationException ex) {
    }
    logger = new PluginLogger(this);
    initialized = true;
}
Also used : IOException(java.io.IOException) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) File(java.io.File) PluginDescriptionFile(org.bukkit.plugin.PluginDescriptionFile) PluginLogger(org.bukkit.plugin.PluginLogger) InvalidConfigurationException(org.bukkit.configuration.InvalidConfigurationException)

Aggregations

File (java.io.File)2 PluginDescriptionFile (org.bukkit.plugin.PluginDescriptionFile)2 PluginLogger (org.bukkit.plugin.PluginLogger)2 DataSourceConfig (com.avaje.ebean.config.DataSourceConfig)1 ServerConfig (com.avaje.ebean.config.ServerConfig)1 IOException (java.io.IOException)1 InvalidConfigurationException (org.bukkit.configuration.InvalidConfigurationException)1 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)1