Skip to content

Commit

Permalink
Rename TebexCheckoutSupportType to TebexEmbeddedCheckoutSupport & add…
Browse files Browse the repository at this point in the history
… basket id parameter to the tebex command
  • Loading branch information
ItsNature committed Aug 26, 2024
1 parent 2bd4bdb commit 762fc22
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +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.tebex.TebexCheckoutSupportType;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.player.ApolloPlayer;
import java.util.List;
import lombok.Value;
Expand Down Expand Up @@ -73,11 +73,11 @@ public class ApolloPlayerHandshakeEvent implements Event {
List<LunarClientMod> installedMods;

/**
* The {@link TebexCheckoutSupportType} type.
* The {@link TebexEmbeddedCheckoutSupport} type.
*
* @return the Tebex checkout support type
* @since 1.1.5
*/
TebexCheckoutSupportType tebexCheckoutSupportType;
TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport;

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @since 1.1.5
*/
public enum TebexCheckoutSupportType {
public enum TebexEmbeddedCheckoutSupport {

/**
* External checkout is supported as a game overlay.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +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.tebex.TebexCheckoutSupportType;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.option.Option;
import com.lunarclient.apollo.option.Options;
import com.lunarclient.apollo.recipients.Recipients;
Expand Down Expand Up @@ -136,11 +136,11 @@ default boolean hasPermission(Options options, Option<String, ?, ?> option) {
List<LunarClientMod> getInstalledMods();

/**
* Returns the {@link TebexCheckoutSupportType} type.
* Returns the {@link TebexEmbeddedCheckoutSupport} type.
*
* @return the Tebex checkout support type
* @since 1.1.5
*/
TebexCheckoutSupportType getTebexCheckoutSupportType();
TebexEmbeddedCheckoutSupport getTebexEmbeddedCheckoutSupport();

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command

Player player = (Player) sender;

if (args.length != 1) {
player.sendMessage("Usage: /tebex <display>");
if (args.length != 2) {
player.sendMessage("Usage: /tebex <display> <basketId>");
return true;
}

switch (args[0].toLowerCase()) {
case "display": {
this.tebexExample.displayTebexEmbeddedCheckoutExample(player);
this.tebexExample.displayTebexEmbeddedCheckoutExample(player, args[1]);
player.sendMessage("Displaying checkout....");
break;
}

default: {
player.sendMessage("Usage: /tebex <display>");
player.sendMessage("Usage: /tebex <display> <basketId>");
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package com.lunarclient.apollo.example.modules;

import com.lunarclient.apollo.Apollo;
import com.lunarclient.apollo.module.tebex.TebexCheckoutSupportType;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.module.tebex.TebexModule;
import com.lunarclient.apollo.player.ApolloPlayer;
import java.util.Optional;
Expand All @@ -34,15 +34,14 @@ public class TebexExample {

private final TebexModule tebexModule = Apollo.getModuleManager().getModule(TebexModule.class);

public void displayTebexEmbeddedCheckoutExample(Player viewer) {
public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketId) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> {
if (apolloPlayer.getTebexCheckoutSupportType() == TebexCheckoutSupportType.UNSUPPORTED) {
if (apolloPlayer.getTebexEmbeddedCheckoutSupport() == TebexEmbeddedCheckoutSupport.UNSUPPORTED) {
return;
}

// The basket ids expire, so this example may not work
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayer, "c4rodk-b8d3439942d859decf45f6ed8b4dad2455f06738");
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayer, basketId);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +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.tebex.TebexCheckoutSupportType;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.roundtrip.ApolloRequest;
import com.lunarclient.apollo.roundtrip.ApolloResponse;
import com.lunarclient.apollo.world.ApolloWorld;
Expand All @@ -52,7 +52,7 @@ public abstract class AbstractApolloPlayer implements ApolloPlayer {
private MinecraftVersion minecraftVersion;
private LunarClientVersion lunarClientVersion;
private List<LunarClientMod> installedMods;
private TebexCheckoutSupportType tebexCheckoutSupportType;
private TebexEmbeddedCheckoutSupport tebexEmbeddedCheckoutSupport;

@Override
public Optional<ApolloWorld> getWorld() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.lunarclient.apollo.event.player.ApolloPlayerHandshakeEvent;
import com.lunarclient.apollo.event.player.ApolloRegisterPlayerEvent;
import com.lunarclient.apollo.event.player.ApolloUnregisterPlayerEvent;
import com.lunarclient.apollo.module.tebex.TebexCheckoutSupportType;
import com.lunarclient.apollo.module.tebex.TebexEmbeddedCheckoutSupport;
import com.lunarclient.apollo.network.NetworkOptions;
import com.lunarclient.apollo.player.v1.PlayerHandshakeMessage;
import java.util.Collection;
Expand Down Expand Up @@ -137,11 +137,11 @@ public void handlePlayerHandshake(@NotNull ApolloPlayer player, @NotNull PlayerH
.build()
).collect(Collectors.toList());

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

EventBus.EventResult<ApolloPlayerHandshakeEvent> result = EventBus.getBus()
Expand All @@ -155,7 +155,7 @@ public void handlePlayerHandshake(@NotNull ApolloPlayer player, @NotNull PlayerH
apolloPlayer.setMinecraftVersion(minecraftVersion);
apolloPlayer.setLunarClientVersion(lunarClientVersion);
apolloPlayer.setInstalledMods(mods);
apolloPlayer.setTebexCheckoutSupportType(checkoutSupportType);
apolloPlayer.setTebexEmbeddedCheckoutSupport(checkoutSupportType);
}

}
7 changes: 3 additions & 4 deletions docs/developers/modules/tebex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ TODO
### Sample Code

```java
public void displayTebexEmbeddedCheckoutExample(Player viewer) {
public void displayTebexEmbeddedCheckoutExample(Player viewer, String basketId) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> {
if (apolloPlayer.getTebexCheckoutSupportType() == TebexCheckoutSupportType.UNSUPPORTED) {
if (apolloPlayer.getTebexEmbeddedCheckoutSupport() == TebexEmbeddedCheckoutSupport.UNSUPPORTED) {
return;
}

// The basket ids expire, so this example may not work
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayer, "c4rodk-b8d3439942d859decf45f6ed8b4dad2455f06738");
this.tebexModule.displayTebexEmbeddedCheckout(apolloPlayer, basketId);
});
}
```

1 comment on commit 762fc22

@LunarClientBot
Copy link
Collaborator

@LunarClientBot LunarClientBot commented on 762fc22 Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📄 Documentation Deployment

Status:✅ Completed
Environment:preview
URL:https://7ecfbd82.lunarclient-dev.pages.dev

Please sign in to comment.