Search in sources :

Example 1 with SetServerAsUninstalledTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction in project Plan by plan-player-analytics.

the class DatabaseCommands method onUninstalled.

public void onUninstalled(CMDSender sender, Arguments arguments) {
    ensureDatabaseIsOpen();
    String identifier = arguments.concatenate(" ");
    Server server = dbSystem.getDatabase().query(ServerQueries.fetchServerMatchingIdentifier(identifier)).orElseThrow(() -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_SERVER_NOT_FOUND, identifier)));
    if (server.getUuid().equals(serverInfo.getServerUUID())) {
        throw new IllegalArgumentException(locale.getString(CommandLang.UNINSTALLING_SAME_SERVER));
    }
    dbSystem.getDatabase().executeTransaction(new SetServerAsUninstalledTransaction(server.getUuid()));
    sender.send(locale.getString(CommandLang.PROGRESS_SUCCESS));
    sender.send(locale.getString(CommandLang.DB_UNINSTALLED));
}
Also used : SetServerAsUninstalledTransaction(com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction) Server(com.djrapitops.plan.identification.Server)

Example 2 with SetServerAsUninstalledTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction in project Plan by plan-player-analytics.

the class ServerQueriesTest method uninstallingServerStopsItFromBeingReturnedInServerQuery.

@Test
default void uninstallingServerStopsItFromBeingReturnedInServerQuery() {
    db().executeTransaction(new SetServerAsUninstalledTransaction(serverUUID()));
    Optional<Server> found = db().query(ServerQueries.fetchServerMatchingIdentifier(serverUUID()));
    assertFalse(found.isPresent());
}
Also used : SetServerAsUninstalledTransaction(com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction) Server(com.djrapitops.plan.identification.Server) Test(org.junit.jupiter.api.Test)

Example 3 with SetServerAsUninstalledTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction in project Plan by plan-player-analytics.

the class ServerQueriesTest method uninstallingServerStopsItFromBeingReturnedInServersQuery.

@Test
default void uninstallingServerStopsItFromBeingReturnedInServersQuery() {
    db().executeTransaction(new SetServerAsUninstalledTransaction(serverUUID()));
    Collection<Server> found = db().query(ServerQueries.fetchPlanServerInformationCollection());
    assertTrue(found.isEmpty());
}
Also used : SetServerAsUninstalledTransaction(com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction) Server(com.djrapitops.plan.identification.Server) Test(org.junit.jupiter.api.Test)

Aggregations

Server (com.djrapitops.plan.identification.Server)3 SetServerAsUninstalledTransaction (com.djrapitops.plan.storage.database.transactions.commands.SetServerAsUninstalledTransaction)3 Test (org.junit.jupiter.api.Test)2