mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
this unblocks a variety of changes, such as positionless tiles, enhanced APIs on Blocks for inventories, and also eliminates a bunch of cyclic references within the core code. linked to #5033
75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\event\player;
|
|
|
|
use pocketmine\block\inventory\EnchantingTableInventoryWindow;
|
|
use pocketmine\event\Cancellable;
|
|
use pocketmine\event\CancellableTrait;
|
|
use pocketmine\item\enchantment\EnchantingOption;
|
|
use pocketmine\player\Player;
|
|
use pocketmine\utils\Utils;
|
|
use function count;
|
|
|
|
/**
|
|
* Called when a player inserts an item into an enchanting table's input slot.
|
|
* The options provided by the event will be shown on the enchanting table menu.
|
|
*/
|
|
class PlayerEnchantingOptionsRequestEvent extends PlayerEvent implements Cancellable{
|
|
use CancellableTrait;
|
|
|
|
/**
|
|
* @param EnchantingOption[] $options
|
|
*/
|
|
public function __construct(
|
|
Player $player,
|
|
private readonly EnchantingTableInventoryWindow $inventory,
|
|
private array $options
|
|
){
|
|
$this->player = $player;
|
|
}
|
|
|
|
public function getInventory() : EnchantingTableInventoryWindow{
|
|
return $this->inventory;
|
|
}
|
|
|
|
/**
|
|
* @return EnchantingOption[]
|
|
*/
|
|
public function getOptions() : array{
|
|
return $this->options;
|
|
}
|
|
|
|
/**
|
|
* @param EnchantingOption[] $options
|
|
*/
|
|
public function setOptions(array $options) : void{
|
|
Utils::validateArrayValueType($options, function(EnchantingOption $_) : void{ });
|
|
if(($optionCount = count($options)) > 3){
|
|
throw new \LogicException("The maximum number of options for an enchanting table is 3, but $optionCount have been passed");
|
|
}
|
|
|
|
$this->options = $options;
|
|
}
|
|
}
|