diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/Gift.java b/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/Gift.java
index 238b766..7cfd999 100644
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/Gift.java
+++ b/API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/Gift.java
@@ -48,7 +48,6 @@ public class Gift {
this.properties = properties;
}
-
public Gift(int id, String name, int diamondCost, String pictureLink) {
this(id, name, diamondCost, new Picture(pictureLink), new JsonObject());
}
diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveOfflineHostException.java b/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveOfflineHostException.java
index b6bebab..4085170 100644
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveOfflineHostException.java
+++ b/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveOfflineHostException.java
@@ -22,9 +22,18 @@
*/
package io.github.jwdeveloper.tiktok.exceptions;
+import io.github.jwdeveloper.tiktok.data.requests.*;
+import lombok.Getter;
+
+@Getter
public class TikTokLiveOfflineHostException extends TikTokLiveException
{
- public TikTokLiveOfflineHostException(String message) {
+ private final LiveUserData.Response userData;
+ private final LiveData.Response liveData;
+
+ public TikTokLiveOfflineHostException(String message, LiveUserData.Response userData, LiveData.Response liveData) {
super(message);
+ this.userData = userData;
+ this.liveData = liveData;
}
-}
+}
\ No newline at end of file
diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveUnknownHostException.java b/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveUnknownHostException.java
index 4cbc179..9ad30b5 100644
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveUnknownHostException.java
+++ b/API/src/main/java/io/github/jwdeveloper/tiktok/exceptions/TikTokLiveUnknownHostException.java
@@ -22,9 +22,18 @@
*/
package io.github.jwdeveloper.tiktok.exceptions;
+import io.github.jwdeveloper.tiktok.data.requests.*;
+import lombok.Getter;
+
+@Getter
public class TikTokLiveUnknownHostException extends TikTokLiveException
{
- public TikTokLiveUnknownHostException(String message) {
+ private final LiveUserData.Response userData;
+ private final LiveData.Response liveData;
+
+ public TikTokLiveUnknownHostException(String message, LiveUserData.Response userData, LiveData.Response liveData) {
super(message);
+ this.userData = userData;
+ this.liveData = liveData;
}
}
\ No newline at end of file
diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/http/LiveHttpClient.java b/API/src/main/java/io/github/jwdeveloper/tiktok/http/LiveHttpClient.java
index 72d218e..218bcbd 100644
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/http/LiveHttpClient.java
+++ b/API/src/main/java/io/github/jwdeveloper/tiktok/http/LiveHttpClient.java
@@ -29,11 +29,6 @@ import io.github.jwdeveloper.tiktok.data.requests.LiveUserData;
public interface LiveHttpClient
{
- /**
- * @return {@link GiftsData.Response} list of gifts that are compiled and available on github
- */
- GiftsData.Response fetchGiftsData();
-
/**
* @return {@link GiftsData.Response} list of gifts that are available in your region / livestream
*/
diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/listener/TikTokEventListener.java b/API/src/main/java/io/github/jwdeveloper/tiktok/listener/TikTokEventListener.java
deleted file mode 100644
index f88335c..0000000
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/listener/TikTokEventListener.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2023-2024 jwdeveloper jacekwoln@gmail.com
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-package io.github.jwdeveloper.tiktok.listener;
-
-import io.github.jwdeveloper.tiktok.live.LiveClient;
-
-/**
- * ListenersManager
- *
- * TikTokEventListener is an alternative way of handing TikTok events.
- *
- * {@code TikTokLive.newClient("someuser").addListener(listener);}
- *
- * After registertion, all listeners are kept in Listener manager - {@link LiveClient#getListenersManager()}
- *
- * Method in TikTokEventListener should meet requirements below to be detected
- *
- @TikTokEventObserver annotation
- *
- 2 parameters of (LiveClient, Class extending TikTokEvent)
- *
- * {@code
- * public static class CustomListener
- * {
- * @TikTokEventObserver
- * public void onError(LiveClient liveClient, TikTokErrorEvent event)
- * {
- * System.out.println(event.getException().getMessage());
- * }
- *
- * @TikTokEventObserver
- * public void onCommentMessage(LiveClient liveClient, TikTokCommentEvent event)
- * {
- * System.out.println(event.getText());
- * }
- *
- * @TikTokEventObserver
- * public void onGiftMessage(LiveClient liveClient, TikTokGiftMessageEvent event)
- * {
- * System.out.println(event.getGift().getDescription());
- * }
- *
- * @TikTokEventObserver
- * public void onAnyEvent(LiveClient liveClient, TikTokEvent event)
- * {
- * System.out.println(event.getClass().getSimpleName());
- * }
- * }
- * }
- *
- */
-@Deprecated(forRemoval = true, since = "1.8.1 (This interface is not longer needed, please remove it from your class) | Removing in 1.9.0")
-public interface TikTokEventListener {
-
-}
\ No newline at end of file
diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/live/GiftsManager.java b/API/src/main/java/io/github/jwdeveloper/tiktok/live/GiftsManager.java
index 9ee4be8..166d69a 100644
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/live/GiftsManager.java
+++ b/API/src/main/java/io/github/jwdeveloper/tiktok/live/GiftsManager.java
@@ -22,12 +22,8 @@
*/
package io.github.jwdeveloper.tiktok.live;
-import com.google.gson.JsonObject;
-import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.data.models.gifts.*;
-import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
diff --git a/API/src/main/java/io/github/jwdeveloper/tiktok/live/builder/LiveClientBuilder.java b/API/src/main/java/io/github/jwdeveloper/tiktok/live/builder/LiveClientBuilder.java
index 972132f..9692330 100644
--- a/API/src/main/java/io/github/jwdeveloper/tiktok/live/builder/LiveClientBuilder.java
+++ b/API/src/main/java/io/github/jwdeveloper/tiktok/live/builder/LiveClientBuilder.java
@@ -30,9 +30,8 @@ import io.github.jwdeveloper.tiktok.mappers.LiveMapper;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
-public interface LiveClientBuilder extends EventsBuilder {
-
-
+public interface LiveClientBuilder extends EventsBuilder
+{
/**
* This method is triggered after default mappings are registered
* It could be used to OVERRIDE behaviour of mappings and implement custom behaviour
@@ -40,18 +39,15 @@ public interface LiveClientBuilder extends EventsBuilder {
* Be aware if for example you override WebcastGiftEvent, onGiftEvent() will not be working
*
* @param onCustomMappings lambda method
- * @return
+ * @return {@link LiveClientBuilder}
*/
LiveClientBuilder mappings(Consumer onCustomMappings);
- @Deprecated(forRemoval = true, since = "1.8.2 use `mappings` method instead")
- LiveClientBuilder onMappings(Consumer onCustomMappings);
-
/**
* Configuration of client settings
*
- * @param onConfigure
- * @return
+ * @param onConfigure Consumer for {@link LiveClientSettings}
+ * @return {@link LiveClientBuilder}
* @see LiveClientSettings
*/
LiveClientBuilder configure(Consumer onConfigure);
@@ -59,7 +55,7 @@ public interface LiveClientBuilder extends EventsBuilder {
/**
* Adds events listener class, its fancy way to register events without using lamda method
*
- * @return
+ * @return {@link LiveClientBuilder}
*/
LiveClientBuilder addListener(Object listener);
@@ -69,7 +65,7 @@ public interface LiveClientBuilder extends EventsBuilder {
* when the default implementation does not meet your needs
*
* @param onCustomizeDependencies access to dependency container
- * @return
+ * @return {@link LiveClientBuilder}
*/
LiveClientBuilder customize(Consumer onCustomizeDependencies);
diff --git a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLive.java b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLive.java
index f01bc4c..e8490f6 100644
--- a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLive.java
+++ b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLive.java
@@ -22,20 +22,18 @@
*/
package io.github.jwdeveloper.tiktok;
-
import io.github.jwdeveloper.tiktok.data.settings.LiveClientSettings;
-import io.github.jwdeveloper.tiktok.gifts.TikTokGiftsManager;
import io.github.jwdeveloper.tiktok.http.LiveHttpClient;
-import io.github.jwdeveloper.tiktok.live.GiftsManager;
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
-public class TikTokLive {
+public class TikTokLive
+{
/**
- * Example: https://www.tiktok.com/@dostawcavideo - hostName would be 'dostawcavideo'
+ * Example: {@code https://www.tiktok.com/@dostawcavideo} - hostName would be 'dostawcavideo'
*
* @param hostName profile name of TikTok user could be found in profile link
* @return LiveClientBuilder
@@ -45,7 +43,7 @@ public class TikTokLive {
}
/**
- * Example: https://www.tiktok.com/@dostawcavideo - hostName would be 'dostawcavideo'
+ * Example: {@code https://www.tiktok.com/@dostawcavideo} - hostName would be 'dostawcavideo'
*
* @param hostName profile name of TikTok user could be found in profile link
* @return true if live is Online, false if is offline
@@ -55,17 +53,17 @@ public class TikTokLive {
}
/**
- * Example: https://www.tiktok.com/@dostawcavideo - hostName would be 'dostawcavideo'
+ * Example: {@code https://www.tiktok.com/@dostawcavideo} - hostName would be 'dostawcavideo'
*
* @param hostName profile name of TikTok user could be found in profile link
- * @return true if live is Online, false if is offline
+ * @return {@link CompletableFuture} of true if live is Online, false if is offline
*/
public static CompletableFuture isLiveOnlineAsync(String hostName) {
return CompletableFuture.supplyAsync(() -> isLiveOnline(hostName));
}
/**
- * Example: https://www.tiktok.com/@dostawcavideo - hostName would be 'dostawcavideo'
+ * Example: {@code https://www.tiktok.com/@dostawcavideo} - hostName would be 'dostawcavideo'
*
* @param hostName profile name of TikTok user could be found in profile link
* @return true is hostName name is valid and exists, false if not
@@ -75,7 +73,7 @@ public class TikTokLive {
}
/**
- * Example: https://www.tiktok.com/@dostawcavideo - hostName would be 'dostawcavideo'
+ * Example: {@code https://www.tiktok.com/@dostawcavideo} - hostName would be 'dostawcavideo'
*
* @param hostName profile name of TikTok user could be found in profile link
* @return true is hostName name is valid and exists, false if not
@@ -101,20 +99,4 @@ public class TikTokLive {
public static LiveHttpClient requests() {
return requests(liveClientSettings -> {});
}
-
- private static GiftsManager giftsManager;
-
- /**
- * Fetch gifts from endpoint and returns GiftManager
- *
- * @return GiftsManager
- */
- public static GiftsManager gifts() {
- if (giftsManager == null) {
- synchronized (GiftsManager.class) {
- giftsManager = new TikTokGiftsManager(requests().fetchGiftsData().getGifts());
- }
- }
- return giftsManager;
- }
}
\ No newline at end of file
diff --git a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClient.java b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClient.java
index 1e3a109..cd50f33 100644
--- a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClient.java
+++ b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClient.java
@@ -114,10 +114,10 @@ public class TikTokLiveClient implements LiveClient
roomInfo.setRoomId(userData.getRoomId());
if (userData.getUserStatus() == LiveUserData.UserStatus.Offline)
- throw new TikTokLiveOfflineHostException("User is offline: " + roomInfo.getHostName());
+ throw new TikTokLiveOfflineHostException("User is offline: " + roomInfo.getHostName(), userData, null);
if (userData.getUserStatus() == LiveUserData.UserStatus.NotFound)
- throw new TikTokLiveUnknownHostException("User not found: " + roomInfo.getHostName());
+ throw new TikTokLiveUnknownHostException("User not found: " + roomInfo.getHostName(), userData, null);
var liveDataRequest = new LiveData.Request(userData.getRoomId());
var liveData = httpClient.fetchLiveData(liveDataRequest);
@@ -126,10 +126,10 @@ public class TikTokLiveClient implements LiveClient
throw new TikTokLiveException("Livestream for " + roomInfo.getHostName() + " is 18+ or age restricted!");
if (liveData.getLiveStatus() == LiveData.LiveStatus.HostNotFound)
- throw new TikTokLiveUnknownHostException("LiveStream for " + roomInfo.getHostName() + " could not be found.");
+ throw new TikTokLiveUnknownHostException("LiveStream for " + roomInfo.getHostName() + " could not be found.", userData, liveData);
if (liveData.getLiveStatus() == LiveData.LiveStatus.HostOffline)
- throw new TikTokLiveOfflineHostException("LiveStream for " + roomInfo.getHostName() + " not found, is the Host offline?");
+ throw new TikTokLiveOfflineHostException("LiveStream for " + roomInfo.getHostName() + " not found, is the Host offline?", userData, liveData);
roomInfo.setTitle(liveData.getTitle());
roomInfo.setViewersCount(liveData.getViewers());
diff --git a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClientBuilder.java b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClientBuilder.java
index 3d471f7..9e9a0b7 100644
--- a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClientBuilder.java
+++ b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveClientBuilder.java
@@ -70,12 +70,6 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
return this;
}
- @Override
- public LiveClientBuilder onMappings(Consumer onCustomMappings) {
- mappings(onCustomMappings);
- return this;
- }
-
public TikTokLiveClientBuilder configure(Consumer onConfigure) {
onConfigure.accept(clientSettings);
return this;
@@ -155,11 +149,7 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
*/
//gifts
- if (clientSettings.isFetchGifts()) {
- dependance.registerSingleton(GiftsManager.class, TikTokLive.gifts());
- } else {
- dependance.registerSingleton(GiftsManager.class, new TikTokGiftsManager(List.of()));
- }
+ dependance.registerSingleton(GiftsManager.class, new TikTokGiftsManager(List.of()));
//mapper
dependance.registerSingleton(TikTokGenericEventMapper.class);
diff --git a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpClient.java b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpClient.java
index d5259a1..16933f8 100644
--- a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpClient.java
+++ b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpClient.java
@@ -44,7 +44,6 @@ public class TikTokLiveHttpClient implements LiveHttpClient
private static final String TIKTOK_SIGN_API = "https://tiktok.eulerstream.com/webcast/fetch";
private static final String TIKTOK_URL_WEB = "https://www.tiktok.com/";
private static final String TIKTOK_URL_WEBCAST = "https://webcast.tiktok.com/webcast/";
- public static final String TIKTOK_GIFTS_URL = "https://raw.githubusercontent.com/TikTok-LIVE-Private/GiftsGenerator/master/page/public/gifts.json";
public static final String TIKTOK_ROOM_GIFTS_URL = TIKTOK_URL_WEBCAST+"gift/list/";
public static final int TIKTOK_AGE_RESTRICTED_CODE = 4003110;
@@ -95,31 +94,6 @@ public class TikTokLiveHttpClient implements LiveHttpClient
return giftsDataMapper.mapRoom(json);
}
- public GiftsData.Response fetchGiftsData() {
- var proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
- if (proxyClientSettings.isEnabled()) {
- while (proxyClientSettings.hasNext()) {
- try {
- return getGiftsData();
- } catch (TikTokProxyRequestException ignored) {}
- }
- }
- return getGiftsData();
- }
-
- @Deprecated(since = "1.8.6", forRemoval = true)
- public GiftsData.Response getGiftsData() {
- var result = httpFactory.client(TIKTOK_GIFTS_URL)
- .build()
- .toJsonResponse();
-
- if (result.isFailure())
- throw new TikTokLiveRequestException("Unable to fetch gifts information's - "+result);
-
- var json = result.getContent();
- return giftsDataMapper.map(json);
- }
-
@Override
public LiveUserData.Response fetchLiveUserData(LiveUserData.Request request) {
var proxyClientSettings = clientSettings.getHttpSettings().getProxyClientSettings();
diff --git a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpOfflineClient.java b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpOfflineClient.java
index bd2cb92..5067567 100644
--- a/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpOfflineClient.java
+++ b/Client/src/main/java/io/github/jwdeveloper/tiktok/TikTokLiveHttpOfflineClient.java
@@ -35,11 +35,6 @@ import java.net.URI;
import java.util.List;
public class TikTokLiveHttpOfflineClient implements LiveHttpClient {
- @Override
- public GiftsData.Response fetchGiftsData() {
- return new GiftsData.Response("", List.of());
- }
-
@Override
public GiftsData.Response fetchRoomGiftsData(String room_id) {
return new GiftsData.Response("", List.of());