getEntitlements()
{
diff --git a/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java b/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java
index cee4c41a7c..b81d5c5fb2 100644
--- a/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java
+++ b/src/main/java/net/dv8tion/jda/api/events/interaction/command/GenericCommandInteractionEvent.java
@@ -26,7 +26,6 @@
import net.dv8tion.jda.api.requests.restaction.interactions.ModalCallbackAction;
import net.dv8tion.jda.api.requests.restaction.interactions.PremiumRequiredCallbackAction;
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
-import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -121,7 +120,7 @@ public ModalCallbackAction replyModal(@Nonnull Modal modal)
return getInteraction().replyModal(modal);
}
- @NotNull
+ @Nonnull
@Override
public PremiumRequiredCallbackAction replyWithPremiumRequired()
{
diff --git a/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java b/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java
index f300d55cb9..2a04315b09 100644
--- a/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java
+++ b/src/main/java/net/dv8tion/jda/api/events/interaction/component/GenericComponentInteractionCreateEvent.java
@@ -29,7 +29,6 @@
import net.dv8tion.jda.api.requests.restaction.interactions.ModalCallbackAction;
import net.dv8tion.jda.api.requests.restaction.interactions.PremiumRequiredCallbackAction;
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
-import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
@@ -127,7 +126,7 @@ public ModalCallbackAction replyModal(@Nonnull Modal modal)
return interaction.replyModal(modal);
}
- @NotNull
+ @Nonnull
@Override
public PremiumRequiredCallbackAction replyWithPremiumRequired()
{
diff --git a/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java b/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java
index 6e65245289..7893fc0262 100644
--- a/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java
+++ b/src/main/java/net/dv8tion/jda/api/interactions/callbacks/IPremiumRequiredReplyCallback.java
@@ -16,7 +16,6 @@
package net.dv8tion.jda.api.interactions.callbacks;
-import net.dv8tion.jda.api.interactions.Interaction;
import net.dv8tion.jda.api.requests.restaction.interactions.PremiumRequiredCallbackAction;
import javax.annotation.CheckReturnValue;
@@ -27,7 +26,7 @@
*
* Replying with {@link #replyWithPremiumRequired()} will automatically acknowledge this interaction.
*/
-public interface IPremiumRequiredReplyCallback extends Interaction
+public interface IPremiumRequiredReplyCallback extends IDeferrableCallback
{
@Nonnull
@CheckReturnValue
diff --git a/src/main/java/net/dv8tion/jda/internal/entities/EntitlementImpl.java b/src/main/java/net/dv8tion/jda/internal/entities/EntitlementImpl.java
index f2aa417218..f4834f4d2c 100644
--- a/src/main/java/net/dv8tion/jda/internal/entities/EntitlementImpl.java
+++ b/src/main/java/net/dv8tion/jda/internal/entities/EntitlementImpl.java
@@ -17,28 +17,24 @@
package net.dv8tion.jda.internal.entities;
import net.dv8tion.jda.api.entities.Entitlement;
-import net.dv8tion.jda.api.utils.data.DataObject;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.OffsetDateTime;
public class EntitlementImpl implements Entitlement
{
- private String id;
- private String skuId;
- private String applicationId;
- @Nullable
- private String userId;
- @Nullable
- private String guildId;
- private Integer type;
- private Boolean deleted;
- @Nullable
+ private long id;
+ private long skuId;
+ private long applicationId;
+ private Long userId;
+ private Long guildId;
+ private int type;
+ private boolean deleted;
private OffsetDateTime startsAt;
- @Nullable
private OffsetDateTime endsAt;
- public EntitlementImpl(String id, String skuId, String applicationId, @Nullable String userId, @Nullable String guildId, Integer type, Boolean deleted, @Nullable OffsetDateTime startsAt, @Nullable OffsetDateTime endsAt)
+ public EntitlementImpl(long id, long skuId, long applicationId, Long userId, Long guildId, int type, boolean deleted, @Nullable OffsetDateTime startsAt, @Nullable OffsetDateTime endsAt)
{
this.id = id;
this.skuId = skuId;
@@ -51,71 +47,97 @@ public EntitlementImpl(String id, String skuId, String applicationId, @Nullable
this.endsAt = endsAt;
}
- public EntitlementImpl(DataObject data) {
- this.id = data.getString("id");
- this.skuId = data.getString("sku_id");
- this.applicationId = data.getString("application_id");
- this.userId = data.getString("user_id", null);
- this.guildId = data.getString("guild_id", null);
- this.type = data.getInt("type");
- this.deleted = data.getBoolean("deleted");
- this.startsAt = data.getOffsetDateTime("starts_at", null);
- this.endsAt = data.getOffsetDateTime("ends_at", null);
+ @Override
+ public long getIdLong()
+ {
+ return id;
}
@Override
- public String getId()
+ public long getSkuIdLong()
{
- return id;
+ return skuId;
}
+ @Nonnull
@Override
public String getSkuId()
{
- return skuId;
+ return Long.toUnsignedString(skuId);
}
@Override
- public String getApplicationId()
+ public long getApplicationIdLong()
{
return applicationId;
}
+ @Nonnull
@Override
+ public String getApplicationId()
+ {
+ return Long.toUnsignedString(applicationId);
+ }
+
@Nullable
- public String getUserId()
+ @Override
+ public Long getUserIdLong()
{
return userId;
}
+ @org.jetbrains.annotations.Nullable
@Override
+ public String getUserId()
+ {
+ if (userId == null)
+ {
+ return null;
+ }
+
+ return Long.toUnsignedString(userId);
+ }
+
@Nullable
- public String getGuildId()
+ @Override
+ public Long getGuildIdLong()
{
return guildId;
}
+ @Nullable
@Override
- public Integer getType()
+ public String getGuildId()
+ {
+ if (guildId == null)
+ {
+ return null;
+ }
+
+ return Long.toUnsignedString(guildId);
+ }
+
+ @Override
+ public int getType()
{
return type;
}
@Override
- public Boolean getDeleted()
+ public boolean getDeleted()
{
return deleted;
}
- @Override
@Nullable
+ @Override
public OffsetDateTime getStartsAt()
{
return startsAt;
}
- @Override
@Nullable
+ @Override
public OffsetDateTime getEndsAt()
{
return endsAt;
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 09b06f2ad8..742cc44d45 100644
--- a/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
+++ b/src/main/java/net/dv8tion/jda/internal/entities/EntityBuilder.java
@@ -2558,6 +2558,21 @@ public AuditLogChange createAuditLogChange(DataObject change)
return new AuditLogChange(oldValue, newValue, key);
}
+ public Entitlement createEntitlement(DataObject object)
+ {
+ return new EntitlementImpl(
+ object.getLong("id"),
+ object.getLong("sku_id"),
+ object.getLong("application_id"),
+ object.isNull("user_id") ? null : object.getLong("user_id"),
+ object.isNull("guild_id") ? null : object.getLong("guild_id"),
+ object.getInt("type"),
+ object.getBoolean("deleted"),
+ object.getOffsetDateTime("starts_at", null),
+ object.getOffsetDateTime("ends_at", null)
+ );
+ }
+
private Map changeToMap(Set changesList)
{
return changesList.stream().collect(Collectors.toMap(AuditLogChange::getKey, UnaryOperator.identity()));
diff --git a/src/main/java/net/dv8tion/jda/internal/handle/EntitlementCreateHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/EntitlementCreateHandler.java
index 60be97ac96..32367ecff4 100644
--- a/src/main/java/net/dv8tion/jda/internal/handle/EntitlementCreateHandler.java
+++ b/src/main/java/net/dv8tion/jda/internal/handle/EntitlementCreateHandler.java
@@ -19,7 +19,6 @@
import net.dv8tion.jda.api.events.entitlement.EntitlementCreateEvent;
import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.JDAImpl;
-import net.dv8tion.jda.internal.entities.EntitlementImpl;
public class EntitlementCreateHandler extends SocketHandler
{
@@ -31,7 +30,7 @@ public EntitlementCreateHandler(JDAImpl api)
@Override
protected Long handleInternally(DataObject content)
{
- getJDA().handleEvent(new EntitlementCreateEvent(getJDA(), responseNumber, new EntitlementImpl(content)));
+ getJDA().handleEvent(new EntitlementCreateEvent(getJDA(), responseNumber, getJDA().getEntityBuilder().createEntitlement(content)));
return null;
}
}
diff --git a/src/main/java/net/dv8tion/jda/internal/handle/EntitlementDeleteHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/EntitlementDeleteHandler.java
index a6ea0f1fee..22a54e3bbd 100644
--- a/src/main/java/net/dv8tion/jda/internal/handle/EntitlementDeleteHandler.java
+++ b/src/main/java/net/dv8tion/jda/internal/handle/EntitlementDeleteHandler.java
@@ -19,7 +19,6 @@
import net.dv8tion.jda.api.events.entitlement.EntitlementDeleteEvent;
import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.JDAImpl;
-import net.dv8tion.jda.internal.entities.EntitlementImpl;
public class EntitlementDeleteHandler extends SocketHandler
{
@@ -31,7 +30,7 @@ public EntitlementDeleteHandler(JDAImpl api)
@Override
protected Long handleInternally(DataObject content)
{
- getJDA().handleEvent(new EntitlementDeleteEvent(getJDA(), responseNumber, new EntitlementImpl(content)));
+ getJDA().handleEvent(new EntitlementDeleteEvent(getJDA(), responseNumber, getJDA().getEntityBuilder().createEntitlement(content)));
return null;
}
}
diff --git a/src/main/java/net/dv8tion/jda/internal/handle/EntitlementUpdateHandler.java b/src/main/java/net/dv8tion/jda/internal/handle/EntitlementUpdateHandler.java
index a622ff84b5..11d0cd3515 100644
--- a/src/main/java/net/dv8tion/jda/internal/handle/EntitlementUpdateHandler.java
+++ b/src/main/java/net/dv8tion/jda/internal/handle/EntitlementUpdateHandler.java
@@ -20,7 +20,6 @@
import net.dv8tion.jda.api.events.entitlement.EntitlementUpdateEvent;
import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.JDAImpl;
-import net.dv8tion.jda.internal.entities.EntitlementImpl;
public class EntitlementUpdateHandler extends SocketHandler
{
@@ -32,7 +31,7 @@ public EntitlementUpdateHandler(JDAImpl api)
@Override
protected Long handleInternally(DataObject content)
{
- getJDA().handleEvent(new EntitlementUpdateEvent(getJDA(), responseNumber, new EntitlementImpl(content)));
+ getJDA().handleEvent(new EntitlementUpdateEvent(getJDA(), responseNumber, getJDA().getEntityBuilder().createEntitlement(content)));
return null;
}
}
diff --git a/src/main/java/net/dv8tion/jda/internal/interactions/InteractionImpl.java b/src/main/java/net/dv8tion/jda/internal/interactions/InteractionImpl.java
index d579a4832f..c21b742451 100644
--- a/src/main/java/net/dv8tion/jda/internal/interactions/InteractionImpl.java
+++ b/src/main/java/net/dv8tion/jda/internal/interactions/InteractionImpl.java
@@ -30,17 +30,14 @@
import net.dv8tion.jda.api.utils.data.DataArray;
import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.JDAImpl;
-import net.dv8tion.jda.internal.entities.EntitlementImpl;
-import net.dv8tion.jda.internal.entities.GuildImpl;
-import net.dv8tion.jda.internal.entities.MemberImpl;
-import net.dv8tion.jda.internal.entities.UserImpl;
+import net.dv8tion.jda.internal.entities.*;
import net.dv8tion.jda.internal.entities.channel.concrete.PrivateChannelImpl;
-import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
public class InteractionImpl implements Interaction
{
@@ -112,13 +109,10 @@ public InteractionImpl(JDAImpl jda, DataObject data)
this.user = user;
}
- DataArray entitlementsArray = data.getArray("entitlements");
- entitlements = new ArrayList<>();
-
- for (int i=0; i getEntitlements()
{
diff --git a/src/main/java/net/dv8tion/jda/internal/interactions/command/CommandInteractionImpl.java b/src/main/java/net/dv8tion/jda/internal/interactions/command/CommandInteractionImpl.java
index ceec669453..03ddaca2ed 100644
--- a/src/main/java/net/dv8tion/jda/internal/interactions/command/CommandInteractionImpl.java
+++ b/src/main/java/net/dv8tion/jda/internal/interactions/command/CommandInteractionImpl.java
@@ -29,7 +29,6 @@
import net.dv8tion.jda.internal.requests.restaction.interactions.PremiumRequiredCallbackActionImpl;
import net.dv8tion.jda.internal.requests.restaction.interactions.ReplyCallbackActionImpl;
import net.dv8tion.jda.internal.utils.Checks;
-import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
@@ -65,7 +64,7 @@ public ModalCallbackAction replyModal(@Nonnull Modal modal)
}
- @NotNull
+ @Nonnull
@Override
public PremiumRequiredCallbackAction replyWithPremiumRequired()
{