mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-01 08:39:31 +01:00
Add some missing nullability annotations
This commit is contained in:
parent
318245c315
commit
ad6b7ee583
@ -86,6 +86,7 @@ public interface DiscordAPI {
|
||||
* @param id the id for the Discord user
|
||||
* @return a future that will result in a {@link DiscordUser} for the id or throw a
|
||||
*/
|
||||
@NotNull
|
||||
CompletableFuture<DiscordUser> retrieveUserById(long id);
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import com.discordsrv.api.DiscordSRVApi;
|
||||
import com.discordsrv.api.discord.api.entity.Snowflake;
|
||||
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -42,6 +43,7 @@ public interface DiscordGuild extends Snowflake {
|
||||
* @return the guild's name
|
||||
*/
|
||||
@Placeholder("server_name")
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
@ -56,12 +58,14 @@ public interface DiscordGuild extends Snowflake {
|
||||
* @param id the id for the Discord guild member
|
||||
* @return the Discord guild member from the cache
|
||||
*/
|
||||
@NotNull
|
||||
Optional<DiscordGuildMember> getMemberById(long id);
|
||||
|
||||
/**
|
||||
* Gets the members of this server that are in the cache.
|
||||
* @return the Discord server members that are currently cached
|
||||
*/
|
||||
@NotNull
|
||||
Set<DiscordGuildMember> getCachedMembers();
|
||||
|
||||
/**
|
||||
@ -69,12 +73,14 @@ public interface DiscordGuild extends Snowflake {
|
||||
* @param id the id for the Discord role
|
||||
* @return the Discord role from the cache
|
||||
*/
|
||||
@NotNull
|
||||
Optional<DiscordRole> getRoleById(long id);
|
||||
|
||||
/**
|
||||
* Gets the roles in this Discord server.
|
||||
* @return an ordered list of the roles in this Discord server
|
||||
*/
|
||||
@NotNull
|
||||
List<DiscordRole> getRoles();
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,7 @@ public interface DiscordGuildMember extends DiscordUser, Mentionable {
|
||||
* Gets the Discord server this member is from.
|
||||
* @return the Discord server this member is from.
|
||||
*/
|
||||
@NotNull
|
||||
DiscordGuild getGuild();
|
||||
|
||||
/**
|
||||
@ -56,6 +57,7 @@ public interface DiscordGuildMember extends DiscordUser, Mentionable {
|
||||
* Gets the roles of this Discord server member.
|
||||
* @return the server member's roles in order from highest to lowest, this does not include the "@everyone" role
|
||||
*/
|
||||
@NotNull
|
||||
List<DiscordRole> getRoles();
|
||||
|
||||
/**
|
||||
@ -63,6 +65,7 @@ public interface DiscordGuildMember extends DiscordUser, Mentionable {
|
||||
* @return the Discord server member's effective name
|
||||
*/
|
||||
@Placeholder("user_effective_name")
|
||||
@NotNull
|
||||
default String getEffectiveName() {
|
||||
return getNickname().orElseGet(this::getUsername);
|
||||
}
|
||||
@ -72,6 +75,7 @@ public interface DiscordGuildMember extends DiscordUser, Mentionable {
|
||||
* @return the user's avatar url in this server
|
||||
*/
|
||||
@Placeholder("user_effective_avatar_url")
|
||||
@NotNull
|
||||
String getEffectiveServerAvatarUrl();
|
||||
|
||||
/**
|
||||
|
@ -45,8 +45,8 @@ public interface DiscordRole extends Snowflake, Mentionable {
|
||||
* Gets the name of the Discord role.
|
||||
* @return the role name
|
||||
*/
|
||||
@NotNull
|
||||
@Placeholder("role_name")
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
@ -62,8 +62,8 @@ public interface DiscordRole extends Snowflake, Mentionable {
|
||||
* @return the color of this role, or {@link #DEFAULT_COLOR} if there is no color set
|
||||
* @see #hasColor()
|
||||
*/
|
||||
@NotNull
|
||||
@Placeholder("role_color")
|
||||
@NotNull
|
||||
Color getColor();
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ public interface ReceivedDiscordMessage extends SendableDiscordMessage, Snowflak
|
||||
* Gets the attachments of this message.
|
||||
* @return this message's attachments
|
||||
*/
|
||||
@NotNull
|
||||
List<Attachment> getAttachments();
|
||||
|
||||
/**
|
||||
@ -65,6 +66,7 @@ public interface ReceivedDiscordMessage extends SendableDiscordMessage, Snowflak
|
||||
* Gets the channel the message was sent in.
|
||||
* @return the channel the message was sent in
|
||||
*/
|
||||
@NotNull
|
||||
DiscordMessageChannel getChannel();
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
package com.discordsrv.api.discord.api.entity.message;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -35,12 +37,14 @@ public interface ReceivedDiscordMessageCluster {
|
||||
* Gets the messages in this cluster.
|
||||
* @return the messages in this cluster
|
||||
*/
|
||||
@NotNull
|
||||
List<? extends ReceivedDiscordMessage> getMessages();
|
||||
|
||||
/**
|
||||
* Deletes all the messages from this cluster, one request per message.
|
||||
* @return a future that fails if any of the requests fail.
|
||||
*/
|
||||
@NotNull
|
||||
CompletableFuture<Void> deleteAll();
|
||||
|
||||
/**
|
||||
@ -48,6 +52,7 @@ public interface ReceivedDiscordMessageCluster {
|
||||
* @param newMessage the new content of the messages
|
||||
* @return a future that fails if any of the requests fail.
|
||||
*/
|
||||
@NotNull
|
||||
CompletableFuture<ReceivedDiscordMessageCluster> editAll(SendableDiscordMessage newMessage);
|
||||
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ public class DiscordAPIImpl implements DiscordAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DiscordUser> retrieveUserById(long id) {
|
||||
public @NotNull CompletableFuture<DiscordUser> retrieveUserById(long id) {
|
||||
JDA jda = discordSRV.jda().orElse(null);
|
||||
if (jda == null) {
|
||||
return notReady();
|
||||
|
@ -25,6 +25,7 @@ import com.discordsrv.common.DiscordSRV;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -44,7 +45,7 @@ public class DiscordGuildImpl implements DiscordGuild {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public @NotNull String getName() {
|
||||
return guild.getName();
|
||||
}
|
||||
|
||||
@ -54,7 +55,7 @@ public class DiscordGuildImpl implements DiscordGuild {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DiscordGuildMember> getMemberById(long id) {
|
||||
public @NotNull Optional<DiscordGuildMember> getMemberById(long id) {
|
||||
Member member = guild.getMemberById(id);
|
||||
if (member == null) {
|
||||
return Optional.empty();
|
||||
@ -64,7 +65,7 @@ public class DiscordGuildImpl implements DiscordGuild {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<DiscordGuildMember> getCachedMembers() {
|
||||
public @NotNull Set<DiscordGuildMember> getCachedMembers() {
|
||||
Set<DiscordGuildMember> members = new HashSet<>();
|
||||
for (Member member : guild.getMembers()) {
|
||||
members.add(new DiscordGuildMemberImpl(discordSRV, member));
|
||||
@ -73,7 +74,7 @@ public class DiscordGuildImpl implements DiscordGuild {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<DiscordRole> getRoleById(long id) {
|
||||
public @NotNull Optional<DiscordRole> getRoleById(long id) {
|
||||
Role role = guild.getRoleById(id);
|
||||
if (role == null) {
|
||||
return Optional.empty();
|
||||
@ -83,7 +84,7 @@ public class DiscordGuildImpl implements DiscordGuild {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiscordRole> getRoles() {
|
||||
public @NotNull List<DiscordRole> getRoles() {
|
||||
List<DiscordRole> roles = new ArrayList<>();
|
||||
for (Role role : guild.getRoles()) {
|
||||
roles.add(new DiscordRoleImpl(role));
|
||||
|
@ -59,7 +59,7 @@ public class DiscordGuildMemberImpl extends DiscordUserImpl implements DiscordGu
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscordGuild getGuild() {
|
||||
public @NotNull DiscordGuild getGuild() {
|
||||
return guild;
|
||||
}
|
||||
|
||||
@ -69,12 +69,12 @@ public class DiscordGuildMemberImpl extends DiscordUserImpl implements DiscordGu
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiscordRole> getRoles() {
|
||||
public @NotNull List<DiscordRole> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEffectiveServerAvatarUrl() {
|
||||
public @NotNull String getEffectiveServerAvatarUrl() {
|
||||
return member.getEffectiveAvatarUrl();
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ package com.discordsrv.common.discord.api.entity.message;
|
||||
import com.discordsrv.api.discord.api.entity.message.ReceivedDiscordMessage;
|
||||
import com.discordsrv.api.discord.api.entity.message.ReceivedDiscordMessageCluster;
|
||||
import com.discordsrv.api.discord.api.entity.message.SendableDiscordMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -35,13 +36,13 @@ public class ReceivedDiscordMessageClusterImpl implements ReceivedDiscordMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReceivedDiscordMessage> getMessages() {
|
||||
public @NotNull List<ReceivedDiscordMessage> getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteAll() {
|
||||
public @NotNull CompletableFuture<Void> deleteAll() {
|
||||
CompletableFuture<Void>[] futures = new CompletableFuture[messages.size()];
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
futures[i] = messages.get(i).delete();
|
||||
@ -52,7 +53,7 @@ public class ReceivedDiscordMessageClusterImpl implements ReceivedDiscordMessage
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public CompletableFuture<ReceivedDiscordMessageCluster> editAll(SendableDiscordMessage newMessage) {
|
||||
public @NotNull CompletableFuture<ReceivedDiscordMessageCluster> editAll(SendableDiscordMessage newMessage) {
|
||||
CompletableFuture<ReceivedDiscordMessage>[] futures = new CompletableFuture[messages.size()];
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
futures[i] = messages.get(i).edit(newMessage);
|
||||
|
@ -218,7 +218,7 @@ public class ReceivedDiscordMessageImpl extends SendableDiscordMessageImpl imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Attachment> getAttachments() {
|
||||
public @NotNull List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ public class ReceivedDiscordMessageImpl extends SendableDiscordMessageImpl imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscordMessageChannel getChannel() {
|
||||
public @NotNull DiscordMessageChannel getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user