Skip to content
Merged
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 @@ -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.paynow.PayNowEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.player.ApolloPlayer;
import java.util.List;
Expand Down Expand Up @@ -80,4 +81,12 @@ public class ApolloPlayerHandshakeEvent implements Event {
*/
TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport;

/**
* The {@link PayNowEmbeddedCheckoutSupport} type.
*
* @return the Pay Now checkout support type
* @since 1.2.1
*/
PayNowEmbeddedCheckoutSupport payNowEmbeddedCheckoutSupport;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 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.paynow;

/**
* Represents the paynow embedded checkout support type.
*
* @since 1.2.1
*/
public enum PayNowEmbeddedCheckoutSupport {

/**
* External checkout is supported as a game overlay.
*
* @since 1.2.1
*/
OVERLAY,

/**
* Embedded checkout is supported in an external window.
*
* @since 1.2.1
*/
WINDOW,

/**
* The checkout is not supported.
*
* @since 1.2.1
*/
UNSUPPORTED

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 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.paynow;

import com.lunarclient.apollo.module.ApolloModule;
import com.lunarclient.apollo.module.ModuleDefinition;
import com.lunarclient.apollo.recipients.Recipients;
import org.jetbrains.annotations.ApiStatus;

/**
* Represents the pay now module.
*
* @since 1.2.1
*/
@ApiStatus.NonExtendable
@ModuleDefinition(id = "pay_now", name = "PayNow")
public abstract class PayNowModule extends ApolloModule {

/**
* Displays the checkout with the provided {@link String} checkout token to the {@link Recipients}.
*
* @param recipients the recipients that are receiving the packet
* @param checkoutToken the paynow checkout token
* @since 1.2.1
*/
public abstract void displayPayNowEmbeddedCheckout(Recipients recipients, String checkoutToken);

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

/**
* Represents an embedded checkout support type.
* Represents the tebex embedded checkout support type.
*
* @since 1.1.6
*/
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.common.location.ApolloLocation;
import com.lunarclient.apollo.module.paynow.PayNowEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.option.Option;
import com.lunarclient.apollo.option.Options;
Expand Down Expand Up @@ -144,4 +145,12 @@ default boolean hasPermission(Options options, Option<String, ?, ?> option) {
*/
@Nullable TebexEmbeddedCheckoutSupport getTebexEmbeddedCheckoutSupport();

/**
* Returns the {@link PayNowEmbeddedCheckoutSupport} type.
*
* @return the Pay Now checkout support type
* @since 1.2.1
*/
@Nullable PayNowEmbeddedCheckoutSupport getPayNowEmbeddedCheckoutSupport();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* This file is part of Apollo, licensed under the MIT License.
*
* Copyright (c) 2023 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.paynow;

import com.lunarclient.apollo.paynow.v1.OpenPayNowEmbeddedCheckoutMessage;
import com.lunarclient.apollo.player.AbstractApolloPlayer;
import com.lunarclient.apollo.recipients.Recipients;
import lombok.NonNull;

/**
* Provides the paynow module.
*
* @since 1.2.1
*/
public final class PayNowModuleImpl extends PayNowModule {

@Override
public void displayPayNowEmbeddedCheckout(@NonNull Recipients recipients, @NonNull String checkoutToken) {
OpenPayNowEmbeddedCheckoutMessage message = OpenPayNowEmbeddedCheckoutMessage.newBuilder()
.setCheckoutToken(checkoutToken)
.build();

recipients.forEach(player -> ((AbstractApolloPlayer) player).sendPacket(message));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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.paynow.PayNowEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.roundtrip.ApolloRequest;
import com.lunarclient.apollo.roundtrip.ApolloResponse;
Expand All @@ -53,6 +54,7 @@ public abstract class AbstractApolloPlayer implements ApolloPlayer {
private LunarClientVersion lunarClientVersion;
private List<LunarClientMod> installedMods;
private TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport;
private PayNowEmbeddedCheckoutSupport payNowEmbeddedCheckoutSupport;

@Override
public Optional<ApolloWorld> getWorld() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.lunarclient.apollo.event.player.ApolloUnregisterPlayerEvent;
import com.lunarclient.apollo.module.modsetting.ModSettingModule;
import com.lunarclient.apollo.module.modsettings.ModSettingModuleImpl;
import com.lunarclient.apollo.module.paynow.PayNowEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.network.NetworkOptions;
import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage;
Expand Down Expand Up @@ -140,18 +141,27 @@ public void handlePlayerHandshake(@NotNull ApolloPlayer player, @NotNull PlayerH
.build()
).collect(Collectors.toList());

TebexEmbeddedCheckoutSupport checkoutSupportType;
int embeddedCheckoutSupport = message.getEmbeddedCheckoutSupportValue();
TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport;
try {
checkoutSupportType = TebexEmbeddedCheckoutSupport.values()[message.getEmbeddedCheckoutSupportValue() - 1];
tebexEmbeddedCheckoutSupport = TebexEmbeddedCheckoutSupport.values()[embeddedCheckoutSupport - 1];
} catch (ArrayIndexOutOfBoundsException e) {
checkoutSupportType = TebexEmbeddedCheckoutSupport.UNSUPPORTED;
tebexEmbeddedCheckoutSupport = TebexEmbeddedCheckoutSupport.UNSUPPORTED;
}

PayNowEmbeddedCheckoutSupport payNowEmbeddedCheckoutSupport;
try {
payNowEmbeddedCheckoutSupport = PayNowEmbeddedCheckoutSupport.values()[embeddedCheckoutSupport - 1];
} catch (ArrayIndexOutOfBoundsException e) {
payNowEmbeddedCheckoutSupport = PayNowEmbeddedCheckoutSupport.UNSUPPORTED;
}

AbstractApolloPlayer apolloPlayer = ((AbstractApolloPlayer) player);
apolloPlayer.setMinecraftVersion(minecraftVersion);
apolloPlayer.setLunarClientVersion(lunarClientVersion);
apolloPlayer.setInstalledMods(mods);
apolloPlayer.setTebexEmbeddedCheckoutSupport(checkoutSupportType);
apolloPlayer.setTebexEmbeddedCheckoutSupport(tebexEmbeddedCheckoutSupport);
apolloPlayer.setPayNowEmbeddedCheckoutSupport(payNowEmbeddedCheckoutSupport);

Map<String, Value> modStatus = message.getModStatusMap();
if (!modStatus.isEmpty()) {
Expand All @@ -162,8 +172,12 @@ public void handlePlayerHandshake(@NotNull ApolloPlayer player, @NotNull PlayerH
}
}

EventBus.EventResult<ApolloPlayerHandshakeEvent> result = EventBus.getBus()
.post(new ApolloPlayerHandshakeEvent(player, minecraftVersion, lunarClientVersion, mods, checkoutSupportType));
ApolloPlayerHandshakeEvent event = new ApolloPlayerHandshakeEvent(
player, minecraftVersion, lunarClientVersion, mods,
tebexEmbeddedCheckoutSupport, payNowEmbeddedCheckoutSupport
);

EventBus.EventResult<ApolloPlayerHandshakeEvent> result = EventBus.getBus().post(event);

for (Throwable throwable : result.getThrowing()) {
throwable.printStackTrace();
Expand Down
6 changes: 3 additions & 3 deletions docs/developers/lightweight/protobuf/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Available fields for each message, including their types, are available on the B
<dependency>
<groupId>com.lunarclient</groupId>
<artifactId>apollo-protos</artifactId>
<version>0.0.4</version>
<version>0.0.5</version>
</dependency>
</dependencies>
```
Expand All @@ -41,7 +41,7 @@ Available fields for each message, including their types, are available on the B
}

dependencies {
api 'com.lunarclient:apollo-protos:0.0.4'
api 'com.lunarclient:apollo-protos:0.0.5'
}
```
</Tab>
Expand All @@ -55,7 +55,7 @@ Available fields for each message, including their types, are available on the B
}

dependencies {
api("com.lunarclient:apollo-protos:0.0.4")
api("com.lunarclient:apollo-protos:0.0.5")
}
```
</Tab>
Expand Down
1 change: 1 addition & 0 deletions docs/developers/modules/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"nametag": "Nametag",
"nickhider": "Nick Hider",
"notification": "Notification",
"paynow": "Pay Now",
"packetenrichment": "Packet Enrichment",
"richpresence": "Rich Presence",
"saturation": "Saturation",
Expand Down
Loading