mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
docs: Update event and punishment service references; add Placeholders API documentation
This commit is contained in:
@@ -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`:
|
Example for registering a listener for the `PlayerReportedEvent`:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
EventService eventService = FancyCore.get().getEventService();
|
EventService eventService = EventService.get();
|
||||||
|
|
||||||
eventService.registerListener(PlayerReportedEvent.class, (event) -> {
|
eventService.registerListener(PlayerReportedEvent.class, (event) -> {
|
||||||
System.out.println("PlayerReportedEvent fired with report id: " + event.getReport().id());
|
System.out.println("PlayerReportedEvent fired with report id: " + event.getReport().id());
|
||||||
});
|
});
|
||||||
|
|||||||
48
docs/src/fancycore/api/placeholders.md
Normal file
48
docs/src/fancycore/api/placeholders.md
Normal 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());
|
||||||
|
```
|
||||||
@@ -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:
|
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
|
```java
|
||||||
PunishmentService punishmentService = FancyCore.get().getPunishmentService();
|
PunishmentService punishmentService = PunishmentService.get();
|
||||||
|
|
||||||
punishmentService.warnPlayer(player, staff, "reason", duration);
|
punishmentService.warnPlayer(player, staff, "reason", duration);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user