Skip to content

Commit 79c92e4

Browse files
committed
Add TebexEmbeddedCheckoutSupport#UNSUPPORTED
1 parent 835906f commit 79c92e4

File tree

4 files changed

+41
-23
lines changed

4 files changed

+41
-23
lines changed

api/src/main/java/com/lunarclient/apollo/module/tebex/TebexEmbeddedCheckoutSupport.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ public enum TebexEmbeddedCheckoutSupport {
4242
*
4343
* @since 1.1.6
4444
*/
45-
WINDOW
45+
WINDOW,
46+
47+
/**
48+
* The checkout is not supported.
49+
*
50+
* @since 1.1.6
51+
*/
52+
UNSUPPORTED
4653

4754
}

bukkit-example/src/main/java/com/lunarclient/apollo/example/api/examples/TebexApiExample.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,25 @@ public class TebexApiExample extends TebexExample {
3939
public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketIdent, String locale) {
4040
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
4141

42-
if (apolloPlayerOpt.isPresent()) {
43-
ApolloPlayer apolloPlayer = apolloPlayerOpt.get();
44-
TebexEmbeddedCheckoutSupport embeddedCheckoutSupport = apolloPlayer.getTebexEmbeddedCheckoutSupport();
42+
if (!apolloPlayerOpt.isPresent()) {
43+
viewer.sendMessage("Complete your purchase at https://pay.tebex.io/" + basketIdent);
44+
return;
45+
}
4546

46-
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayerOpt.get(), basketIdent, locale);
47+
ApolloPlayer apolloPlayer = apolloPlayerOpt.get();
48+
TebexEmbeddedCheckoutSupport embeddedCheckoutSupport = apolloPlayer.getTebexEmbeddedCheckoutSupport();
4749

48-
if (embeddedCheckoutSupport == TebexEmbeddedCheckoutSupport.OVERLAY) {
49-
viewer.sendMessage("Opening checkout as game overlay!");
50-
} else {
51-
viewer.sendMessage("Opening checkout in an external window!");
52-
}
53-
} else {
50+
if (embeddedCheckoutSupport == TebexEmbeddedCheckoutSupport.UNSUPPORTED) {
5451
viewer.sendMessage("Complete your purchase at https://pay.tebex.io/" + basketIdent);
52+
return;
53+
}
54+
55+
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayerOpt.get(), basketIdent, locale);
56+
57+
if (embeddedCheckoutSupport == TebexEmbeddedCheckoutSupport.OVERLAY) {
58+
viewer.sendMessage("Opening checkout as game overlay!");
59+
} else {
60+
viewer.sendMessage("Opening checkout in an external window!");
5561
}
5662
}
5763

common/src/main/java/com/lunarclient/apollo/player/ApolloPlayerManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void handlePlayerHandshake(@NotNull ApolloPlayer player, @NotNull PlayerH
141141
try {
142142
checkoutSupportType = TebexEmbeddedCheckoutSupport.values()[message.getEmbeddedCheckoutSupportValue() - 1];
143143
} catch (ArrayIndexOutOfBoundsException e) {
144-
checkoutSupportType = null;
144+
checkoutSupportType = TebexEmbeddedCheckoutSupport.UNSUPPORTED;
145145
}
146146

147147
EventBus.EventResult<ApolloPlayerHandshakeEvent> result = EventBus.getBus()

docs/developers/modules/tebex.mdx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,28 @@ Explore each integration by cycling through each tab to find the best fit for yo
8282
**Display Tebex Embedded Checkout**
8383

8484
```java
85-
@Override
8685
public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketIdent, String locale) {
8786
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
8887

89-
if (apolloPlayerOpt.isPresent()) {
90-
ApolloPlayer apolloPlayer = apolloPlayerOpt.get();
91-
TebexEmbeddedCheckoutSupport embeddedCheckoutSupport = apolloPlayer.getTebexEmbeddedCheckoutSupport();
88+
if (!apolloPlayerOpt.isPresent()) {
89+
viewer.sendMessage("Complete your purchase at https://pay.tebex.io/" + basketIdent);
90+
return;
91+
}
9292

93-
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayerOpt.get(), basketIdent, locale);
93+
ApolloPlayer apolloPlayer = apolloPlayerOpt.get();
94+
TebexEmbeddedCheckoutSupport embeddedCheckoutSupport = apolloPlayer.getTebexEmbeddedCheckoutSupport();
9495

95-
if (embeddedCheckoutSupport == TebexEmbeddedCheckoutSupport.OVERLAY) {
96-
viewer.sendMessage("Opening checkout as game overlay!");
97-
} else {
98-
viewer.sendMessage("Opening checkout in an external window!");
99-
}
100-
} else {
96+
if (embeddedCheckoutSupport == TebexEmbeddedCheckoutSupport.UNSUPPORTED) {
10197
viewer.sendMessage("Complete your purchase at https://pay.tebex.io/" + basketIdent);
98+
return;
99+
}
100+
101+
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayerOpt.get(), basketIdent, locale);
102+
103+
if (embeddedCheckoutSupport == TebexEmbeddedCheckoutSupport.OVERLAY) {
104+
viewer.sendMessage("Opening checkout as game overlay!");
105+
} else {
106+
viewer.sendMessage("Opening checkout in an external window!");
102107
}
103108
}
104109
```

0 commit comments

Comments
 (0)