From 450d2a05e40ce727a60fd89e0ef869ad2cf0041c Mon Sep 17 00:00:00 2001 From: V Play Games <74888319+V-Play-Games@users.noreply.github.com> Date: Sun, 20 Feb 2022 22:29:05 +0530 Subject: [PATCH] Remove StoreChannel (#2011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: V-Play-Games Co-authored-by: Florian Spieß --- .../dv8tion/jda/api/entities/Category.java | 39 ++--- .../dv8tion/jda/api/entities/ChannelType.java | 4 - .../net/dv8tion/jda/api/entities/Guild.java | 12 +- .../jda/api/entities/StoreChannel.java | 58 -------- .../channel/IGuildChannelContainer.java | 134 ------------------ .../guild/invite/GenericGuildInviteEvent.java | 19 --- .../GenericPermissionOverrideEvent.java | 19 --- .../channel/concrete/StoreChannelManager.java | 32 ----- .../jda/api/sharding/ShardManager.java | 6 - .../net/dv8tion/jda/internal/JDAImpl.java | 13 -- .../jda/internal/entities/EntityBuilder.java | 41 ------ .../jda/internal/entities/GuildImpl.java | 21 +-- .../internal/entities/StoreChannelImpl.java | 107 -------------- .../internal/handle/ChannelCreateHandler.java | 1 - .../internal/handle/ChannelDeleteHandler.java | 17 --- .../internal/handle/ChannelUpdateHandler.java | 26 ---- .../internal/handle/GuildDeleteHandler.java | 7 +- .../concrete/StoreChannelManagerImpl.java | 30 ---- .../internal/requests/WebSocketClient.java | 1 - 19 files changed, 17 insertions(+), 570 deletions(-) delete mode 100644 src/main/java/net/dv8tion/jda/api/entities/StoreChannel.java delete mode 100644 src/main/java/net/dv8tion/jda/api/managers/channel/concrete/StoreChannelManager.java delete mode 100644 src/main/java/net/dv8tion/jda/internal/entities/StoreChannelImpl.java delete mode 100644 src/main/java/net/dv8tion/jda/internal/managers/channel/concrete/StoreChannelManagerImpl.java diff --git a/src/main/java/net/dv8tion/jda/api/entities/Category.java b/src/main/java/net/dv8tion/jda/api/entities/Category.java index d7be2038ce..4f42078bf7 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Category.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Category.java @@ -52,7 +52,6 @@ public interface Category extends GuildChannel, ICopyableChannel, IPositionableC * All {@link GuildChannel Channels} listed * for this Category *
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 @@ -61,7 +60,6 @@ public interface Category extends GuildChannel, ICopyableChannel, IPositionableC default List getChannels() { List channels = new ArrayList<>(); - channels.addAll(getStoreChannels()); channels.addAll(getTextChannels()); channels.addAll(getVoiceChannels()); channels.addAll(getStageChannels()); @@ -71,22 +69,6 @@ default List 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 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 @@ -255,12 +237,12 @@ default List getStageChannels() ChannelAction 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}. *
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}. *
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. *
This uses ascending order with a 0 based index. @@ -276,19 +258,19 @@ default List 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}. *
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}. - *
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}. + *
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. *
This uses ascending order with a 0 based index. @@ -303,7 +285,8 @@ default List getStageChannels() * * * @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 diff --git a/src/main/java/net/dv8tion/jda/api/entities/ChannelType.java b/src/main/java/net/dv8tion/jda/api/entities/ChannelType.java index 6a38cfa66c..e5808b9f16 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/ChannelType.java +++ b/src/main/java/net/dv8tion/jda/api/entities/ChannelType.java @@ -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. */ diff --git a/src/main/java/net/dv8tion/jda/api/entities/Guild.java b/src/main/java/net/dv8tion/jda/api/entities/Guild.java index d16aba952a..165c13183c 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Guild.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Guild.java @@ -1378,10 +1378,6 @@ default List getMembersWithRoles(@Nonnull Collection roles) @Override SortedSnowflakeCacheView getCategoryCache(); - @Nonnull - @Override - SortedSnowflakeCacheView getStoreChannelCache(); - @Nonnull @Override SortedSnowflakeCacheView getTextChannelCache(); @@ -1401,12 +1397,12 @@ default List getMembersWithRoles(@Nonnull Collection roles) * *

The returned list is ordered in the same fashion as it would be by the official discord client. *

    - *
  1. TextChannel and StoreChannel without parent
  2. + *
  3. TextChannel and NewsChannel without parent
  4. *
  5. VoiceChannel without parent
  6. *
  7. StageChannel without parent
  8. *
  9. Categories *
      - *
    1. TextChannel and StoreChannel with category as parent
    2. + *
    3. TextChannel and NewsChannel with category as parent
    4. *
    5. VoiceChannel with category as parent
    6. *
    7. StageChannel with category as parent
    8. *
    @@ -1429,12 +1425,12 @@ default List getChannels() * *

    The returned list is ordered in the same fashion as it would be by the official discord client. *

      - *
    1. TextChannel and StoreChannel without parent
    2. + *
    3. TextChannel and NewsChannel without parent
    4. *
    5. VoiceChannel without parent
    6. *
    7. StageChannel without parent
    8. *
    9. Categories *
        - *
      1. TextChannel and StoreChannel with category as parent
      2. + *
      3. TextChannel and NewsChannel with category as parent
      4. *
      5. VoiceChannel with category as parent
      6. *
      7. StageChannel with category as parent
      8. *
      diff --git a/src/main/java/net/dv8tion/jda/api/entities/StoreChannel.java b/src/main/java/net/dv8tion/jda/api/entities/StoreChannel.java deleted file mode 100644 index 0a1bc25305..0000000000 --- a/src/main/java/net/dv8tion/jda/api/entities/StoreChannel.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.dv8tion.jda.api.entities; - -import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.managers.channel.concrete.StoreChannelManager; -import net.dv8tion.jda.api.requests.restaction.ChannelAction; - -import javax.annotation.Nonnull; - -/** - * Represents a Discord Store GuildChannel. - * - * @since 4.0.0 - * - * @see Guild#getStoreChannelCache() - * @see Guild#getStoreChannels() - * @see Guild#getStoreChannelsByName(String, boolean) - * @see Guild#getStoreChannelById(long) - * - * @see JDA#getStoreChannelCache() - * @see JDA#getStoreChannels() - * @see JDA#getStoreChannelsByName(String, boolean) - * @see JDA#getStoreChannelById(long) - */ -//TODO-v5: We're probably going to remove this entity as Discord has deprecated it. -public interface StoreChannel extends GuildChannel, ICategorizableChannel, IPositionableChannel, ICopyableChannel, IPermissionContainer, IMemberContainer -{ - - @Nonnull - @Override - ChannelAction createCopy(@Nonnull Guild guild); - - @Nonnull - @Override - default ChannelAction createCopy() - { - return createCopy(getGuild()); - } - - @Override - @Nonnull - StoreChannelManager getManager(); -} diff --git a/src/main/java/net/dv8tion/jda/api/entities/channel/IGuildChannelContainer.java b/src/main/java/net/dv8tion/jda/api/entities/channel/IGuildChannelContainer.java index 83d9735c66..13b74c7ac7 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/channel/IGuildChannelContainer.java +++ b/src/main/java/net/dv8tion/jda/api/entities/channel/IGuildChannelContainer.java @@ -112,7 +112,6 @@ default T getChannelById(@Nonnull Class type, long id) *
    10. {@link #getNewsChannelById(String)}
    11. *
    12. {@link #getStageChannelById(String)}
    13. *
    14. {@link #getVoiceChannelById(String)}
    15. - *
    16. {@link #getStoreChannelById(String)}
    17. *
    18. {@link #getCategoryById(String)}
    19. * * @@ -149,7 +148,6 @@ default GuildChannel getGuildChannelById(@Nonnull String id) *
    20. {@link #getNewsChannelById(long)}
    21. *
    22. {@link #getStageChannelById(long)}
    23. *
    24. {@link #getVoiceChannelById(long)}
    25. - *
    26. {@link #getStoreChannelById(long)}
    27. *
    28. {@link #getCategoryById(long)}
    29. * * @@ -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) @@ -199,7 +195,6 @@ default GuildChannel getGuildChannelById(long id) *
    30. {@link #getNewsChannelById(String)}
    31. *
    32. {@link #getStageChannelById(String)}
    33. *
    34. {@link #getVoiceChannelById(String)}
    35. - *
    36. {@link #getStoreChannelById(String)}
    37. *
    38. {@link #getCategoryById(String)}
    39. * * @@ -241,7 +236,6 @@ default GuildChannel getGuildChannelById(@Nonnull ChannelType type, @Nonnull Str *
    40. {@link #getNewsChannelById(long)}
    41. *
    42. {@link #getStageChannelById(long)}
    43. *
    44. {@link #getVoiceChannelById(long)}
    45. - *
    46. {@link #getStoreChannelById(long)}
    47. *
    48. {@link #getCategoryById(long)}
    49. * * @@ -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); } @@ -628,132 +620,6 @@ default List getCategories() } - // StoreChannels - - - /** - * Sorted {@link net.dv8tion.jda.api.utils.cache.SnowflakeCacheView SnowflakeCacheView} of {@link StoreChannel}. - *
      In {@link Guild} cache, channels are sorted according to their position and id. - * - *

      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. - *
      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 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. - *
      If there are no channels with the provided name, then this returns an empty list. - * - *

      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. - *
      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 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. - *
      If there is no channel with an id that matches the provided one, then this returns {@code null}. - * - *

      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. - *
      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. - *
      If there is no channel with an id that matches the provided one, then this returns {@code null}. - * - *

      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. - *
      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. - *
      In {@link Guild} cache, channels are sorted according to their position and id. - * - *

      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. - * - *

      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. - *
      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 getStoreChannels() - { - return getStoreChannelCache().asList(); - } - - // TextChannels diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/invite/GenericGuildInviteEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/invite/GenericGuildInviteEvent.java index 3331edc348..5c861e466c 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/invite/GenericGuildInviteEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/invite/GenericGuildInviteEvent.java @@ -167,25 +167,6 @@ public StageChannel getStageChannel() return (StageChannel) getChannel(); } - /** - * The {@link StoreChannel} this invite points to. - * - * @throws IllegalStateException - * If this did not happen in a channel of type {@link ChannelType#STORE ChannelType.STORE} - * - * @return {@link StoreChannel} - * - * @see #getChannel() - * @see #getChannelType() - */ - @Nonnull - public StoreChannel getStoreChannel() - { - if (getChannelType() != ChannelType.STORE) - throw new IllegalStateException("The channel is not of type STORE"); - return (StoreChannel) getChannel(); - } - /** * The {@link Category} this invite points to. * diff --git a/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java b/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java index 58382b7cf3..ca1a26f158 100644 --- a/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java +++ b/src/main/java/net/dv8tion/jda/api/events/guild/override/GenericPermissionOverrideEvent.java @@ -121,25 +121,6 @@ public VoiceChannel getVoiceChannel() throw new IllegalStateException("This override is for a channel of type " + getChannelType()); } - /** - * The {@link StoreChannel} this override belongs to. - * - * @throws IllegalStateException - * If the override does not belong to a StoreChannel - * - * @return {@link StoreChannel} - * - * @see #getChannel() - * @see #getChannelType() - */ - @Nonnull - public StoreChannel getStoreChannel() - { - if (channel instanceof StoreChannel) - return (StoreChannel) channel; - throw new IllegalStateException("This override is for a channel of type " + getChannelType()); - } - /** * The {@link Category} this override belongs to. *
      Note: This is not the same as {@code getChannel().getParentCategory()}! diff --git a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/StoreChannelManager.java b/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/StoreChannelManager.java deleted file mode 100644 index 3355650f43..0000000000 --- a/src/main/java/net/dv8tion/jda/api/managers/channel/concrete/StoreChannelManager.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.dv8tion.jda.api.managers.channel.concrete; - -import net.dv8tion.jda.api.entities.StoreChannel; -import net.dv8tion.jda.api.managers.channel.ChannelManager; -import net.dv8tion.jda.api.managers.channel.attribute.ICategorizableChannelManager; -import net.dv8tion.jda.api.managers.channel.attribute.IPermissionContainerManager; -import net.dv8tion.jda.api.managers.channel.attribute.IPositionableChannelManager; - -//TODO-v5: Remove when we remove StoreChannels -public interface StoreChannelManager extends - ChannelManager, - IPermissionContainerManager, - IPositionableChannelManager, - ICategorizableChannelManager -{ -} diff --git a/src/main/java/net/dv8tion/jda/api/sharding/ShardManager.java b/src/main/java/net/dv8tion/jda/api/sharding/ShardManager.java index 6a978c5944..c6b4f4eda0 100644 --- a/src/main/java/net/dv8tion/jda/api/sharding/ShardManager.java +++ b/src/main/java/net/dv8tion/jda/api/sharding/ShardManager.java @@ -779,12 +779,6 @@ default SnowflakeCacheView getVoiceChannelCache() return CacheView.allSnowflakes(() -> this.getShardCache().stream().map(JDA::getVoiceChannelCache)); } - @Nonnull - default SnowflakeCacheView getStoreChannelCache() - { - return CacheView.allSnowflakes(() -> this.getShardCache().stream().map(JDA::getStoreChannelCache)); - } - @Nonnull @Override default SnowflakeCacheView getStageChannelCache() diff --git a/src/main/java/net/dv8tion/jda/internal/JDAImpl.java b/src/main/java/net/dv8tion/jda/internal/JDAImpl.java index da5c72ee5f..6d9a1d089a 100644 --- a/src/main/java/net/dv8tion/jda/internal/JDAImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/JDAImpl.java @@ -97,7 +97,6 @@ public class JDAImpl implements JDA protected final SnowflakeCacheViewImpl userCache = new SnowflakeCacheViewImpl<>(User.class, User::getName); protected final SnowflakeCacheViewImpl guildCache = new SnowflakeCacheViewImpl<>(Guild.class, Guild::getName); protected final SnowflakeCacheViewImpl categories = new SnowflakeCacheViewImpl<>(Category.class, Channel::getName); - protected final SnowflakeCacheViewImpl storeChannelCache = new SnowflakeCacheViewImpl<>(StoreChannel.class, Channel::getName); protected final SnowflakeCacheViewImpl textChannelCache = new SnowflakeCacheViewImpl<>(TextChannel.class, Channel::getName); protected final SnowflakeCacheViewImpl newsChannelCache = new SnowflakeCacheViewImpl<>(NewsChannel.class, Channel::getName); protected final SnowflakeCacheViewImpl voiceChannelCache = new SnowflakeCacheViewImpl<>(VoiceChannel.class, Channel::getName); @@ -628,13 +627,6 @@ public SnowflakeCacheView getCategoryCache() return categories; } - @Nonnull - @Override - public SnowflakeCacheView getStoreChannelCache() - { - return storeChannelCache; - } - @Nonnull @Override public SnowflakeCacheView getTextChannelCache() @@ -1099,11 +1091,6 @@ public SnowflakeCacheViewImpl getCategoriesView() return categories; } - public SnowflakeCacheViewImpl getStoreChannelsView() - { - return storeChannelCache; - } - public SnowflakeCacheViewImpl getTextChannelsView() { return textChannelCache; diff --git a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java index 2b73301363..e8b9a623bd 100644 --- a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java +++ b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java @@ -331,9 +331,6 @@ private void createGuildChannel(GuildImpl guildObj, DataObject channelData) case CATEGORY: createCategory(guildObj, channelData, guildObj.getIdLong()); break; - case STORE: - createStoreChannel(guildObj, channelData, guildObj.getIdLong()); - break; default: LOG.debug("Cannot create channel for type " + channelData.getInt("type")); } @@ -939,44 +936,6 @@ public Category createCategory(GuildImpl guild, DataObject json, long guildId) return channel; } - public StoreChannel createStoreChannel(DataObject json, long guildId) - { - return createStoreChannel(null, json, guildId); - } - - public StoreChannel createStoreChannel(GuildImpl guild, DataObject json, long guildId) - { - boolean playbackCache = false; - final long id = json.getLong("id"); - StoreChannelImpl channel = (StoreChannelImpl) getJDA().getStoreChannelsView().get(id); - if (channel == null) - { - if (guild == null) - guild = (GuildImpl) getJDA().getGuildById(guildId); - SnowflakeCacheViewImpl - guildStoreView = guild.getStoreChannelView(), - storeView = getJDA().getStoreChannelsView(); - try ( - UnlockHook glock = guildStoreView.writeLock(); - UnlockHook jlock = storeView.writeLock()) - { - channel = new StoreChannelImpl(id, guild); - guildStoreView.getMap().put(id, channel); - playbackCache = storeView.getMap().put(id, channel) == null; - } - } - - channel - .setParentCategory(json.getLong("parent_id", 0)) - .setName(json.getString("name")) - .setPosition(json.getInt("position")); - - createOverridesPass(channel, json.getArray("permission_overwrites")); - if (playbackCache) - getJDA().getEventCache().playbackCache(EventCache.Type.CHANNEL, id); - return channel; - } - public TextChannel createTextChannel(DataObject json, long guildId) { return createTextChannel(null, json, guildId); diff --git a/src/main/java/net/dv8tion/jda/internal/entities/GuildImpl.java b/src/main/java/net/dv8tion/jda/internal/entities/GuildImpl.java index b4b72cf454..43e8c8c0b2 100644 --- a/src/main/java/net/dv8tion/jda/internal/entities/GuildImpl.java +++ b/src/main/java/net/dv8tion/jda/internal/entities/GuildImpl.java @@ -79,7 +79,6 @@ public class GuildImpl implements Guild private final SortedSnowflakeCacheViewImpl categoryCache = new SortedSnowflakeCacheViewImpl<>(Category.class, Channel::getName, Comparator.naturalOrder()); private final SortedSnowflakeCacheViewImpl voiceChannelCache = new SortedSnowflakeCacheViewImpl<>(VoiceChannel.class, Channel::getName, Comparator.naturalOrder()); - private final SortedSnowflakeCacheViewImpl storeChannelCache = new SortedSnowflakeCacheViewImpl<>(StoreChannel.class, Channel::getName, Comparator.naturalOrder()); private final SortedSnowflakeCacheViewImpl textChannelCache = new SortedSnowflakeCacheViewImpl<>(TextChannel.class, Channel::getName, Comparator.naturalOrder()); private final SortedSnowflakeCacheViewImpl newsChannelCache = new SortedSnowflakeCacheViewImpl<>(NewsChannel.class, Channel::getName, Comparator.naturalOrder()); private final SortedSnowflakeCacheViewImpl stageChannelCache = new SortedSnowflakeCacheViewImpl<>(StageChannel.class, Channel::getName, Comparator.naturalOrder()); @@ -567,13 +566,6 @@ public SortedSnowflakeCacheView getCategoryCache() return categoryCache; } - @Nonnull - @Override - public SortedSnowflakeCacheView getStoreChannelCache() - { - return storeChannelCache; - } - @Nonnull @Override public SortedSnowflakeCacheView getTextChannelCache() @@ -642,10 +634,8 @@ public List getChannels(boolean includeHidden) SnowflakeCacheViewImpl stageView = getStageChannelsView(); SnowflakeCacheViewImpl textView = getTextChannelsView(); SnowflakeCacheViewImpl newsView = getNewsChannelView(); - SnowflakeCacheViewImpl storeView = getStoreChannelView(); List textChannels; List newsChannels; - List storeChannels; List voiceChannels; List stageChannels; List categories; @@ -653,12 +643,10 @@ public List getChannels(boolean includeHidden) UnlockHook voiceHook = voiceView.readLock(); UnlockHook textHook = textView.readLock(); UnlockHook newsHook = newsView.readLock(); - UnlockHook storeHook = storeView.readLock(); UnlockHook stageHook = stageView.readLock()) { if (includeHidden) { - storeChannels = storeView.asList(); textChannels = textView.asList(); newsChannels = newsView.asList(); voiceChannels = voiceView.asList(); @@ -666,17 +654,15 @@ public List getChannels(boolean includeHidden) } else { - storeChannels = storeView.stream().filter(filterHidden).collect(Collectors.toList()); textChannels = textView.stream().filter(filterHidden).collect(Collectors.toList()); newsChannels = newsView.stream().filter(filterHidden).collect(Collectors.toList()); voiceChannels = voiceView.stream().filter(filterHidden).collect(Collectors.toList()); stageChannels = stageView.stream().filter(filterHidden).collect(Collectors.toList()); } categories = categoryView.asList(); // we filter categories out when they are empty (no visible channels inside) - channels = new ArrayList<>((int) categoryView.size() + voiceChannels.size() + textChannels.size() + newsChannels.size() + storeChannels.size() + stageChannels.size()); + channels = new ArrayList<>((int) categoryView.size() + voiceChannels.size() + textChannels.size() + newsChannels.size() + stageChannels.size()); } - storeChannels.stream().filter(it -> it.getParentCategory() == null).forEach(channels::add); textChannels.stream().filter(it -> it.getParentCategory() == null).forEach(channels::add); newsChannels.stream().filter(it -> it.getParentCategory() == null).forEach(channels::add); voiceChannels.stream().filter(it -> it.getParentCategory() == null).forEach(channels::add); @@ -1977,11 +1963,6 @@ public SortedSnowflakeCacheViewImpl getCategoriesView() return categoryCache; } - public SortedSnowflakeCacheViewImpl getStoreChannelView() - { - return storeChannelCache; - } - public SortedSnowflakeCacheViewImpl getTextChannelsView() { return textChannelCache; diff --git a/src/main/java/net/dv8tion/jda/internal/entities/StoreChannelImpl.java b/src/main/java/net/dv8tion/jda/internal/entities/StoreChannelImpl.java deleted file mode 100644 index 32bae21971..0000000000 --- a/src/main/java/net/dv8tion/jda/internal/entities/StoreChannelImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.dv8tion.jda.internal.entities; - -import gnu.trove.map.TLongObjectMap; -import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.managers.channel.concrete.StoreChannelManager; -import net.dv8tion.jda.api.requests.restaction.ChannelAction; -import net.dv8tion.jda.api.utils.MiscUtil; -import net.dv8tion.jda.internal.entities.mixin.channel.attribute.ICategorizableChannelMixin; -import net.dv8tion.jda.internal.entities.mixin.channel.attribute.IPermissionContainerMixin; -import net.dv8tion.jda.internal.entities.mixin.channel.attribute.IPositionableChannelMixin; - -import javax.annotation.Nonnull; -import java.util.Collections; -import java.util.List; - -//TODO-v5: Remove this class entirely. -public class StoreChannelImpl extends AbstractGuildChannelImpl implements - StoreChannel, - IPermissionContainerMixin, - IPositionableChannelMixin, - ICategorizableChannelMixin -{ - public StoreChannelImpl(long id, GuildImpl guild) - { - super(id, guild); - } - - @Nonnull - @Override - public ChannelType getType() - { - return ChannelType.STORE; - } - - @Override - public long getParentCategoryIdLong() - { - return 0; - } - - @Override - public int getPositionRaw() - { - return 0; - } - - @Nonnull - @Override - public List getMembers() - { - return Collections.emptyList(); - } - - @Nonnull - @Override - public ChannelAction createCopy(@Nonnull Guild guild) - { - throw new UnsupportedOperationException(); - } - - @Nonnull - @Override - public StoreChannelManager getManager() - { - throw new UnsupportedOperationException(); - } - - @Override - public TLongObjectMap getPermissionOverrideMap() - { - return MiscUtil.newLongMap(); - } - - @Override - public StoreChannelImpl setParentCategory(long parentCategoryId) - { - return this; - } - - @Override - public StoreChannelImpl setPosition(int position) - { - return this; - } - - @Override - public String toString() - { - return "SC:" + getName() + '(' + getId() + ')'; - } -} diff --git a/src/main/java/net/dv8tion/jda/internal/handle/ChannelCreateHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/ChannelCreateHandler.java index ed5740a5bb..a34cba92aa 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/ChannelCreateHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/ChannelCreateHandler.java @@ -63,7 +63,6 @@ private Channel buildChannel(ChannelType type, DataObject content, long guildId) { case TEXT: return builder.createTextChannel(content, guildId); case NEWS: return builder.createNewsChannel(content, guildId); - case STORE: return builder.createStoreChannel(content, guildId); case VOICE: return builder.createVoiceChannel(content, guildId); case STAGE: return builder.createStageChannel(content, guildId); case CATEGORY: return builder.createCategory(content, guildId); diff --git a/src/main/java/net/dv8tion/jda/internal/handle/ChannelDeleteHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/ChannelDeleteHandler.java index bd9f55264a..5036f3ecab 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/ChannelDeleteHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/ChannelDeleteHandler.java @@ -49,23 +49,6 @@ protected Long handleInternally(DataObject content) switch (type) { - case STORE: - { - //TODO-v5-unified-channel-cache: We can put all the removals at the top once we have a unified channel cache - StoreChannel channel = getJDA().getStoreChannelsView().remove(channelId); - if (channel == null || guild == null) - { - WebSocketClient.LOG.debug("CHANNEL_DELETE attempted to delete a store channel that is not yet cached. JSON: {}", content); - return null; - } - - guild.getStoreChannelView().remove(channelId); - getJDA().handleEvent( - new ChannelDeleteEvent( - getJDA(), responseNumber, - channel)); - break; - } case TEXT: { TextChannel channel = getJDA().getTextChannelsView().remove(channelId); diff --git a/src/main/java/net/dv8tion/jda/internal/handle/ChannelUpdateHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/ChannelUpdateHandler.java index 66f24c6570..831c7aac3d 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/ChannelUpdateHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/ChannelUpdateHandler.java @@ -79,32 +79,6 @@ protected Long handleInternally(DataObject content) switch (type) { - case STORE: - { - StoreChannelImpl storeChannel = (StoreChannelImpl) channel; - - final String oldName = storeChannel.getName(); - final int oldPosition = storeChannel.getPositionRaw(); - - if (!Objects.equals(oldName, name)) - { - storeChannel.setName(name); - getJDA().handleEvent( - new ChannelUpdateNameEvent( - getJDA(), responseNumber, - storeChannel, oldName, name - )); - } - if (!Objects.equals(oldPosition, position)) - { - storeChannel.setPosition(position); - getJDA().handleEvent( - new ChannelUpdatePositionEvent( - getJDA(), responseNumber, - storeChannel, oldPosition, position)); - } - break; - } case TEXT: { final String topic = content.getString("topic", null); diff --git a/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java index bd1f47a56e..574106d67d 100644 --- a/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java +++ b/src/main/java/net/dv8tion/jda/internal/handle/GuildDeleteHandler.java @@ -65,7 +65,6 @@ protected Long handleInternally(DataObject content) // this prevents some race-conditions for getting audio managers from guilds SnowflakeCacheViewImpl guildView = getJDA().getGuildsView(); SnowflakeCacheViewImpl stageView = getJDA().getStageChannelView(); - SnowflakeCacheViewImpl storeView = getJDA().getStoreChannelsView(); SnowflakeCacheViewImpl textView = getJDA().getTextChannelsView(); SnowflakeCacheViewImpl threadView = getJDA().getThreadChannelsView(); SnowflakeCacheViewImpl newsView = getJDA().getNewsChannelView(); @@ -73,16 +72,12 @@ protected Long handleInternally(DataObject content) SnowflakeCacheViewImpl categoryView = getJDA().getCategoriesView(); guildView.remove(id); + try (UnlockHook hook = stageView.writeLock()) { guild.getStageChannelCache() .forEachUnordered(chan -> stageView.getMap().remove(chan.getIdLong())); } - try (UnlockHook hook = storeView.writeLock()) - { - guild.getStoreChannelCache() - .forEachUnordered(chan -> storeView.getMap().remove(chan.getIdLong())); - } try (UnlockHook hook = textView.writeLock()) { guild.getTextChannelCache() diff --git a/src/main/java/net/dv8tion/jda/internal/managers/channel/concrete/StoreChannelManagerImpl.java b/src/main/java/net/dv8tion/jda/internal/managers/channel/concrete/StoreChannelManagerImpl.java deleted file mode 100644 index 89d9ff55c8..0000000000 --- a/src/main/java/net/dv8tion/jda/internal/managers/channel/concrete/StoreChannelManagerImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.dv8tion.jda.internal.managers.channel.concrete; - -import net.dv8tion.jda.api.entities.StoreChannel; -import net.dv8tion.jda.api.managers.channel.concrete.StoreChannelManager; -import net.dv8tion.jda.internal.managers.channel.ChannelManagerImpl; - -//TODO-v5: Remove with StoreChannel -public class StoreChannelManagerImpl extends ChannelManagerImpl implements StoreChannelManager -{ - public StoreChannelManagerImpl(StoreChannel channel) - { - super(channel); - } -} diff --git a/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java b/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java index 207db0e51b..00271a2278 100644 --- a/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java +++ b/src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java @@ -749,7 +749,6 @@ protected void invalidate() api.getTextChannelsView().clear(); api.getVoiceChannelsView().clear(); - api.getStoreChannelsView().clear(); api.getCategoriesView().clear(); api.getGuildsView().clear(); api.getUsersView().clear();