Skip to content

Commit 407f51f

Browse files
authored
Merge pull request #59 from jwdeveloper/develop-1.4.0
MINOR update
2 parents 965816e + 3387986 commit 407f51f

File tree

107 files changed

+2096
-191133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2096
-191133
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
backend-infrastructure/.aws-sam
22

3+
4+
.db
35
# Created by https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode
46
*.db
57
### Linux ###
68
*~
7-
.db
89
# temporary files which can be created if a process still has a handle open of a deleted file
910
.fuse_hidden*
1011

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
*/
2323
package io.github.jwdeveloper.tiktok.data.events.gift;
2424

25-
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
26-
import io.github.jwdeveloper.tiktok.annotations.EventType;
27-
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
28-
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
25+
import io.github.jwdeveloper.tiktok.annotations.*;
26+
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
2927
import io.github.jwdeveloper.tiktok.data.models.users.User;
3028
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
3129
import lombok.Getter;
@@ -53,4 +51,4 @@ public TikTokGiftComboEvent(Gift gift, User host, WebcastGiftMessage msg, GiftSe
5351
super(gift, host, msg);
5452
this.comboState = comboState;
5553
}
56-
}
54+
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@
2323
package io.github.jwdeveloper.tiktok.data.events.gift;
2424

2525

26-
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
27-
import io.github.jwdeveloper.tiktok.annotations.EventType;
26+
import io.github.jwdeveloper.tiktok.annotations.*;
2827
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
29-
import io.github.jwdeveloper.tiktok.data.models.Picture;
30-
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
31-
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
28+
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
3229
import io.github.jwdeveloper.tiktok.data.models.users.User;
3330
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
3431
import lombok.Getter;
3532

36-
import java.util.ArrayList;
37-
3833

3934
/**
4035
* Triggered when user sends gifts that has

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/Gift.java

Lines changed: 31 additions & 1402 deletions
Large diffs are not rendered by default.

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/GiftOld.java

Lines changed: 1417 additions & 0 deletions
Large diffs are not rendered by default.

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/GiftSendType.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@ public enum GiftSendType
2828
Begin,
2929
Active;
3030

31-
3231
public static GiftSendType fromNumber(long number)
3332
{
3433
return switch ((int) number) {
35-
case 0 -> GiftSendType.Finished;
3634
case 1, 2, 4 -> GiftSendType.Active;
3735
default -> GiftSendType.Finished;
3836
};
3937
}
40-
}
38+
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/requests/GiftsData.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,7 @@ public final class Request
4242
public static final class Response
4343
{
4444
private String json;
45-
private List<GiftModel> gifts;
46-
}
47-
48-
@Data
49-
public static class GiftModel
50-
{
51-
private int id;
52-
private String name;
53-
private int diamondCost;
54-
private String image;
45+
private List<Gift> gifts;
5546
}
5647

5748
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/settings/LiveClientSettings.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
@Data
3434
public class LiveClientSettings {
3535

36+
37+
/**
38+
* Determines if gifts data is downloaded before TikTokLive starts,
39+
* when `false` then client.giftManager() does not contain initial gifts
40+
*/
41+
private boolean fetchGifts;
42+
3643
/**
3744
* ISO-Language for Client
3845
*/

API/src/main/java/io/github/jwdeveloper/tiktok/http/LiveHttpClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface LiveHttpClient
3434
*/
3535
GiftsData.Response fetchGiftsData();
3636

37+
3738
/**
3839
* Returns information about user that is having a livestream
3940
* @param userName name of user

API/src/main/java/io/github/jwdeveloper/tiktok/live/GiftManager.java renamed to API/src/main/java/io/github/jwdeveloper/tiktok/live/GiftsManager.java

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,65 @@
2222
*/
2323
package io.github.jwdeveloper.tiktok.live;
2424

25-
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
25+
import com.google.gson.JsonObject;
2626
import io.github.jwdeveloper.tiktok.data.models.Picture;
27+
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
28+
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
2729

30+
import java.util.Collections;
2831
import java.util.List;
32+
import java.util.Map;
33+
import java.util.function.Predicate;
2934

30-
public interface GiftManager {
35+
public interface GiftsManager {
3136

3237
/**
33-
* In case you can't find your gift in Gift enum. You can register gift
34-
* manually here to make it detected while TikTokGiftEvent
38+
* You can create and attach your own custom gift to manager
3539
*
36-
* @param id gift's id
37-
* @param name gift's name
38-
* @param diamondCost diamond cost
39-
* @return
40+
* @param gift
4041
*/
41-
Gift registerGift(int id, String name, int diamondCost, Picture picture);
42-
42+
void attachGift(Gift gift);
4343

4444
/**
45+
* You can create and attach your own custom gift to manager
4546
*
46-
* @param giftId
47-
* @return
47+
* @param gifts
4848
*/
49-
Gift findById(int giftId);
49+
void attachGiftsList(List<Gift> gifts);
5050

5151
/**
52+
* finds gift by name
53+
* When gift not found return Gift.UNDEFINED;
5254
*
53-
* @param giftName
54-
* @return
55+
* @param name gift name
5556
*/
56-
Gift findByName(String giftName);
57+
Gift getByName(String name);
5758

5859
/**
60+
* finds gift by id
61+
* When gift not found return Gift.UNDEFINED;
5962
*
60-
* @return all gifts
63+
* @param giftId giftId
64+
*/
65+
Gift getById(int giftId);
66+
67+
68+
/**
69+
* finds gift by filter
70+
* When gift not found return Gift.UNDEFINED;
71+
*/
72+
Gift getByFilter(Predicate<Gift> filter);
73+
74+
List<Gift> getManyByFilter(Predicate<Gift> filter);
75+
76+
/**
77+
* @return list of all gifts
78+
*/
79+
List<Gift> toList();
80+
81+
82+
/**
83+
* @return list of all map of all gifts where Integer is gift Id
6184
*/
62-
List<Gift> getGifts();
63-
}
85+
Map<Integer, Gift> toMap();
86+
}

0 commit comments

Comments
 (0)