docs: Update event and punishment service references; add Placeholders API documentation

This commit is contained in:
Oliver
2025-11-25 13:48:12 +01:00
parent 0336844633
commit 9cba1bfb31
3 changed files with 51 additions and 2 deletions

View File

@@ -12,7 +12,8 @@ FancyCore has its own event system that allows you to listen to various events t
Example for registering a listener for the `PlayerReportedEvent`:
```java
EventService eventService = FancyCore.get().getEventService();
EventService eventService = EventService.get();
eventService.registerListener(PlayerReportedEvent.class, (event) -> {
System.out.println("PlayerReportedEvent fired with report id: " + event.getReport().id());
});

View File

@@ -0,0 +1,48 @@
---
icon: dot
order: 7
---
# Placeholders API
FancyCore includes a Placeholders API that allows you to create and manage custom placeholders for use in various plugins.
## Parse placeholders
To parse placeholders in a string, use the `PlaceholderService`'s `parse` method. Here's an example:
```java
PlaceholderService placeholderService = PlaceholderService.get();
String parsedString = placeholderService.parse(player, "Hello, {player_name}! Your rank is {player_rank}.");
```
## Creating a custom placeholder
To create a custom placeholder, implement the `PlaceholderProvider` interface and register it with the `PlaceholderService`. Here's an example of creating a simple placeholder that returns a player's rank:
```java
public class PlayerRankPlaceholder implements PlaceholderProvider {
@Override
public String getName() {
return "Player Rank Placeholder";
}
@Override
public String getIdentifier() {
return "player_rank";
}
@Override
public String parse(FancyPlayer player, String input) {
return player.getRank().getName();
}
}
```
You can then register your placeholder provider with the `PlaceholderService`:
```java
PlaceholderService placeholderService = PlaceholderService.get();
placeholderService.registerPlaceholderProvider(new PlayerRankPlaceholder());
```

View File

@@ -12,7 +12,7 @@ FancyCore provides a comprehensive Punishment API that allows you to manage play
With the Punishment Service, you can easily issue various types of punishments to players. Below are examples of how to use the Punishment Service:
```java
PunishmentService punishmentService = FancyCore.get().getPunishmentService();
PunishmentService punishmentService = PunishmentService.get();
punishmentService.warnPlayer(player, staff, "reason", duration);