Search in sources :

Example 11 with EnableException

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

the class ServerFileLoader method save.

@Override
public void save(Server server) {
    try {
        if (!prepared)
            prepare();
        server.getId().ifPresent(id -> set("Server.ID", id));
        set("Server.UUID", server.getUuid());
        set("Server.Web_address", server.getWebAddress());
        save();
    } catch (IOException e) {
        throw new EnableException("Failed to write ServerInfoFile.yml: " + e.getMessage());
    }
}
Also used : EnableException(com.djrapitops.plan.exceptions.EnableException) IOException(java.io.IOException)

Example 12 with EnableException

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

the class BungeeSystemTest method bungeeDoesNotEnableWithDefaultIP.

@Test
void bungeeDoesNotEnableWithDefaultIP() {
    EnableException thrown = assertThrows(EnableException.class, () -> {
        PlanSystem bungeeSystem = component.getPlanSystem();
        try {
            PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
            config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
            config.set(ProxySettings.IP, "0.0.0.0");
            DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
            SQLiteDB db = dbSystem.getSqLiteFactory().usingDefaultFile();
            db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
            dbSystem.setActiveDatabase(db);
            // Throws EnableException
            bungeeSystem.enable();
        } finally {
            bungeeSystem.disable();
        }
    });
    assertEquals("IP setting still 0.0.0.0 - Configure Alternative_IP/IP that connects to the Proxy server.", thrown.getMessage());
}
Also used : DBSystem(com.djrapitops.plan.storage.database.DBSystem) EnableException(com.djrapitops.plan.exceptions.EnableException) SQLiteDB(com.djrapitops.plan.storage.database.SQLiteDB) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 13 with EnableException

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

the class ServerServerInfo method registerNew.

private Server registerNew(ServerUUID serverUUID) {
    Server server = createServerObject(serverUUID);
    logger.info("Registering a new server in database with UUID " + serverUUID);
    fromDatabase.save(server);
    Server stored = fromDatabase.load(serverUUID).orElseThrow(() -> new EnableException("Failed to register server (not found after saving to database)"));
    fromFile.save(stored);
    return stored;
}
Also used : EnableException(com.djrapitops.plan.exceptions.EnableException)

Example 14 with EnableException

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

the class ProxyServerInfo method registerServer.

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) Server(com.djrapitops.plan.identification.Server)

Example 15 with EnableException

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

the class VelocityServerInfo method registerServer.

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

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