Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Added events for KitUI #113

Merged
merged 3 commits into from
Jun 5, 2019
Merged

Added events for KitUI #113

merged 3 commits into from
Jun 5, 2019

Conversation

larryTheCoder
Copy link
Contributor

Pull Request description

Since this plugin only intended for "server use" and not "plugin use", I decided to add some events on this plugin so developers could actually cancels, change or listen to any changes that has been made in this plugin or player itself.

Name of events

  • KitEvent Backbone of the kit event and not intended to be used, but extends to it.
  • KitEquipEvent This event is called when the player tries to equip a kit without paying it first.
  • KitPurchaseEvent This event will be called if there is a price when buying a kit.

You could add another event if you want to, this is just basics for the kit events, as some additional requests to use this kit on their plugins

Code of the API

// This is a function in a class that implements listener and
// Has been registered by event Listener.

// use Infernus101\KitUI\events\KitPurchaseEvent;
public function onKitPurchase(KitPurchaseEvent $event){
	$event->setPrice(500);       // Set the amount that you want.

	$pl = $event->getPlayer();   // Get the player that buys the kit.
	$price = $event->getPrice(); // The price of the kit.

	// This message will be sent to the player.
	$pl->sendMessage("You bought this kit for $price");
}

// use Infernus101\KitUI\events\KitEquipEvent;
public function onKitEquip(KitEquipEvent $event){
	$pl = $event->getPlayer();   // Get the player that buys the kit.
	$kit = $event->getKit();     // Return the kit that player tries to equip

	$event->setCancelled(true);  // Cancels them
}

Side note

This code has been formatted properly and documented as possible.

@Infernus101
Copy link
Owner

Good job formatting 💯

@Infernus101 Infernus101 merged commit 2616d4f into Infernus101:master Jun 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants