use of com.almuradev.almura.feature.title.network.ClientboundTitlesRegistryPacket in project Almura by AlmuraDev.
the class ServerTitleManager method deleteTitle.
public void deleteTitle(final Player player, final String id) {
checkNotNull(player);
checkNotNull(id);
if (!this.getTitle(id).isPresent()) {
// TODO Dockter, we're in a desync...either send them a notification that title deletion failed as it doesn't exist or remove this TODO
this.network.sendTo(player, new ClientboundTitlesRegistryPacket(this.titles.values().stream().filter(title -> {
if (!title.isHidden()) {
return true;
}
return player.hasPermission(Almura.ID + ".title.admin");
}).collect(Collectors.toSet())));
} else {
this.scheduler.createTaskBuilder().async().execute(() -> {
try (final DSLContext context = this.databaseManager.createContext(true)) {
final int result = TitleQueries.createDeleteTitle(id).build(context).keepStatement(false).execute();
final Runnable runnable;
if (result == 0) {
runnable = () -> {
// TODO Dockter, send a notification down to the player that deletion failed
};
} else {
runnable = this::loadTitles;
}
this.scheduler.createTaskBuilder().execute(runnable).submit(this.container);
} catch (SQLException e) {
e.printStackTrace();
}
}).submit(this.container);
}
}
Aggregations