mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-15 04:02:53 +00:00
[SONAR] fixing major sonar issues
This commit is contained in:
@@ -685,8 +685,7 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
||||
|
||||
@Transactional
|
||||
public CompletableFuture<Void> addEmotes(List<CompletableFuture<Message>> assignablePlacePostsMessageFutures, String placeKey) {
|
||||
try {
|
||||
Message firstMessage = assignablePlacePostsMessageFutures.get(0).get();
|
||||
Message firstMessage = assignablePlacePostsMessageFutures.get(0).join();
|
||||
Long serverId = firstMessage.getGuild().getIdLong();
|
||||
|
||||
AServer innerServer = serverManagementService.loadOrCreate(serverId);
|
||||
@@ -696,7 +695,7 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
||||
List<CompletableFuture<Void>> reactionFutures = new ArrayList<>();
|
||||
int usedEmotes = 0;
|
||||
for (CompletableFuture<Message> messageCompletableFuture : assignablePlacePostsMessageFutures) {
|
||||
Message sentMessage = messageCompletableFuture.get();
|
||||
Message sentMessage = messageCompletableFuture.join();
|
||||
// this uses the actual embed count as a limit, so this relies on fields to be used for description, if this changes, this needs to be changed
|
||||
MessageEmbed embed = sentMessage.getEmbeds().get(0);
|
||||
List<AssignableRole> firstRoles = roleStream.subList(usedEmotes, usedEmotes + embed.getFields().size());
|
||||
@@ -709,11 +708,6 @@ public class AssignableRolePlaceServiceBean implements AssignableRolePlaceServic
|
||||
self.storeCreatedAssignableRolePlacePosts(placeKey, serverId, assignablePlacePostsMessageFutures);
|
||||
return CompletableFuture.completedFuture(null);
|
||||
});
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Failed to process future from sending assignable place posts messages.", e);
|
||||
throw new AbstractoRunTimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@@ -30,11 +30,8 @@ public class ServerManagementServiceBean implements ServerManagementService {
|
||||
|
||||
@Override
|
||||
public AServer loadOrCreate(Long id) {
|
||||
if(repository.existsById(id)) {
|
||||
return repository.findById(id).get();
|
||||
} else {
|
||||
return createServer(id);
|
||||
}
|
||||
Optional<AServer> optional = repository.findById(id);
|
||||
return optional.orElseGet(() -> createServer(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,8 @@ import net.dv8tion.jda.api.entities.Member;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class UserManagementServiceBean implements UserManagementService {
|
||||
@@ -29,10 +31,7 @@ public class UserManagementServiceBean implements UserManagementService {
|
||||
|
||||
@Override
|
||||
public AUser loadUser(Long userId) {
|
||||
if(userRepository.existsById(userId)) {
|
||||
return userRepository.findById(userId).get();
|
||||
} else {
|
||||
return this.createUser(userId);
|
||||
}
|
||||
Optional<AUser> optional = userRepository.findById(userId);
|
||||
return optional.orElseGet(() -> this.createUser(userId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user