From 9cba1bfb3132a969d35884963f9f4bf84deaf19f Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 25 Nov 2025 13:48:12 +0100 Subject: [PATCH] docs: Update event and punishment service references; add Placeholders API documentation --- docs/src/fancycore/api/events.md | 3 +- docs/src/fancycore/api/placeholders.md | 48 ++++++++++++++++++++++++++ docs/src/fancycore/api/punishments.md | 2 +- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 docs/src/fancycore/api/placeholders.md diff --git a/docs/src/fancycore/api/events.md b/docs/src/fancycore/api/events.md index 8f2dbb65..35e1154b 100644 --- a/docs/src/fancycore/api/events.md +++ b/docs/src/fancycore/api/events.md @@ -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()); }); diff --git a/docs/src/fancycore/api/placeholders.md b/docs/src/fancycore/api/placeholders.md new file mode 100644 index 00000000..48b18e1d --- /dev/null +++ b/docs/src/fancycore/api/placeholders.md @@ -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()); +``` \ No newline at end of file diff --git a/docs/src/fancycore/api/punishments.md b/docs/src/fancycore/api/punishments.md index 6cbf0ae3..0ed2f104 100644 --- a/docs/src/fancycore/api/punishments.md +++ b/docs/src/fancycore/api/punishments.md @@ -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);