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));
}
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());
}
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());
}
Aggregations