Skip to content

Commit

Permalink
Update and remove deprecated symbols (#2686)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment authored Jul 7, 2024
1 parent f4b9092 commit cf00f6c
Show file tree
Hide file tree
Showing 32 changed files with 56 additions and 1,044 deletions.
16 changes: 7 additions & 9 deletions src/main/java/net/dv8tion/jda/api/JDA.java
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,8 @@ default User getUserById(long id)
*
* <p><b>This will only check cached users!</b>
*
* <p>To check users without discriminators, use {@code username#0000} instead.
*
* @param tag
* The Discord Tag in the format {@code Username#Discriminator}
*
Expand All @@ -1035,7 +1037,6 @@ default User getUserById(long id)
* @return The {@link net.dv8tion.jda.api.entities.User} for the discord tag or null if no user has the provided tag
*/
@Nullable
@Incubating
default User getUserByTag(@Nonnull String tag)
{
Checks.notNull(tag, "Tag");
Expand Down Expand Up @@ -1069,16 +1070,13 @@ default User getUserByTag(@Nonnull String tag)
* @return The {@link net.dv8tion.jda.api.entities.User} for the discord tag or null if no user has the provided tag
*/
@Nullable
@Incubating
default User getUserByTag(@Nonnull String username, @Nonnull String discriminator)
default User getUserByTag(@Nonnull String username, @Nullable String discriminator)
{
Checks.notNull(username, "Username");
Checks.notNull(discriminator, "Discriminator");
Checks.check(discriminator.length() == 4 && Helpers.isNumeric(discriminator), "Invalid format for discriminator!");
int codePointLength = Helpers.codePointLength(username);
Checks.check(codePointLength >= 2 && codePointLength <= 32, "Username must be between 2 and 32 codepoints in length!");
Checks.inRange(username, 2, 32, "Username");
Checks.check(discriminator == null || discriminator.length() == 4 && Helpers.isNumeric(discriminator), "Invalid format for discriminator! Provided: %s", discriminator);
String actualDiscriminator = discriminator == null ? "0000" : discriminator;
return getUserCache().applyStream(stream ->
stream.filter(it -> it.getDiscriminator().equals(discriminator))
stream.filter(it -> it.getDiscriminator().equals(actualDiscriminator))
.filter(it -> it.getName().equals(username))
.findFirst()
.orElse(null)
Expand Down
90 changes: 1 addition & 89 deletions src/main/java/net/dv8tion/jda/api/JDABuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package net.dv8tion.jda.api;

import com.neovisionaries.ws.client.WebSocketFactory;
import net.dv8tion.jda.annotations.ForRemoval;
import net.dv8tion.jda.annotations.ReplaceWith;
import net.dv8tion.jda.api.audio.factory.IAudioSendFactory;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.events.Event;
Expand Down Expand Up @@ -547,32 +545,6 @@ public JDABuilder setEventPassthrough(boolean enable)
return setFlag(ConfigFlag.EVENT_PASSTHROUGH, enable);
}

/**
* Whether the rate-limit should be relative to the current time plus latency.
* <br>By default we use the {@code X-RateLimit-Reset-After} header to determine when
* a rate-limit is no longer imminent. This has the disadvantage that it might wait longer than needed due
* to the latency which is ignored by the reset-after relative delay.
*
* <p>When disabled, we will use the {@code X-RateLimit-Reset} absolute timestamp instead which accounts for
* latency but requires a properly NTP synchronized clock to be present.
* If your system does have this feature you might gain a little quicker rate-limit handling than the default allows.
*
* <p>Default: <b>true</b>
*
* @param enable
* True, if the relative {@code X-RateLimit-Reset-After} header should be used.
*
* @return The JDABuilder instance. Useful for chaining.
*/
@Nonnull
@Deprecated
@ForRemoval(deadline = "5.1.0")
@ReplaceWith("setRestConfig(new RestConfig().setRelativeRateLimit(enable))")
public JDABuilder setRelativeRateLimit(boolean enable)
{
return setFlag(ConfigFlag.USE_RELATIVE_RATELIMIT, enable);
}

/**
* Custom {@link RestConfig} to use for this JDA instance.
* <br>This can be used to customize how rate-limits are handled and configure a custom http proxy.
Expand Down Expand Up @@ -903,67 +875,7 @@ public JDABuilder setWebsocketFactory(@Nullable WebSocketFactory factory)
* the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution
* and should be handled carefully. <b>Only change this pool if you know what you're doing.</b>
* <br><b>This automatically disables the automatic shutdown of the rate-limit pool, you can enable
* it using {@link #setRateLimitPool(ScheduledExecutorService, boolean) setRateLimitPool(executor, true)}</b>
*
* <p>This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions.
* Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)}
* and similar methods.
*
* <p>Default: {@link ScheduledThreadPoolExecutor} with 5 threads.
*
* @param pool
* The thread-pool to use for rate-limit handling
*
* @return The JDABuilder instance. Useful for chaining.
*
* @deprecated This pool is now split into two pools.
* You should use {@link #setRateLimitScheduler(ScheduledExecutorService)} and {@link #setRateLimitElastic(ExecutorService)} instead.
*/
@Nonnull
@Deprecated
@ReplaceWith("setRateLimitScheduler(pool)")
public JDABuilder setRateLimitPool(@Nullable ScheduledExecutorService pool)
{
return setRateLimitPool(pool, pool == null);
}

/**
* Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in
* the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution
* and should be handled carefully. <b>Only change this pool if you know what you're doing.</b>
*
* <p>This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions.
* Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)}
* and similar methods.
*
* <p>Default: {@link ScheduledThreadPoolExecutor} with 5 threads.
*
* @param pool
* The thread-pool to use for rate-limit handling
* @param automaticShutdown
* Whether {@link JDA#shutdown()} should shutdown this pool
*
* @return The JDABuilder instance. Useful for chaining.
*
* @deprecated This pool is now split into two pools.
* You should use {@link #setRateLimitScheduler(ScheduledExecutorService, boolean)} and {@link #setRateLimitElastic(ExecutorService, boolean)} instead.
*/
@Nonnull
@Deprecated
@ReplaceWith("setRateLimitScheduler(pool, automaticShutdown)")
public JDABuilder setRateLimitPool(@Nullable ScheduledExecutorService pool, boolean automaticShutdown)
{
this.rateLimitScheduler = pool;
this.shutdownRateLimitScheduler = automaticShutdown;
return this;
}

/**
* Sets the {@link ScheduledExecutorService ScheduledExecutorService} that should be used in
* the JDA rate-limit handler. Changing this can drastically change the JDA behavior for RestAction execution
* and should be handled carefully. <b>Only change this pool if you know what you're doing.</b>
* <br><b>This automatically disables the automatic shutdown of the rate-limit pool, you can enable
* it using {@link #setRateLimitPool(ScheduledExecutorService, boolean) setRateLimitPool(executor, true)}</b>
* it using {@link #setRateLimitScheduler(ScheduledExecutorService, boolean) setRateLimitScheduler(executor, true)}</b>
*
* <p>This is used mostly by the Rate-Limiter to handle backoff delays by using scheduled executions.
* Besides that it is also used by planned execution for {@link net.dv8tion.jda.api.requests.RestAction#queueAfter(long, TimeUnit)}
Expand Down
109 changes: 2 additions & 107 deletions src/main/java/net/dv8tion/jda/api/audio/hooks/ConnectionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package net.dv8tion.jda.api.audio.hooks;

import net.dv8tion.jda.annotations.ForRemoval;
import net.dv8tion.jda.annotations.ReplaceWith;
import net.dv8tion.jda.api.audio.SpeakingMode;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.UserSnowflake;
Expand All @@ -38,7 +36,7 @@ public interface ConnectionListener
* @param ping
* The time, in milliseconds, for round-trip packet travel to discord.
*/
void onPing(long ping);
default void onPing(long ping) {}

/**
* Called when the status of the audio channel changes. Used to track the connection state of the audio connection
Expand All @@ -47,110 +45,7 @@ public interface ConnectionListener
* @param status
* The new {@link net.dv8tion.jda.api.audio.hooks.ConnectionStatus ConnectionStatus} of the audio connection.
*/
void onStatusChange(@Nonnull ConnectionStatus status);

/**
* This method is an easy way to detect if a user is talking. Discord sends us an event when a user starts or stops
* talking and it is parallel to the audio socket, so this event could come milliseconds before or after audio begins
* or stops. This method is brilliant for clients wanting to display that a user is currently talking.
* <p>
* Unlike the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleCombinedAudio(net.dv8tion.jda.api.audio.CombinedAudio)
* AudioReceiveHandler.handleCombinedAudio(CombinedAudio)} and
* {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} methods which are
* fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such
* is only fired when that changes. So while the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} method is fired every time JDA receives audio data from Discord,
* this is only fired when that stream starts and when it stops.
* <br>If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning
* and once after 3 minutes when they stop talking even though the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} method was fired thousands of times over the course of the 3 minutes.
*
* @param user
* Never-null {@link net.dv8tion.jda.api.entities.User User} who's talking status has changed.
* @param speaking
* If true, the user has begun transmitting audio.
*
* @deprecated This method no longer represents the actual speaking state of the user.
* Discord does not send updates when a user starts and stops speaking anymore.
* You can use {@link #onUserSpeakingModeUpdate(UserSnowflake, EnumSet)} to see when a user changes their speaking mode,
* or use an {@link net.dv8tion.jda.api.audio.AudioReceiveHandler AudioReceiveHandler} to check when a user is speaking.
*/
@Deprecated
@ForRemoval
@ReplaceWith("onUserSpeakingModeUpdate(User, EnumSet<SpeakingMode>)")
default void onUserSpeaking(@Nonnull User user, boolean speaking) {}

/**
* This method is an easy way to detect if a user is talking. Discord sends us an event when a user starts or stops
* talking and it is parallel to the audio socket, so this event could come milliseconds before or after audio begins
* or stops. This method is brilliant for clients wanting to display that a user is currently talking.
* <p>
* Unlike the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleCombinedAudio(net.dv8tion.jda.api.audio.CombinedAudio)
* AudioReceiveHandler.handleCombinedAudio(CombinedAudio)} and
* {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} methods which are
* fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such
* is only fired when that changes. So while the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} method is fired every time JDA receives audio data from Discord,
* this is only fired when that stream starts and when it stops.
* <br>If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning
* and once after 3 minutes when they stop talking even though the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} method was fired thousands of times over the course of the 3 minutes.
*
* @param user
* Never-null {@link net.dv8tion.jda.api.entities.User User} who's talking status has changed.
* @param modes
* EnumSet, containing the active speaking modes.
* Empty if the user has stopped transmitting audio.
*
* @see java.util.EnumSet EnumSet
* @see net.dv8tion.jda.api.audio.SpeakingMode SpeakingMode
*
* @deprecated This method no longer represents the actual speaking state of the user.
* Discord does not send updates when a user starts and stops speaking anymore.
* You can use {@link #onUserSpeakingModeUpdate(UserSnowflake, EnumSet)} to see when a user changes their speaking mode,
* or use an {@link net.dv8tion.jda.api.audio.AudioReceiveHandler AudioReceiveHandler} to check when a user is speaking.
*/
@Deprecated
@ForRemoval
@ReplaceWith("onUserSpeakingModeUpdate(User, EnumSet<SpeakingMode>)")
default void onUserSpeaking(@Nonnull User user, @Nonnull EnumSet<SpeakingMode> modes) {}


/**
* This method is an easy way to detect if a user is talking. Discord sends us an event when a user starts or stops
* talking and it is parallel to the audio socket, so this event could come milliseconds before or after audio begins
* or stops. This method is brilliant for clients wanting to display that a user is currently talking.
* <p>
* Unlike the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleCombinedAudio(net.dv8tion.jda.api.audio.CombinedAudio)
* AudioReceiveHandler.handleCombinedAudio(CombinedAudio)} and
* {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} methods which are
* fired extremely often, this method is fired as a flag for the beginning and ending of audio transmission, and as such
* is only fired when that changes. So while the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} method is fired every time JDA receives audio data from Discord,
* this is only fired when that stream starts and when it stops.
* <br>If the user speaks for 3 minutes straight without ever stopping, then this would fire 2 times, once at the beginning
* and once after 3 minutes when they stop talking even though the {@link net.dv8tion.jda.api.audio.AudioReceiveHandler#handleUserAudio(net.dv8tion.jda.api.audio.UserAudio)
* AudioReceiveHandler.handleUserAudio(UserAudio)} method was fired thousands of times over the course of the 3 minutes.
*
* @param user
* Never-null {@link net.dv8tion.jda.api.entities.User User} who's talking status has changed.
* @param speaking
* If true, the user has begun transmitting audio.
* @param soundshare
* If true, the user is using soundshare
*
* @deprecated This method no longer represents the actual speaking state of the user.
* Discord does not send updates when a user starts and stops speaking anymore.
* You can use {@link #onUserSpeakingModeUpdate(UserSnowflake, EnumSet)} to see when a user changes their speaking mode,
* or use an {@link net.dv8tion.jda.api.audio.AudioReceiveHandler AudioReceiveHandler} to check when a user is speaking.
*/
@Deprecated
@ForRemoval
@ReplaceWith("onUserSpeakingModeUpdate(User, EnumSet<SpeakingMode>)")
default void onUserSpeaking(@Nonnull User user, boolean speaking, boolean soundshare) {}
default void onStatusChange(@Nonnull ConnectionStatus status) {}

/**
* This method is used to listen for users changing their speaking mode.
Expand Down
23 changes: 0 additions & 23 deletions src/main/java/net/dv8tion/jda/api/audio/hooks/ListenerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,6 @@ public void onStatusChange(@Nonnull ConnectionStatus status)
}
}

@Override
public void onUserSpeaking(@Nonnull User user, @Nonnull EnumSet<SpeakingMode> modes)
{
if (listener == null)
return;
ConnectionListener listener = this.listener;
try
{
if (listener != null)
{
listener.onUserSpeaking(user, modes);
listener.onUserSpeaking(user, modes.contains(SpeakingMode.VOICE));
listener.onUserSpeaking(user, modes.contains(SpeakingMode.VOICE), modes.contains(SpeakingMode.SOUNDSHARE));
}
}
catch (Throwable t)
{
log.error("The ConnectionListener encountered and uncaught exception", t);
if (t instanceof Error)
throw (Error) t;
}
}

@Override
public void onUserSpeakingModeUpdate(@Nonnull UserSnowflake user, @Nonnull EnumSet<SpeakingMode> modes)
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/dv8tion/jda/api/audit/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public enum ActionType
* <p><b>Possible Keys</b><br>
* <ul>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_NAME THREAD_NAME}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_SLOWMODE THREAD_SLOWMODE}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#CHANNEL_SLOWMODE CHANNEL_SLOWMODE}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_ARCHIVED THREAD_ARCHIVED}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_AUTO_ARCHIVE_DURATION THREAD_AUTO_ARCHIVE_DURATION}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_LOCKED THREAD_LOCKED}</li>
Expand All @@ -567,7 +567,7 @@ public enum ActionType
* <p><b>Possible Keys</b><br>
* <ul>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_NAME THREAD_NAME}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_SLOWMODE THREAD_SLOWMODE}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#CHANNEL_SLOWMODE CHANNEL_SLOWMODE}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_ARCHIVED THREAD_ARCHIVED}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_AUTO_ARCHIVE_DURATION THREAD_AUTO_ARCHIVE_DURATION}</li>
* <li>{@link net.dv8tion.jda.api.audit.AuditLogKey#THREAD_LOCKED THREAD_LOCKED}</li>
Expand Down
Loading

0 comments on commit cf00f6c

Please sign in to comment.