Search in sources :

Example 6 with EnableException

use of com.djrapitops.plan.exceptions.EnableException in project Plan by plan-player-analytics.

the class ConfigSystem method enable.

@Override
public void enable() {
    try {
        copyDefaults();
        config.reorder(Arrays.asList("Server", "Network", "Plugin", "Database", "Webserver", "Data_gathering", "Time", "Display_options", "Formatting", "World_aliases", "Export", "Plugins"));
        config.save();
        checkWrongTimeZone();
    } catch (IOException e) {
        errorLogger.error(e, ErrorContext.builder().whatToDo("Fix write permissions to " + config.getConfigFilePath()).build());
        throw new EnableException("Failed to save default config: " + e.getMessage(), e);
    }
    theme.enable();
}
Also used : EnableException(com.djrapitops.plan.exceptions.EnableException) IOException(java.io.IOException)

Example 7 with EnableException

use of com.djrapitops.plan.exceptions.EnableException in project Plan by plan-player-analytics.

the class ServerFileLoader method load.

@Override
public Optional<Server> load(ServerUUID loaded) {
    try {
        if (!prepared)
            prepare();
        String serverUUIDString = getString("Server.UUID");
        if (serverUUIDString == null)
            return Optional.empty();
        Integer id = getInteger("Server.ID");
        ServerUUID serverUUID = ServerUUID.fromString(serverUUIDString);
        String name = config.getNode(PluginSettings.SERVER_NAME.getPath()).map(ConfigNode::getString).orElse("Proxy");
        String address = getString("Server.Web_address");
        return Optional.of(new Server(id, serverUUID, name, address, false));
    } catch (IOException e) {
        throw new EnableException("Failed to read ServerInfoFile.yml: " + e.getMessage());
    }
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) EnableException(com.djrapitops.plan.exceptions.EnableException) Server(com.djrapitops.plan.identification.Server) IOException(java.io.IOException)

Example 8 with EnableException

use of com.djrapitops.plan.exceptions.EnableException in project Plan by plan-player-analytics.

the class PlanFiles method enable.

@Override
public void enable() {
    ResourceCache.invalidateAll();
    ResourceCache.cleanUp();
    try {
        Path dir = getDataDirectory();
        if (!Files.isSymbolicLink(dir))
            Files.createDirectories(dir);
        if (!configFile.exists())
            Files.createFile(configFile.toPath());
    } catch (IOException e) {
        throw new EnableException("Failed to create config.yml, " + e.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) EnableException(com.djrapitops.plan.exceptions.EnableException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 9 with EnableException

use of com.djrapitops.plan.exceptions.EnableException in project Plan by plan-player-analytics.

the class BungeeServerInfo method registerServer.

/**
 * @throws EnableException
 */
private Server registerServer() {
    Server proxy = createServerObject();
    fromDatabase.save(proxy);
    Server stored = fromDatabase.load(null).orElseThrow(() -> new EnableException("BungeeCord registration failed (DB)"));
    fromFile.save(stored);
    return stored;
}
Also used : EnableException(com.djrapitops.plan.exceptions.EnableException)

Example 10 with EnableException

use of com.djrapitops.plan.exceptions.EnableException in project Plan by plan-player-analytics.

the class DBSystem method enable.

@Override
public void enable() {
    try {
        db.init();
        logger.info(locale.getString(PluginLang.ENABLED_DATABASE, db.getType().getName()));
    } catch (DBInitException e) {
        Throwable cause = e.getCause();
        String message = cause == null ? e.getMessage() : cause.getMessage();
        throw new EnableException(db.getType().getName() + " init failure: " + message, cause);
    }
}
Also used : EnableException(com.djrapitops.plan.exceptions.EnableException) DBInitException(com.djrapitops.plan.exceptions.database.DBInitException)

Aggregations

EnableException (com.djrapitops.plan.exceptions.EnableException)15 IOException (java.io.IOException)6 Server (com.djrapitops.plan.identification.Server)3 ServerUUID (com.djrapitops.plan.identification.ServerUUID)2 UncheckedIOException (java.io.UncheckedIOException)2 Path (java.nio.file.Path)2 DBInitException (com.djrapitops.plan.exceptions.database.DBInitException)1 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)1 WatchedFile (com.djrapitops.plan.settings.upkeep.WatchedFile)1 DBSystem (com.djrapitops.plan.storage.database.DBSystem)1 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1