Skip to content

Commit

Permalink
this bites me every single time
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Nov 24, 2024
1 parent 45a4282 commit dcbf1c7
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/player/InventoryWindow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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\player;

use pocketmine\inventory\Inventory;

abstract class InventoryWindow{

public function __construct(
protected Player $viewer,
protected Inventory $inventory
){}

public function getViewer() : Player{
return $this->viewer;
}

public function getInventory() : Inventory{
return $this->inventory;
}

public function onOpen() : void{
$this->inventory->onOpen($this->viewer);
}

public function onClose() : void{
$this->inventory->onClose($this->viewer);
}
}
51 changes: 51 additions & 0 deletions src/player/PlayerInventoryWindow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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\player;

use pocketmine\inventory\Inventory;

/**
* Window for player-owned inventories. The player can access these at all times.
*/
final class PlayerInventoryWindow extends InventoryWindow{

public const TYPE_INVENTORY = 0;
public const TYPE_OFFHAND = 1;
public const TYPE_ARMOR = 2;
public const TYPE_CURSOR = 3;
public const TYPE_CRAFTING = 4;

public function __construct(
Player $viewer,
Inventory $inventory,
private int $type
){
parent::__construct($viewer, $inventory);
}

/**
* Returns the type of player inventory in this window.
*/
public function getType() : int{ return $this->type; }
}

0 comments on commit dcbf1c7

Please sign in to comment.