Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement events #2

Open
Muqsit opened this issue Sep 21, 2020 · 0 comments
Open

Implement events #2

Muqsit opened this issue Sep 21, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@Muqsit
Copy link
Owner

Muqsit commented Sep 21, 2020

Plugin developers may want to cancel processing packages until players have logged in (HereAuth), until custom player data is fetched asynchronously...

public function onTebexOnlinePlayerPurchase(TebexOnlinePlayerPurchaseEvent $event) : void{
	if($this->manager->isLocked($event->getPlayer())){
		// Will keep trying to process this package
		// everytime plugin checks for pending packages
		// until the event isn't cancelled.
		$event->setCancelled();
	}
}

to implement a custom rewarding system that does not rely on tebex's enforced command execution...

public const PACKAGE_RANDOM_LOOT = 1337;

/**
 * @param TebexOnlinePlayerPurchaseEvent $event
 * @priority MONITOR
 * @ignoreCancelled true
 */
public function onTebexOnlinePlayerPurchase(TebexOnlinePlayerPurchaseEvent $event) : void{
	if($event->getPackage()->getId() === self::PACKAGE_RANDOM_LOOT){
		LootTables::getRandom()->reward($event->getPlayer());
	}
}

or simply logging.

/**
 * @param TebexPlayerPurchaseEvent $event
 * @priority MONITOR
 * @ignoreCancelled true
 */
public function onTebexPlayerPurchase(TebexPlayerPurchaseEvent $event) : void{
	$this->logTebexPurchaseToDiscord(
		$event->getPackage(),
		$event->getPlayer(),
		$event->getCommands()
	);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant