Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions src/superarmor/middle1/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
use pocketmine\command\CommandSender;
use pocketmine\player\Player;
use pocketmine\item\VanillaItems;
use pocketmine\Server;
use pocketmine\utils\Config;
use pocketmine\math\Vector3;
use superarmor\middle1\libs\Form\SimpleForm;
use jojoe77777\FormAPI\SimpleForm;
use superarmor\middle1\Data\ {
Enchantments, Items
};

class Main extends PluginBase implements Listener
{
private $config;
private Config $config;

public function onEnable() : void
{
Expand All @@ -29,16 +29,16 @@ public function onEnable() : void
$this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML);
}

public function onCommand(CommandSender $p, Command $cmd, string $label, array $args) : bool
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool
{
if ($cmd->getName() == "armor") {
if (!$p instanceof Player) {
if ($command->getName() == "armor") {
if (!$sender instanceof Player) {
$this->getLogger()->info("Only player");
return true;
}

if (!$p->isSurvival()) {
$p->sendMessage("§cIn survival only!");
if (!$sender->isSurvival()) {
$sender->sendMessage("§cIn survival only!");
return true;
}

Expand All @@ -55,18 +55,24 @@ function (Player $sender, ? int $result = null) {
$item_count = $inventory->getItemInHand()->getCount(); //переменная для счёта кол-во предметов в руке игрока
$EnchantmentsClass = new Enchantments($this->config); //объявление Enchantments класса
$ItemsClass = new Items($this->config); //объявления Items класса
if ($item_in_hand_name != $this->config->getNested("buy-armor.name-item-for-buy") || $item_count < $this->config->getNested("full-armor.cost")) {
$price = $this->config->getNested("full-armor.cost");
$item_for_buy = $this->config->getNested("buy-armor.name-item-for-buy");
if ($item_in_hand_name != $item_for_buy || $item_count < $price) {
$sender->sendMessage(
"Take in hand " . $this->config->getNested("full-armor.cost") . " diamonds");
"Take in hand " . $price . " " . $item_for_buy);
return true;
}
$inventory->removeItem(VanillaItems::DIAMOND()->setCount($this->config->getNested("full-armor.cost")));
if(empty(VanillaItems::$item_for_buy())){
Server::getInstance()->getLogger()->warning("The " . $item_for_buy ." is not VanillaItems");
return false;
}
$inventory->removeItem(VanillaItems::$item_for_buy()->setCount($price));
$position = $sender->getPosition();
//Все предметы
$boots = $ItemsClass->getName("boots"); // Ботинки
$chest = $ItemsClass->getName("chest"); // Кирасса
$helmet = $ItemsClass->getName("helmet"); // Шлем
$leggins = $ItemsClass->getName("leggins"); // Штаны
// $boots = $ItemsClass->getName("boots"); // Ботинки
// $chest = $ItemsClass->getName("chest"); // Кирасса
// $helmet = $ItemsClass->getName("helmet"); // Шлем
// $leggins = $ItemsClass->getName("leggins"); // Штаны
// Все чары
$boots = $EnchantmentsClass->getEnchantments("boots");
$chest = $EnchantmentsClass->getEnchantments("chest");
Expand Down Expand Up @@ -108,7 +114,6 @@ function (Player $sender, ? int $result = null) {
break;

case 2:
return true;
break;
}
return false;
Expand All @@ -118,8 +123,9 @@ function (Player $sender, ? int $result = null) {
$form->addButton("§8To buy super armor", 0, "textures/items/chainmail_chestplate.png");
$form->addButton("§7FAQ", 0, "textures/items/book_normal.png");
$form->addButton("§o§cExit");
$form->sendToPlayer($p);
$form->sendToPlayer($sender);
return true;
}
return true;
}
}