mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -05:00
Added javadocs for clarity
Optimized methods in TikTokGiftEventHandler and TikTokGenericEventMapper
This commit is contained in:
@@ -29,8 +29,6 @@ import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
|
||||
@EventMeta(eventType = EventType.Message)
|
||||
@Getter
|
||||
public class TikTokGiftComboEvent extends TikTokGiftEvent {
|
||||
@@ -43,12 +41,9 @@ public class TikTokGiftComboEvent extends TikTokGiftEvent {
|
||||
|
||||
public static TikTokGiftComboEvent of(Gift gift, int combo, GiftComboStateType comboState) {
|
||||
return new TikTokGiftComboEvent(
|
||||
gift,
|
||||
new User(0L, "Test", new Picture("")),
|
||||
WebcastGiftMessage
|
||||
.newBuilder()
|
||||
.setComboCount(combo)
|
||||
.build(),
|
||||
comboState);
|
||||
gift,
|
||||
new User(0L, "Test", new Picture("")),
|
||||
WebcastGiftMessage.newBuilder().setComboCount(combo).build(),
|
||||
comboState);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok.data.events.gift;
|
||||
|
||||
|
||||
import io.github.jwdeveloper.tiktok.annotations.*;
|
||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.models.Picture;
|
||||
@@ -31,8 +30,6 @@ import io.github.jwdeveloper.tiktok.data.models.users.User;
|
||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
|
||||
@EventMeta(eventType = EventType.Message)
|
||||
@Getter
|
||||
public class TikTokGiftEvent extends TikTokHeaderEvent {
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
package io.github.jwdeveloper.tiktok.data.models.gifts;
|
||||
|
||||
public enum GiftComboStateType {
|
||||
Finished,
|
||||
Begin,
|
||||
Active;
|
||||
Active,
|
||||
Finished;
|
||||
|
||||
public static GiftComboStateType fromNumber(long number) {
|
||||
return switch ((int) number) {
|
||||
|
||||
@@ -123,8 +123,11 @@ public interface EventsBuilder<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked for gifts that has no combo, or when combo finishes
|
||||
*
|
||||
* Triggers for these different reasons:
|
||||
* <ol>
|
||||
* <li>User sends gifts that have no combo (most of expensive gifts)</li>
|
||||
* <li>{@link TikTokGiftComboEvent} has combaState = {@link GiftComboStateType#Finished}</li>
|
||||
* </ol>
|
||||
* @param action consumable action
|
||||
* @return self instance
|
||||
*/
|
||||
@@ -133,19 +136,19 @@ public interface EventsBuilder<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered every time gift is sent
|
||||
* Triggered every time a gift is sent
|
||||
* <p>Example when user sends gift with combo</p>
|
||||
* <ul>
|
||||
* <li>Combo: 1 -> comboState = {@link GiftComboStateType#Begin}</li>
|
||||
* <li>Combo: 4 -> comboState = {@link GiftComboStateType#Active}</li>
|
||||
* <li>Combo: 8 -> comboState = {@link GiftComboStateType#Active}</li>
|
||||
* <li>Combo: 12 -> comboState = {@link GiftComboStateType#Finished}</li>
|
||||
* </ul>
|
||||
* Both {@link TikTokGiftComboEvent} and {@link TikTokGiftEvent} events are triggered when comboState is Finished
|
||||
*
|
||||
* @apiNote {@link GiftComboStateType} has 3 states: {@link GiftComboStateType#Begin Begin}, {@link GiftComboStateType#Active Active}, & {@link GiftComboStateType#Finished Finished}
|
||||
* @param action consumable action
|
||||
* @return self instance
|
||||
* @see GiftComboStateType it has 3 states
|
||||
*
|
||||
* <p>Example when user sends gift with combo</p>
|
||||
* <p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
|
||||
* <p>Combo: 4 -> comboState = GiftSendType.Active</p>
|
||||
* <p>Combo: 8 -> comboState = GiftSendType.Active</p>
|
||||
* <p>Combo: 12 -> comboState = GiftSendType.Finished</p>
|
||||
* <p>
|
||||
* Remember if comboState is Finished both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
||||
*/
|
||||
default T onGiftCombo(EventConsumer<TikTokGiftComboEvent> action) {
|
||||
return onEvent(TikTokGiftComboEvent.class, action);
|
||||
|
||||
Reference in New Issue
Block a user