Skip to content

Commit

Permalink
More markdown work
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsNature committed Sep 12, 2024
1 parent 30daf89 commit c4a8928
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@
import com.lunarclient.apollo.Apollo;
import com.lunarclient.apollo.module.chat.ChatModule;
import com.lunarclient.apollo.recipients.Recipients;
import java.util.concurrent.ThreadLocalRandom;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

public class ChatExample {

private final ChatModule chatModule = Apollo.getModuleManager().getModule(ChatModule.class);

private final int messageId = ThreadLocalRandom.current().nextInt(100);
private int countdown = 5;

public void displayLiveChatMessageExample() {
this.chatModule.displayLiveChatMessage(Recipients.ofEveryone(),
Component.text("Game starting in ", NamedTextColor.GREEN)
.append(Component.text(this.countdown, NamedTextColor.BLUE)),
this.messageId
13
);

if (--this.countdown == 0) {
Expand All @@ -50,7 +48,7 @@ public void displayLiveChatMessageExample() {
}

public void removeLiveChatMessageExample() {
this.chatModule.removeLiveChatMessage(Recipients.ofEveryone(), this.messageId);
this.chatModule.removeLiveChatMessage(Recipients.ofEveryone(), 13);
}

}
113 changes: 56 additions & 57 deletions docs/developers/modules/beam.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,62 @@ public void resetBeamsExample(Player viewer) {
}
```

### `Beam` Options

`.id(String)` should include a unique identifier for the beam.

```java
.id("spawn-beacon")
```

`.color(java.awt.Color)` is how you dictate the color of the beam. See the [colors page](/apollo/developers/utilities/colors) for more.

**Color Types**

<Tabs items={['Java Presets', 'Minecraft Presets', 'Hex & RGB']}>
<Tab>

The `java.awt.Color` class statically exposes some colors, although they do not correspond to any existing colors used in Minecraft.

```java
.color(Color.CYAN)
```

</Tab>

<Tab>

The `ApolloColors` class statically exposes colors that correspond to Bukkit/Spigot's `ChatColor` enum.

```java
.color(ApolloColors.LIGHT_PURPLE)
```

</Tab>

<Tab>

Custom colors can be created from any RGB values using `new Color(int red, int green, int blue)`, or from any hex color using `Color.decode(String hex)`.

```java
.color(Color.decode("#FF00FF"))
```

</Tab>
</Tabs>

`.location(ApolloBlockLocation)` used to determine the exact block you want the beam to be displayed on. See the [locations utilities page](/apollo/developers/utilities/locations) for more.

```java
.location(ApolloBlockLocation.builder()
.world("world")
.x(0)
.y(60)
.z(0)
.build()
)
```

</Tab>

<Tab>
Expand Down Expand Up @@ -153,60 +209,3 @@ public void resetBeamsExample(Player viewer) {
</Tab>

</Tabs>


### `Beam` Options

`.id(String)` should include a unique identifier for the beam.

```java
.id("spawn-beacon")
```

`.color(java.awt.Color)` is how you dictate the color of the beam. See the [colors page](/apollo/developers/utilities/colors) for more.

**Color Types**

<Tabs items={['Java Presets', 'Minecraft Presets', 'Hex & RGB']}>
<Tab>

The `java.awt.Color` class statically exposes some colors, although they do not correspond to any existing colors used in Minecraft.

```java
.color(Color.CYAN)
```

</Tab>

<Tab>

The `ApolloColors` class statically exposes colors that correspond to Bukkit/Spigot's `ChatColor` enum.

```java
.color(ApolloColors.LIGHT_PURPLE)
```

</Tab>

<Tab>

Custom colors can be created from any RGB values using `new Color(int red, int green, int blue)`, or from any hex color using `Color.decode(String hex)`.

```java
.color(Color.decode("#FF00FF"))
```

</Tab>
</Tabs>

`.location(ApolloBlockLocation)` used to determine the exact block you want the beam to be displayed on. See the [locations utilities page](/apollo/developers/utilities/locations) for more.

```java
.location(ApolloBlockLocation.builder()
.world("world")
.x(0)
.y(60)
.z(0)
.build()
)
```
120 changes: 114 additions & 6 deletions docs/developers/modules/border.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ The border module not only enhances Minecraft's current world border system, but
## Integration

### Sample Code
Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.

<Tabs items={['Apollo API', 'apollo-protos library', 'Manual JSON Object Construction']}>

<Tab>

### Displaying a Border

```java
public void displayBorderExample(Player viewer) {
Expand Down Expand Up @@ -42,6 +49,24 @@ public void displayBorderExample(Player viewer) {
}
```

### Removing a Border

```java
public void removeBorderExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.borderModule.removeBorder(apolloPlayer, "pvp-tagged-spawn"));
}
```

### Resetting all Borders

```java
public void resetBordersExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(this.borderModule::resetBorders);
}
```

### `Border` Options

`.id(String)` should include a unique identifier for the border. It's important when you have multiple borders in a single world.
Expand Down Expand Up @@ -128,20 +153,103 @@ Custom colors can be created from any RGB values using `new Color(int red, int g
.durationTicks(0)
```

### Removing a specific border for a player
</Tab>

<Tab>

### Displaying a Border

```java
public void displayBorderExample(Player viewer) {
DisplayBorderMessage message = DisplayBorderMessage.newBuilder()
.setId("pvp-tagged-spawn")
.setWorld("world")
.setCancelEntry(true)
.setCancelExit(true)
.setCanShrinkOrExpand(false)
.setColor(ProtobufUtil.createColorProto(Color.RED))
.setBounds(ProtobufUtil.createCuboid2DProto(Cuboid2D.builder()
.minX(-50)
.minZ(-50)
.maxX(50)
.maxZ(50)
.build()))
.setDurationTicks(1000)
.build();

ProtobufPacketUtil.sendPacket(viewer, message);
}
```

### Removing a Border

```java
public void removeBorderExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.borderModule.removeBorder(apolloPlayer, "pvp-tagged-spawn"));
RemoveBorderMessage message = RemoveBorderMessage.newBuilder()
.setId("pvp-tagged-spawn")
.build();

ProtobufPacketUtil.sendPacket(viewer, message);
}
```

### Resetting all borders for a player
### Resetting all Borders

```java
public void resetBordersExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(this.borderModule::resetBorders);
ResetBordersMessage message = ResetBordersMessage.getDefaultInstance();
ProtobufPacketUtil.sendPacket(viewer, message);
}
```

</Tab>

<Tab>

### Displaying a Border

```java
public void displayBorderExample(Player viewer) {
JsonObject message = new JsonObject();
message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.DisplayBorderMessage");
message.addProperty("id", "pvp-tagged-spawn");
message.addProperty("world", "world");
message.addProperty("cancel_entry", true);
message.addProperty("cancel_exit", true);
message.addProperty("can_shrink_or_expand", false);
message.add("color", JsonUtil.createColorObject(Color.RED));
message.add("bounds", JsonUtil.createCuboid2DObject(
Cuboid2D.builder().minX(-50).minZ(-50).maxX(50).maxZ(50).build()
));
message.addProperty("duration_ticks", 1000);

JsonPacketUtil.sendPacket(viewer, message);
}
```

### Removing a Border

```java
public void removeBorderExample(Player viewer) {
JsonObject message = new JsonObject();
message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.RemoveBorderMessage");
message.addProperty("id", "pvp-tagged-spawn");

JsonPacketUtil.sendPacket(viewer, message);
}
```

### Resetting all Borders

```java
public void resetBordersExample(Player viewer) {
JsonObject message = new JsonObject();
message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.border.v1.ResetBordersMessage");

JsonPacketUtil.sendPacket(viewer, message);
}
```

</Tab>

</Tabs>
Loading

1 comment on commit c4a8928

@LunarClientBot
Copy link
Collaborator

@LunarClientBot LunarClientBot commented on c4a8928 Sep 12, 2024

Choose a reason for hiding this comment

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

📄 Documentation Deployment

Status:❌ Failed
Environment:preview
URL:Pending...

Please sign in to comment.