[AB-8] upgrading to new JDA alpha version 19

cleaning up imports
This commit is contained in:
Sheldan
2022-09-18 15:51:49 +02:00
parent 102209aaca
commit 4e1f9e0018
216 changed files with 682 additions and 704 deletions

View File

@@ -4,20 +4,21 @@ import dev.sheldan.abstracto.statistic.emote.model.database.TrackedEmote;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
/**
* Model which is used to render in emotes for the command `showTrackedEmotes`, which still exist in the server.
* This means there is a {@link Emote} instance available.
* This means there is a {@link RichCustomEmoji} instance available.
*/
@Getter
@Setter
@Builder
public class AvailableTrackedEmote {
/**
* The {@link Emote} instance of the {@link TrackedEmote} to show
* The {@link RichCustomEmoji} instance of the {@link TrackedEmote} to show
*/
private Emote emote;
private CustomEmoji emote;
/**
* The original {@link TrackedEmote} instance from the server to show
*/

View File

@@ -4,10 +4,10 @@ import dev.sheldan.abstracto.statistic.emote.model.database.TrackedEmote;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
/**
* Model used to render the emote stats for various commands. This contains the concrete {@link Emote} (if available).
* Model used to render the emote stats for various commands. This contains the concrete {@link CustomEmoji} (if available).
* This is only the case for emotes from the server. For external and deleted emotes, only {@link EmoteStatsResultDisplay} and
* {@link TrackedEmote} will be available.
*/
@@ -16,9 +16,9 @@ import net.dv8tion.jda.api.entities.Emote;
@Builder
public class EmoteStatsResultDisplay {
/**
* The actual {@link Emote} from the server, if available. Not available for deleted and external emotes.
* The actual {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} from the server, if available. Not available for deleted and external emotes.
*/
private Emote emote;
private CustomEmoji emote;
/**
* The {@link EmoteStatsResult} for one particular emote, containing the amount of times the emote has been used.
*/

View File

@@ -11,7 +11,7 @@ import java.util.List;
/**
* Model used to render the currently tracked emotes of a {@link Guild}. They are split up into
* the static/animated emotes from the server itself. The {@link net.dv8tion.jda.internal.requests.Route.Emotes}
* the static/animated emotes from the server itself. The {@link net.dv8tion.jda.api.entities.emoji.RichCustomEmoji}
* which were previously on the server and (if enabled) all external {@link TrackedEmote} from the server.
*/
@Getter
@@ -80,7 +80,7 @@ public class TrackedEmoteOverview {
} else {
AvailableTrackedEmote availableEmote = AvailableTrackedEmote
.builder()
.emote(guild.getEmoteById(trackedEmote.getTrackedEmoteId().getId()))
.emote(guild.getEmojiById(trackedEmote.getTrackedEmoteId().getId()))
.trackedEmote(trackedEmote)
.build();
if(trackedEmote.getAnimated()) {

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.statistic.emote.service;
import dev.sheldan.abstracto.core.models.cache.CachedEmote;
import dev.sheldan.abstracto.statistic.emote.model.PersistingEmote;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.Guild;
import java.util.List;
@@ -20,19 +19,19 @@ public interface TrackedEmoteRuntimeService {
Map<Long, Map<Long, List<PersistingEmote>>> getRuntimeConfig();
/**
* Adds the given {@link Emote} used in the {@link Guild} to the runtime storage.
* Adds the given {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} used in the {@link Guild} to the runtime storage.
* The necessary lock will be acquired by this method.
* @param emote The {@link Emote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param emote The {@link CachedEmote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} is used
* @param external Whether or not the emote is external
*/
void addEmoteForServer(CachedEmote emote, Guild guild, boolean external);
/**
* Adds the given {@link Emote} used in the {@link Guild} to the runtime storage.
* Adds the given {@link CachedEmote} used in the {@link Guild} to the runtime storage.
* The necessary lock will be acquired by this method.
* @param emote The {@link CachedEmote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param guild The {@link Guild} in which the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} is used
* @param count The amount of usages which should be added
* @param external Whether or not the emote is external
*/
@@ -46,20 +45,20 @@ public interface TrackedEmoteRuntimeService {
/**
* Creates a {@link PersistingEmote} from the given parameters.
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param guild The {@link Guild} in which the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} is used
* @param emote The {@link CachedEmote} to create a {@link PersistingEmote} from
* @param external Whether or not the {@link Emote} is external
* @return A created {@link PersistingEmote} instance from the {@link Emote}
* @param external Whether or not the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} is external
* @return A created {@link PersistingEmote} instance from the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji}
*/
PersistingEmote createFromEmote(Guild guild, CachedEmote emote, boolean external);
/**
* Creates a {@link PersistingEmote} from the given parameters.
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param guild The {@link Guild} in which the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} is used
* @param emote The {@link CachedEmote} to create a {@link PersistingEmote} from
* @param count The amount of usages the {@link Emote} has been used
* @param external Whether or not the {@link Emote} is external
* @return A created {@link PersistingEmote} instance from the {@link Emote}
* @param count The amount of usages the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} has been used
* @param external Whether or not the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji} is external
* @return A created {@link PersistingEmote} instance from the {@link net.dv8tion.jda.api.entities.emoji.CustomEmoji}
*/
PersistingEmote createFromEmote(Guild guild, CachedEmote emote, Long count, boolean external);

View File

@@ -5,8 +5,8 @@ import dev.sheldan.abstracto.statistic.emote.model.PersistingEmote;
import dev.sheldan.abstracto.statistic.emote.model.TrackedEmoteOverview;
import dev.sheldan.abstracto.statistic.emote.model.TrackedEmoteSynchronizationResult;
import dev.sheldan.abstracto.statistic.emote.model.database.TrackedEmote;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
import java.util.List;
import java.util.Map;
@@ -17,27 +17,27 @@ import java.util.Map;
public interface TrackedEmoteService {
/**
* Adds the given list of {@link Emote}s to the runtime storage for the given {@link Guild}
* @param emotes The list of {@link Emote}s to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote}s were used and where the usages should be added
* Adds the given list of {@link CustomEmoji}s to the runtime storage for the given {@link Guild}
* @param emotes The list of {@link CustomEmoji}s to add to the runtime storage
* @param guild The {@link Guild} in which the {@link CustomEmoji}s were used and where the usages should be added
*/
void addEmoteToRuntimeStorage(List<CachedEmote> emotes, Guild guild);
/**
* Adds the given {@link Emote} with the given amount to the runtime storage for the given {@link Guild}
* Adds the given {@link CustomEmoji} with the given amount to the runtime storage for the given {@link Guild}
* @param emote The {@link CachedEmote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote} was used and in which the usage should be added
* @param count The amount of times which the {@link Emote} has been used and should be reflected in the runtime storage
* @param guild The {@link Guild} in which the {@link CustomEmoji} was used and in which the usage should be added
* @param count The amount of times which the {@link CustomEmoji} has been used and should be reflected in the runtime storage
*/
void addEmoteToRuntimeStorage(CachedEmote emote, Guild guild, Long count);
/**
* Adds the given {@link Emote} with the given amount to the runtime storage for the given {@link Guild}
* @param emote The {@link Emote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote} was used and in which the usage should be added
* @param count The amount of times which the {@link Emote} has been used and should be reflected in the runtime storage
* Adds the given {@link CustomEmoji} with the given amount to the runtime storage for the given {@link Guild}
* @param emote The {@link CustomEmoji} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link CustomEmoji} was used and in which the usage should be added
* @param count The amount of times which the {@link CustomEmoji} has been used and should be reflected in the runtime storage
*/
void addEmoteToRuntimeStorage(Emote emote, Guild guild, Long count);
void addEmoteToRuntimeStorage(CustomEmoji emote, Guild guild, Long count);
/**
* Takes the given map of server_ids with the list of {@link PersistingEmote} and stores the objects in the database
@@ -47,28 +47,28 @@ public interface TrackedEmoteService {
void storeEmoteStatistics(Map<Long, List<PersistingEmote>> usagesToStore);
/**
* Creates a fake {@link TrackedEmote} from the given {@link Emote} and {@link Guild}. This {@link TrackedEmote}
* Creates a fake {@link TrackedEmote} from the given {@link CustomEmoji} and {@link Guild}. This {@link TrackedEmote}
* is not persisted and has the fake value set to true
* @param emote The {@link Emote} to be used for the fake {@link TrackedEmote}
* @param emote The {@link CustomEmoji} to be used for the fake {@link TrackedEmote}
* @param guild The {@link Guild} to be used for the fake {@link TrackedEmote}
* @return The fake {@link TrackedEmote} which was created
*/
TrackedEmote getFakeTrackedEmote(Emote emote, Guild guild);
TrackedEmote getFakeTrackedEmote(CustomEmoji emote, Guild guild);
/**
* Creates a fake {@link TrackedEmote} from the given emote ID and server ID. This {@link TrackedEmote}
* is not persisted and has the fake value set to true
* @param emoteId The ID of an {@link Emote}
* @param emoteId The ID of an {@link CustomEmoji}
* @param guild The ID of an {@link dev.sheldan.abstracto.core.models.database.AServer}
* @return The fake {@link TrackedEmote} which was created
*/
TrackedEmote getFakeTrackedEmote(Long emoteId, Guild guild);
/**
* Checks the currently existing {@link Emote}s in the {@link Guild} with the currently {@link TrackedEmote} and synchronizes
* the state. This means: unknown {@link Emote} are created as {@link TrackedEmote} and already existing {@link TrackedEmote}
* Checks the currently existing {@link CustomEmoji}s in the {@link Guild} with the currently {@link TrackedEmote} and synchronizes
* the state. This means: unknown {@link CustomEmoji} are created as {@link TrackedEmote} and already existing {@link TrackedEmote}
* which are not found in the {@link Guild} are marked as deleted.
* @param guild The {@link Guild} to synchronize the {@link Emote} for
* @param guild The {@link Guild} to synchronize the {@link CustomEmoji} for
* @return The {@link TrackedEmoteSynchronizationResult} which contains information about what changed (number of deletions and additions)
*/
TrackedEmoteSynchronizationResult synchronizeTrackedEmotes(Guild guild);
@@ -90,22 +90,22 @@ public interface TrackedEmoteService {
TrackedEmoteOverview loadTrackedEmoteOverview(Guild guild, Boolean showTrackingDisabled);
/**
* Creates a {@link TrackedEmote} from the {@link Emote} based on a usage in {@link Guild}
* This method detects if the {@link Emote} is external or not on its own.
* @param emote The {@link Emote} to create a {@link TrackedEmote} for
* Creates a {@link TrackedEmote} from the {@link CustomEmoji} based on a usage in {@link Guild}
* This method detects if the {@link CustomEmoji} is external or not on its own.
* @param emote The {@link CustomEmoji} to create a {@link TrackedEmote} for
* @param guild The {@link Guild} for which the {@link TrackedEmote} should be created for
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(Emote emote, Guild guild);
TrackedEmote createTrackedEmote(CustomEmoji emote, Guild guild);
/**
* Creates a {@link TrackedEmote} from the {@link Emote} based on a usage in {@link Guild}
* @param emote The {@link Emote} to create a {@link TrackedEmote} for
* Creates a {@link TrackedEmote} from the {@link CustomEmoji} based on a usage in {@link Guild}
* @param emote The {@link CustomEmoji} to create a {@link TrackedEmote} for
* @param guild The {@link Guild} in which the {@link TrackedEmote} should be created for
* @param external Whether or not the {@link Emote} is part of the {@link Guild} or not
* @param external Whether or not the {@link CustomEmoji} is part of the {@link Guild} or not
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(Emote emote, Guild guild, boolean external);
TrackedEmote createTrackedEmote(CustomEmoji emote, Guild guild, boolean external);
/**
* Deletes the referenced {@link TrackedEmote} in the database

View File

@@ -6,8 +6,9 @@ import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.statistic.emote.exception.TrackedEmoteNotFoundException;
import dev.sheldan.abstracto.statistic.emote.model.PersistingEmote;
import dev.sheldan.abstracto.statistic.emote.model.database.TrackedEmote;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.emoji.CustomEmoji;
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
import java.util.List;
import java.util.Optional;
@@ -18,52 +19,52 @@ import java.util.Optional;
public interface TrackedEmoteManagementService {
/**
* Creates and persists a {@link TrackedEmote} for which tracking is enabled with the given individual parameters
* @param emoteId The ID of the {@link Emote} to track
* @param emoteName The name of the {@link Emote} to track
* @param animated Whether or not the {@link Emote} to track is animated
* @param server The {@link AServer} for which the {@link Emote} should be tracked
* @param emoteId The ID of the {@link CustomEmoji} to track
* @param emoteName The name of the {@link CustomEmoji} to track
* @param animated Whether or not the {@link CustomEmoji} to track is animated
* @param server The {@link AServer} for which the {@link CustomEmoji} should be tracked
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(Long emoteId, String emoteName, Boolean animated, AServer server);
/**
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link Emote} and {@link Guild}
* @param emote The {@link Emote} to be used to create a {@link TrackedEmote}
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link CustomEmoji} and {@link Guild}
* @param emote The {@link CustomEmoji} to be used to create a {@link TrackedEmote}
* @param guild The {@link Guild} for which the emote should be tracked for
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(Emote emote, Guild guild);
TrackedEmote createTrackedEmote(CustomEmoji emote, Guild guild);
/**
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link Emote}.
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link CustomEmoji}.
* The emote used here must contain a {@link Guild guild} instance, emotes created from {@link net.dv8tion.jda.api.entities.Message messages}
* do not.
* @param emote The {@link Emote} to be used to create a {@link TrackedEmote}
* @param emote The {@link CustomEmoji} to be used to create a {@link TrackedEmote}
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(Emote emote);
TrackedEmote createTrackedEmote(RichCustomEmoji emote);
/**
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link Emote} and {@link Guild}
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link CustomEmoji} and {@link Guild}
* @param emote The {@link CachedEmote} to be used to create a {@link TrackedEmote}
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(CachedEmote emote);
/**
* Creates and persist a {@link TrackedEmote} for which tracking is enabled based on the given {@link Emote} and {@link Guild}
* @param emote The {@link Emote} to be used to create a {@link TrackedEmote}
* Creates and persist a {@link TrackedEmote} for which tracking is enabled based on the given {@link CustomEmoji} and {@link Guild}
* @param emote The {@link CustomEmoji} to be used to create a {@link TrackedEmote}
* @param guild The {@link Guild} for which the emote should be tracked for
* @param external Whether or not the emote is external
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(Emote emote, Guild guild, boolean external);
TrackedEmote createTrackedEmote(CustomEmoji emote, Guild guild, boolean external);
/**
* Creates and persis a {@link TrackedEmote} based ont he given parameters
* @param emoteId The ID of an {@link Emote}
* @param emoteName The name of an {@link Emote}
* @param animated Whether or not the {@link Emote} is enabled
* @param emoteId The ID of an {@link CustomEmoji}
* @param emoteName The name of an {@link CustomEmoji}
* @param animated Whether or not the {@link CustomEmoji} is enabled
* @param tracked Whether or not the {@link TrackedEmote} should have tracking enabled
* @param server The {@link AServer} for which the {@link TrackedEmote} should be created
* @return The created {@link TrackedEmote} instance in the database
@@ -72,10 +73,10 @@ public interface TrackedEmoteManagementService {
/**
* Creates an {@link TrackedEmote} based on the parameters which is external
* @param emoteId The ID of an {@link Emote}
* @param emoteName the name of an {@link Emote}
* @param externalUrl The URL of the {@link Emote} which should be stored
* @param animated Whether or not the {@link Emote} is external
* @param emoteId The ID of an {@link CustomEmoji}
* @param emoteName the name of an {@link CustomEmoji}
* @param externalUrl The URL of the {@link CustomEmoji} which should be stored
* @param animated Whether or not the {@link CustomEmoji} is external
* @param server The {@link AServer} for which the {@link TrackedEmote} should be created
* @param trackingEnabled Whether or not the {@link TrackedEmote} should have tracking enabled
* @return The created {@link TrackedEmote} instance in the database
@@ -84,9 +85,9 @@ public interface TrackedEmoteManagementService {
/**
* Creates an {@link TrackedEmote} based on the parameters which is not being tracked
* @param emoteId The ID of an {@link Emote}
* @param emoteName The name of an {@link Emote}
* @param animated Whether or not the {@link Emote} is animated
* @param emoteId The ID of an {@link CustomEmoji}
* @param emoteName The name of an {@link CustomEmoji}
* @param animated Whether or not the {@link CustomEmoji} is animated
* @param server The {@link AServer} for which the {@link TrackedEmote} should be created
* @return The created {@link TrackedEmote} instance in the database
*/
@@ -100,28 +101,28 @@ public interface TrackedEmoteManagementService {
TrackedEmote createExternalTrackedEmote(PersistingEmote persistingEmote);
/**
* Creates an external {@link TrackedEmote} based on the {@link Emote} and the {@link Guild}
* @param emote The {@link Emote} to be used to create an external {@link TrackedEmote}
* Creates an external {@link TrackedEmote} based on the {@link CustomEmoji} and the {@link Guild}
* @param emote The {@link CustomEmoji} to be used to create an external {@link TrackedEmote}
* @param guild The {@link Guild} for which the emote should be tracked for
* @return The create {@link TrackedEmote} instance in the database
*/
TrackedEmote createExternalTrackedEmote(Emote emote, Guild guild);
TrackedEmote createExternalTrackedEmote(CustomEmoji emote, Guild guild);
/**
* Marks the {@link TrackedEmote} identified by serverId and emoteId as deleted
* @param serverId The ID of the server to mark the {@link TrackedEmote} as deleted
* @param emoteId The ID of the {@link Emote} to mark the {@link TrackedEmote} as deleted
* @param emoteId The ID of the {@link CustomEmoji} to mark the {@link TrackedEmote} as deleted
* @throws TrackedEmoteNotFoundException if no {@link TrackedEmote} with the given IDs can be found
*/
void markAsDeleted(Long serverId, Long emoteId);
/**
* Marks the {@link Emote emote} as deleted in the database. This {@link Emote emote} must
* Marks the {@link CustomEmoji emote} as deleted in the database. This {@link CustomEmoji emote} must
* not come from a {@link net.dv8tion.jda.api.entities.Message message}, because then the {@link Guild guild}
* is null.
* @throws TrackedEmoteNotFoundException if no {@link TrackedEmote} with the given IDs can be found
*/
void markAsDeleted(Emote emote);
void markAsDeleted(RichCustomEmoji emote);
/**
* Marks the given {@link TrackedEmote} as deleted
@@ -132,24 +133,24 @@ public interface TrackedEmoteManagementService {
/**
* Retrieves a {@link TrackedEmote} by the given emoteID and serverID
* @param emoteId The ID of the {@link AServer} so search for
* @param serverId The ID Of the {@link Emote} to search for
* @param serverId The ID Of the {@link CustomEmoji} to search for
* @return The found {@link TrackedEmote} instance if, one exists
* @throws TrackedEmoteNotFoundException if no {@link TrackedEmote} with the given IDs can be found
*/
TrackedEmote loadByEmoteId(Long emoteId, Long serverId);
/**
* Loads a {@link TrackedEmote} by the given {@link Emote}. The ID necessary for the server is the {@link Guild} from the emote.
* The {@link Emote} must containing a {@link Guild} object, this is not guaranteed, but this implementation relies on it.
* @param emote The {@link Emote} to find a {@link TrackedEmote} for
* Loads a {@link TrackedEmote} by the given {@link CustomEmoji}. The ID necessary for the server is the {@link Guild} from the emote.
* The {@link CustomEmoji} must containing a {@link Guild} object, this is not guaranteed, but this implementation relies on it.
* @param emote The {@link CustomEmoji} to find a {@link TrackedEmote} for
* @return The {@link TrackedEmote} which was found
* @throws TrackedEmoteNotFoundException if no {@link TrackedEmote} with the given IDs can be found
*/
TrackedEmote loadByEmote(Emote emote);
TrackedEmote loadByEmote(RichCustomEmoji emote);
/**
* Checks whether or not a {@link TrackedEmote} with the given emote ID and server ID exists
* @param emoteId The ID of an {@link Emote} to check
* @param emoteId The ID of an {@link CustomEmoji} to check
* @param serverId the ID of an {@link AServer} to check
* @return Whether or not a {@link TrackedEmote} with the given IDs exists
*/
@@ -165,7 +166,7 @@ public interface TrackedEmoteManagementService {
/**
* Searches for a {@link TrackedEmote} by the given emoteId and serverId and returns an {@link Optional} containing the value, if any.
* @param emoteId The ID of the {@link Emote} to search for
* @param emoteId The ID of the {@link CustomEmoji} to search for
* @param serverId The ID of the {@link AServer} to search for
* @return An {@link Optional} containing a {@link TrackedEmote} if it exists, empty otherwise
*/