Example of how to add your own tags to WFT
- Create an EventListener
- Create an listen for the event TagReplaceEvent
- Get the text using the function
getText() - Replace the required string with
str_replace(), built into php - Set the text with the
setText($text)
// Import the event class
use WolfDen133\WFT\Event\TagReplaceEvent;
use pocketmine\event\Listener;
// Create the event listener class
class EventListener extends Listener {
// Listen for the TagReplaceEvent driven by the plugin
public function onTagReplaceEvent (TagReplaceEvent $event) : void
{
// Get the text from the event
$text = $event->getText();
// Replace the tags you need
$replace = str_replace(["{tag1}", "{tag2}"], ["Value 1", "Value 2"], $text);
// And replace the text
$event->setText($replace);
}
}Thats it, easy!