mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Began rework to dynamic gifts. Did not fetch from url yet.
This commit is contained in:
@@ -22,10 +22,8 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok.data.events.gift;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftOld;
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
|
||||
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
|
||||
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||
import lombok.Getter;
|
||||
@@ -49,8 +47,8 @@ import lombok.Getter;
|
||||
public class TikTokGiftComboEvent extends TikTokGiftEvent {
|
||||
private final GiftSendType comboState;
|
||||
|
||||
public TikTokGiftComboEvent(GiftOld gift, User host, WebcastGiftMessage msg, GiftSendType comboState) {
|
||||
public TikTokGiftComboEvent(Gift gift, User host, WebcastGiftMessage msg, GiftSendType comboState) {
|
||||
super(gift, host, msg);
|
||||
this.comboState = comboState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,9 @@
|
||||
package io.github.jwdeveloper.tiktok.data.events.gift;
|
||||
|
||||
|
||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftOld;
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
|
||||
import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||
import lombok.Getter;
|
||||
@@ -40,12 +39,12 @@ import lombok.Getter;
|
||||
@EventMeta(eventType = EventType.Message)
|
||||
@Getter
|
||||
public class TikTokGiftEvent extends TikTokHeaderEvent {
|
||||
private final GiftOld gift;
|
||||
private final Gift gift;
|
||||
private final User user;
|
||||
private final User toUser;
|
||||
private final int combo;
|
||||
|
||||
public TikTokGiftEvent(GiftOld gift, User liveHost, WebcastGiftMessage msg) {
|
||||
public TikTokGiftEvent(Gift gift, User liveHost, WebcastGiftMessage msg) {
|
||||
super(msg.getCommon());
|
||||
this.gift = gift;
|
||||
user = User.map(msg.getUser(), msg.getUserIdentity());
|
||||
|
||||
@@ -2,12 +2,17 @@ package io.github.jwdeveloper.tiktok.data.models.gifts;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import io.github.jwdeveloper.tiktok.data.models.Picture;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Gift {
|
||||
public class Gift
|
||||
{
|
||||
@Getter private static final Set<Gift> gifts = new HashSet<>();
|
||||
public static final Gift UNDEFINED = new Gift(-1, "undefined", -1, "", null);
|
||||
|
||||
private final int id;
|
||||
|
||||
private final String name;
|
||||
@@ -17,4 +22,20 @@ public class Gift {
|
||||
private final Picture picture;
|
||||
|
||||
private final JsonObject properties;
|
||||
}
|
||||
|
||||
public Gift(int id, String name, int diamondCost, String pictureLink, JsonObject properties) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.diamondCost = diamondCost;
|
||||
this.picture = new Picture(pictureLink);
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public boolean hasDiamondCostRange(int minimalCost, int maximalCost) {
|
||||
return diamondCost >= minimalCost && diamondCost <= maximalCost;
|
||||
}
|
||||
|
||||
public boolean hasDiamondCost(int cost) {
|
||||
return diamondCost == cost;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,13 +28,11 @@ public enum GiftSendType
|
||||
Begin,
|
||||
Active;
|
||||
|
||||
|
||||
public static GiftSendType fromNumber(long number)
|
||||
{
|
||||
return switch ((int) number) {
|
||||
case 0 -> GiftSendType.Finished;
|
||||
case 1, 2, 4 -> GiftSendType.Active;
|
||||
default -> GiftSendType.Finished;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,9 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok.live;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftOld;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.github.jwdeveloper.tiktok.data.models.Picture;
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,26 +39,29 @@ public interface GiftManager {
|
||||
* @param diamondCost diamond cost
|
||||
* @return
|
||||
*/
|
||||
GiftOld registerGift(int id, String name, int diamondCost, Picture picture);
|
||||
default Gift registerGift(int id, String name, int diamondCost, Picture picture) {
|
||||
return registerGift(id, name, diamondCost, picture, null);
|
||||
}
|
||||
|
||||
Gift registerGift(int id, String name, int diamondCost, Picture picture, JsonObject properties);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param giftId
|
||||
* @return
|
||||
*/
|
||||
GiftOld findById(int giftId);
|
||||
Gift findById(int giftId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param giftName
|
||||
* @return
|
||||
*/
|
||||
GiftOld findByName(String giftName);
|
||||
Gift findByName(String giftName);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return all gifts
|
||||
*/
|
||||
List<GiftOld> getGifts();
|
||||
}
|
||||
List<Gift> getGifts();
|
||||
}
|
||||
Reference in New Issue
Block a user