Skip to content

Commit

Permalink
Remove StoreChannel (#2011)
Browse files Browse the repository at this point in the history
Co-authored-by: V-Play-Games <vaibhavnargwani28@gmail>
Co-authored-by: Florian Spieß <business@minnced.club>
  • Loading branch information
3 people committed Feb 20, 2022
1 parent 33244b6 commit 450d2a0
Show file tree
Hide file tree
Showing 19 changed files with 17 additions and 570 deletions.
39 changes: 11 additions & 28 deletions src/main/java/net/dv8tion/jda/api/entities/Category.java
Expand Up @@ -52,7 +52,6 @@ public interface Category extends GuildChannel, ICopyableChannel, IPositionableC
* All {@link GuildChannel Channels} listed
* for this Category
* <br>This may contain {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels},
* {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels},
* and {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}!
*
* @return Immutable list of all child channels
Expand All @@ -61,7 +60,6 @@ public interface Category extends GuildChannel, ICopyableChannel, IPositionableC
default List<GuildChannel> getChannels()
{
List<GuildChannel> channels = new ArrayList<>();
channels.addAll(getStoreChannels());
channels.addAll(getTextChannels());
channels.addAll(getVoiceChannels());
channels.addAll(getStageChannels());
Expand All @@ -71,22 +69,6 @@ default List<GuildChannel> getChannels()
return Collections.unmodifiableList(channels);
}

/**
* All {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels}
* listed for this Category
*
* @return Immutable list of all child StoreChannels
*
* @since 4.0.0
*/
@Nonnull
default List<StoreChannel> getStoreChannels()
{
return Collections.unmodifiableList(getGuild().getStoreChannelCache().stream()
.filter(channel -> equals(channel.getParentCategory()))
.sorted().collect(Collectors.toList()));
}

/**
* All {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* listed for this Category
Expand Down Expand Up @@ -255,12 +237,12 @@ default List<StageChannel> getStageChannels()
ChannelAction<StageChannel> createStageChannel(@Nonnull String name);

/**
* Modifies the positional order of this Category's nested {@link #getTextChannels() TextChannels} and {@link #getStoreChannels() StoreChannels}.
* Modifies the positional order of this Category's nested {@link #getTextChannels() TextChannels} and {@link #getNewsChannels() NewsChannels}.
* <br>This uses an extension of {@link ChannelOrderAction ChannelOrderAction}
* specialized for ordering the nested {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* and {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels} of this {@link net.dv8tion.jda.api.entities.Category Category}.
* and {@link net.dv8tion.jda.api.entities.NewsChannel NewsChannels} of this {@link net.dv8tion.jda.api.entities.Category Category}.
* <br>Like {@link ChannelOrderAction}, the returned {@link CategoryOrderAction CategoryOrderAction}
* can be used to move TextChannels/StoreChannels {@link OrderAction#moveUp(int) up},
* can be used to move TextChannels/NewsChannels {@link OrderAction#moveUp(int) up},
* {@link OrderAction#moveDown(int) down}, or
* {@link OrderAction#moveTo(int) to} a specific position.
* <br>This uses <b>ascending</b> order with a 0 based index.
Expand All @@ -276,19 +258,19 @@ default List<StageChannel> getStageChannels()
*
* @return A {@link CategoryOrderAction CategoryOrderAction} for
* ordering the Category's {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* and {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels}.
* and {@link net.dv8tion.jda.api.entities.NewsChannel NewsChannels}.
*/
@Nonnull
@CheckReturnValue
CategoryOrderAction modifyTextChannelPositions();

/**
* Modifies the positional order of this Category's nested {@link #getVoiceChannels() VoiceChannels}.
* Modifies the positional order of this Category's nested {@link #getVoiceChannels() VoiceChannels} and {@link #getStageChannels() StageChannels}.
* <br>This uses an extension of {@link ChannelOrderAction ChannelOrderAction}
* specialized for ordering the nested {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels} of this
* {@link net.dv8tion.jda.api.entities.Category Category}.
* <br>Like {@code ChannelOrderAction}, the returned {@link CategoryOrderAction CategoryOrderAction}
* can be used to move VoiceChannels {@link OrderAction#moveUp(int) up},
* specialized for ordering the nested {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}
* and {@link net.dv8tion.jda.api.entities.StageChannel StageChannels} of this {@link net.dv8tion.jda.api.entities.Category Category}.
* <br>Like {@link ChannelOrderAction}, the returned {@link CategoryOrderAction CategoryOrderAction}
* can be used to move VoiceChannels/StageChannels {@link OrderAction#moveUp(int) up},
* {@link OrderAction#moveDown(int) down}, or
* {@link OrderAction#moveTo(int) to} a specific position.
* <br>This uses <b>ascending</b> order with a 0 based index.
Expand All @@ -303,7 +285,8 @@ default List<StageChannel> getStageChannels()
* </ul>
*
* @return A {@link CategoryOrderAction CategoryOrderAction} for
* ordering the Category's {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}.
* ordering the Category's {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}
* and {@link net.dv8tion.jda.api.entities.StageChannel StageChannels}.
*/
@Nonnull
@CheckReturnValue
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/net/dv8tion/jda/api/entities/ChannelType.java
Expand Up @@ -47,10 +47,6 @@ public enum ChannelType
* A {@link net.dv8tion.jda.api.entities.NewsChannel NewsChannel}, Guild-Only.
*/
NEWS(5, 0, true),
/**
* A {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel}, Guild-Only.
*/
STORE(6, 0, true),
/**
* A {@link StageChannel StageChannel}, Guild-Only.
*/
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/net/dv8tion/jda/api/entities/Guild.java
Expand Up @@ -1378,10 +1378,6 @@ default List<Member> getMembersWithRoles(@Nonnull Collection<Role> roles)
@Override
SortedSnowflakeCacheView<Category> getCategoryCache();

@Nonnull
@Override
SortedSnowflakeCacheView<StoreChannel> getStoreChannelCache();

@Nonnull
@Override
SortedSnowflakeCacheView<TextChannel> getTextChannelCache();
Expand All @@ -1401,12 +1397,12 @@ default List<Member> getMembersWithRoles(@Nonnull Collection<Role> roles)
*
* <p>The returned list is ordered in the same fashion as it would be by the official discord client.
* <ol>
* <li>TextChannel and StoreChannel without parent</li>
* <li>TextChannel and NewsChannel without parent</li>
* <li>VoiceChannel without parent</li>
* <li>StageChannel without parent</li>
* <li>Categories
* <ol>
* <li>TextChannel and StoreChannel with category as parent</li>
* <li>TextChannel and NewsChannel with category as parent</li>
* <li>VoiceChannel with category as parent</li>
* <li>StageChannel with category as parent</li>
* </ol>
Expand All @@ -1429,12 +1425,12 @@ default List<GuildChannel> getChannels()
*
* <p>The returned list is ordered in the same fashion as it would be by the official discord client.
* <ol>
* <li>TextChannel and StoreChannel without parent</li>
* <li>TextChannel and NewsChannel without parent</li>
* <li>VoiceChannel without parent</li>
* <li>StageChannel without parent</li>
* <li>Categories
* <ol>
* <li>TextChannel and StoreChannel with category as parent</li>
* <li>TextChannel and NewsChannel with category as parent</li>
* <li>VoiceChannel with category as parent</li>
* <li>StageChannel with category as parent</li>
* </ol>
Expand Down
58 changes: 0 additions & 58 deletions src/main/java/net/dv8tion/jda/api/entities/StoreChannel.java

This file was deleted.

Expand Up @@ -112,7 +112,6 @@ default <T extends Channel> T getChannelById(@Nonnull Class<T> type, long id)
* <li>{@link #getNewsChannelById(String)}</li>
* <li>{@link #getStageChannelById(String)}</li>
* <li>{@link #getVoiceChannelById(String)}</li>
* <li>{@link #getStoreChannelById(String)}</li>
* <li>{@link #getCategoryById(String)}</li>
* </ul>
*
Expand Down Expand Up @@ -149,7 +148,6 @@ default GuildChannel getGuildChannelById(@Nonnull String id)
* <li>{@link #getNewsChannelById(long)}</li>
* <li>{@link #getStageChannelById(long)}</li>
* <li>{@link #getVoiceChannelById(long)}</li>
* <li>{@link #getStoreChannelById(long)}</li>
* <li>{@link #getCategoryById(long)}</li>
* </ul>
*
Expand All @@ -169,8 +167,6 @@ default GuildChannel getGuildChannelById(long id)
channel = getVoiceChannelById(id);
if (channel == null)
channel = getStageChannelById(id);
if (channel == null)
channel = getStoreChannelById(id);
if (channel == null)
channel = getCategoryById(id);
if (channel == null)
Expand Down Expand Up @@ -199,7 +195,6 @@ default GuildChannel getGuildChannelById(long id)
* <li>{@link #getNewsChannelById(String)}</li>
* <li>{@link #getStageChannelById(String)}</li>
* <li>{@link #getVoiceChannelById(String)}</li>
* <li>{@link #getStoreChannelById(String)}</li>
* <li>{@link #getCategoryById(String)}</li>
* </ul>
*
Expand Down Expand Up @@ -241,7 +236,6 @@ default GuildChannel getGuildChannelById(@Nonnull ChannelType type, @Nonnull Str
* <li>{@link #getNewsChannelById(long)}</li>
* <li>{@link #getStageChannelById(long)}</li>
* <li>{@link #getVoiceChannelById(long)}</li>
* <li>{@link #getStoreChannelById(long)}</li>
* <li>{@link #getCategoryById(long)}</li>
* </ul>
*
Expand All @@ -266,8 +260,6 @@ default GuildChannel getGuildChannelById(@Nonnull ChannelType type, long id)
return getVoiceChannelById(id);
case STAGE:
return getStageChannelById(id);
case STORE:
return getStoreChannelById(id);
case CATEGORY:
return getCategoryById(id);
}
Expand Down Expand Up @@ -628,132 +620,6 @@ default List<Category> getCategories()
}


// StoreChannels


/**
* Sorted {@link net.dv8tion.jda.api.utils.cache.SnowflakeCacheView SnowflakeCacheView} of {@link StoreChannel}.
* <br>In {@link Guild} cache, channels are sorted according to their position and id.
*
* <p>This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
* For {@link Guild}, {@link JDA}, or {@link ShardManager},
* this returns the relevant channel with respect to the cache within each of those objects.
* For a guild, this would mean it only returns channels within the same guild.
* <br>If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
* To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
*
* @return {@link net.dv8tion.jda.api.utils.cache.SortedSnowflakeCacheView SortedSnowflakeCacheView}
*
* @since 4.0.0
*/
@Nonnull
SnowflakeCacheView<StoreChannel> getStoreChannelCache();

/**
* Gets a list of all {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels}
* in this Guild that have the same name as the one provided.
* <br>If there are no channels with the provided name, then this returns an empty list.
*
* <p>This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
* For {@link Guild}, {@link JDA}, or {@link ShardManager},
* this returns the relevant channel with respect to the cache within each of those objects.
* For a guild, this would mean it only returns channels within the same guild.
* <br>If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
* To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
*
* @param name
* The name used to filter the returned {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannels}.
* @param ignoreCase
* Determines if the comparison ignores case when comparing. True - case insensitive.
*
* @return Possibly-empty immutable list of all StoreChannels with names that match the provided name.
*
* @since 4.0.0
*/
@Nonnull
default List<StoreChannel> getStoreChannelsByName(@Nonnull String name, boolean ignoreCase)
{
return getStoreChannelCache().getElementsByName(name, ignoreCase);
}

/**
* Gets a {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel} that has the same id as the one provided.
* <br>If there is no channel with an id that matches the provided one, then this returns {@code null}.
*
* <p>This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
* For {@link Guild}, {@link JDA}, or {@link ShardManager},
* this returns the relevant channel with respect to the cache within each of those objects.
* For a guild, this would mean it only returns channels within the same guild.
* <br>If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
* To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
*
* @param id
* The id of the {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel}.
*
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel} with matching id.
*
* @since 4.0.0
*/
@Nullable
default StoreChannel getStoreChannelById(@Nonnull String id)
{
return getStoreChannelCache().getElementById(id);
}

/**
* Gets a {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel} that has the same id as the one provided.
* <br>If there is no channel with an id that matches the provided one, then this returns {@code null}.
*
* <p>This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
* For {@link Guild}, {@link JDA}, or {@link ShardManager},
* this returns the relevant channel with respect to the cache within each of those objects.
* For a guild, this would mean it only returns channels within the same guild.
* <br>If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
* To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
*
* @param id
* The id of the {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel}.
*
* @return Possibly-null {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel} with matching id.
*
* @since 4.0.0
*/
@Nullable
default StoreChannel getStoreChannelById(long id)
{
return getStoreChannelCache().getElementById(id);
}

/**
* Gets all {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel} in the cache.
* <br>In {@link Guild} cache, channels are sorted according to their position and id.
*
* <p>This copies the backing store into a list. This means every call
* creates a new list with O(n) complexity. It is recommended to store this into
* a local variable or use {@link #getStoreChannelCache()} and use its more efficient
* versions of handling these values.
*
* <p>This getter exists on any instance of {@link IGuildChannelContainer} and only checks the caches with the relevant scoping.
* For {@link Guild}, {@link JDA}, or {@link ShardManager},
* this returns the relevant channel with respect to the cache within each of those objects.
* For a guild, this would mean it only returns channels within the same guild.
* <br>If this is called on {@link JDA} or {@link ShardManager}, this may return null immediately after building, because the cache isn't initialized yet.
* To make sure the cache is initialized after building your {@link JDA} instance, you can use {@link JDA#awaitReady()}.
*
* @return An immutable List of all {@link net.dv8tion.jda.api.entities.StoreChannel StoreChannel} in this Guild.
*
* @since 4.0.0
*/
@Nonnull
default List<StoreChannel> getStoreChannels()
{
return getStoreChannelCache().asList();
}


// TextChannels


Expand Down

0 comments on commit 450d2a0

Please sign in to comment.