Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public final class LunarClientMod {
* @return the mod display name
* @since 1.0.6
*/
String displayName;
@Nullable String displayName;

/**
* Returns the mod {@link String} version (e.g. '1.2.21').
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.lunarclient.apollo.client.version.LunarClientVersion;
import com.lunarclient.apollo.client.version.MinecraftVersion;
import com.lunarclient.apollo.event.Event;
import com.lunarclient.apollo.module.modsetting.ModSettingModule;
import com.lunarclient.apollo.module.paynow.PayNowEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.player.ApolloPlayer;
Expand Down Expand Up @@ -69,9 +70,10 @@ public class ApolloPlayerHandshakeEvent implements Event {
* A {@link List} of {@link LunarClientMod} the player has installed.
*
* @return the installed mods
* @deprecated for removal since 1.2.5, use {@link ModSettingModule#requestInstalledMods(ApolloPlayer)} instead.
* @since 1.0.6
*/
List<LunarClientMod> installedMods;
@Deprecated List<LunarClientMod> installedMods;

/**
* The {@link TebexEmbeddedCheckoutSupport} type.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2026 Moonsworth
*
* 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 com.lunarclient.apollo.module.modsetting;

import com.lunarclient.apollo.roundtrip.ApolloRequest;
import lombok.Builder;

/**
* Represents the installed mods request.
*
* @since 1.2.5
*/
@Builder
public final class InstalledModsRequest extends ApolloRequest<InstalledModsResponse> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2026 Moonsworth
*
* 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 com.lunarclient.apollo.module.modsetting;

import com.lunarclient.apollo.client.mod.LunarClientMod;
import com.lunarclient.apollo.roundtrip.pagination.ApolloPaginatedResponse;
import java.util.List;
import java.util.UUID;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

/**
* Represents the installed mods response.
*
* @since 1.2.5
*/
@Getter
@SuperBuilder
public final class InstalledModsResponse extends ApolloPaginatedResponse<LunarClientMod> {

@Override
public ApolloPaginatedResponse<LunarClientMod> combine(UUID packetId, List<LunarClientMod> elements) {
return InstalledModsResponse.builder()
.packetId(packetId)
.elements(elements)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.lunarclient.apollo.module.modsetting;

import com.lunarclient.apollo.ApolloPlatform;
import com.lunarclient.apollo.async.Future;
import com.lunarclient.apollo.module.ApolloModule;
import com.lunarclient.apollo.module.ModuleDefinition;
import com.lunarclient.apollo.option.Option;
Expand Down Expand Up @@ -66,4 +67,13 @@ public boolean isClientNotify() {
*/
public abstract <T, C extends Option<T, ?, ?>> T getStatus(@NotNull ApolloPlayer player, @NonNull C option);

/**
* Sends the {@link InstalledModsRequest} to the {@link ApolloPlayer}.
*
* @param player the player
* @return future to be listened to for errors/success
* @since 1.2.5
*/
public abstract Future<InstalledModsResponse> requestInstalledMods(ApolloPlayer player);

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.lunarclient.apollo.client.version.LunarClientVersion;
import com.lunarclient.apollo.client.version.MinecraftVersion;
import com.lunarclient.apollo.common.location.ApolloLocation;
import com.lunarclient.apollo.module.modsetting.ModSettingModule;
import com.lunarclient.apollo.module.paynow.PayNowEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.option.Option;
Expand Down Expand Up @@ -133,9 +134,10 @@ default boolean hasPermission(Options options, Option<String, ?, ?> option) {
* Returns a {@link List} of {@link LunarClientMod} the player has installed.
*
* @return the installed mods
* @deprecated for removal since 1.2.5, use {@link ModSettingModule#requestInstalledMods(ApolloPlayer)} instead.
* @since 1.1.6
*/
@Nullable List<LunarClientMod> getInstalledMods();
@Deprecated @Nullable List<LunarClientMod> getInstalledMods();

/**
* Returns the {@link TebexEmbeddedCheckoutSupport} type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package com.lunarclient.apollo.roundtrip;

import com.lunarclient.apollo.async.future.UncertainFuture;
import com.lunarclient.apollo.roundtrip.pagination.ApolloPaginatedResponse;
import com.lunarclient.apollo.roundtrip.pagination.ApolloPaginationManager;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -52,6 +54,13 @@ public final class ApolloRoundtripManager {
*/
private final ScheduledThreadPoolExecutor timeoutExecutor;

/**
* The manager for paginated responses.
*
* @since 1.2.5
*/
private final ApolloPaginationManager paginationManager;

/**
* Constructs the {@link ApolloRoundtripManager}.
*
Expand All @@ -60,15 +69,31 @@ public final class ApolloRoundtripManager {
public ApolloRoundtripManager() {
this.listeners = new ConcurrentHashMap<>();
this.timeoutExecutor = new ScheduledThreadPoolExecutor(1);
this.paginationManager = new ApolloPaginationManager(this);
}

/**
* Handles the given {@link ApolloResponse}.
*
* @param response the response
* @since 1.0.0
* @since 1.2.5
*/
public void handleResponse(ApolloResponse response) {
if (response instanceof ApolloPaginatedResponse<?>) {
this.paginationManager.handlePage((ApolloPaginatedResponse<?>) response);
return;
}

this.completeFuture(response);
}

/**
* Completes the {@link UncertainFuture} for a given {@link ApolloResponse}.
*
* @param response the response
* @since 1.2.5
*/
public void completeFuture(ApolloResponse response) {
UncertainFuture<ApolloResponse> future = this.listeners.remove(response.getPacketId());

if (future != null) {
Expand All @@ -91,6 +116,7 @@ public <T extends ApolloResponse> void registerListener(ApolloRequest<T> request
this.timeoutExecutor.schedule(() -> {
try {
UncertainFuture<ApolloResponse> listener = this.listeners.remove(packetId);
this.paginationManager.handleTimeout(packetId);

if (listener != null) {
Throwable error = new Throwable("Timeout exceeded!");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2026 Moonsworth
*
* 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 com.lunarclient.apollo.roundtrip.pagination;

import com.lunarclient.apollo.roundtrip.ApolloResponse;
import java.util.List;
import java.util.UUID;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

/**
* Represents a Paginated Apollo Response.
*
* @param <T> the type of the elements in the paginated payload
* @since 1.2.5
*/
@Getter
@SuperBuilder
public abstract class ApolloPaginatedResponse<T> extends ApolloResponse {

/**
* The current page number.
*
* @since 1.2.5
*/
@Getter(AccessLevel.PROTECTED)
int page;

/**
* The total number of pages expected.
*
* @since 1.2.5
*/
@Getter(AccessLevel.PROTECTED)
int totalPages;

/**
* The elements contained in this specific page.
*
* @since 1.2.5
*/
List<T> elements;

/**
* Checks if this is the final page in the sequence.
*
* @return true if it is the last page
* @since 1.2.5
*/
public boolean isLastPage() {
return this.page == this.totalPages - 1;
}

/**
* Creates a finalized response containing all paginated elements.
*
* @param packetId the response packet id
* @param elements the complete list of elements across all pages
* @return a new combined response
* @since 1.2.5
*/
public abstract ApolloPaginatedResponse<T> combine(UUID packetId, List<T> elements);

}
Loading
Loading