Muqsit / InvMenu

A PocketMine-MP virion to create and manage virtual inventories!
https://poggit.pmmp.io/ci/Muqsit/InvMenu/~
GNU General Public License v3.0
201 stars 75 forks source link

Main #123

Closed callumrawlinson closed 3 years ago

callumrawlinson commented 3 years ago

Hello the issue is

Error: "Class 'muqsit\invmenu\InvMenuHandler' not found" (EXCEPTION) in "plugins/gamegui (1).phar/src/callum/games/Main" at line 20 [12:59:47] [Server thread/CRITICAL]: #0 pmsrc/src/pocketmine/plugin/PluginBase(116): callum\games\Main->onEnable() [12:59:47] [Server thread/CRITICAL]: #1 pmsrc/src/pocketmine/plugin/PluginManager(552): pocketmine\plugin\PluginBase->setEnabled(boolean 1) [12:59:47] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/Server(1786): pocketmine\plugin\PluginManager->enablePlugin(object callum\games\Main) [12:59:47] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/Server(1772): pocketmine\Server->enablePlugin(object callum\games\Main) [12:59:47] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Server(1585): pocketmine\Server->enablePlugins(integer 1) [12:59:47] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/PocketMine(272): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[16] /home/container/, string[24] /home/container/plugins/) [12:59:47] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/PocketMine(302): pocketmine\server() [12:59:47] [Server thread/CRITICAL]: #7 pmsrc(11): require(string[71] phar:///home/container/PocketMine-MP.phar/src/pocketmine/PocketMine.php) [12:59:47] [Server thread/INFO]: Disabling GamesGUI v1.0.0

callumrawlinson commented 3 years ago

my code is `<?php

namespace callum\games;

use muqsit\invmenu\InvMenu; use muqsit\invmenu\InvMenuHandler; use muqsit\invmenu\transaction\InvMenuTransaction; use muqsit\invmenu\transaction\InvMenuTransactionResult; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\PluginCommand; use pocketmine\item\Item; use pocketmine\Player; use pocketmine\plugin\PluginBase;

class Main extends PluginBase{

public function onEnable(){
    $this->getLogger()->info("GameGUI has been enabled");
    if(!InvMenuHandler::isRegistered()){
        InvMenuHandler::register($this);
    }
    $command = new PluginCommand("games", $this);
    $command->setDescription("Open GameGUI");
    $this->getServer()->getCommandMap()->register("game", $command);
}

public function onDisable(){
    $this->getLogger()->info("GameGUI has been disabled");
}

public function onCommand(CommandSender $player, Command $cmd, string $label, array $args) : bool{
    switch($cmd->getName()){
        case "games":
            if(!$player instanceof Player){
                $player->sendMessage("Opening");
                return true;
            }
            $this->games($player);
            break;
    }
    return true;
}

public function games(Player $player){
    $menu = InvMenu::create(InvMenu::TYPE_CHEST);
    $menu->readOnly();
    $menu->setListener(\Closure::fromCallable([$this, "GUIListener"]));
    $menu->setName("GameGUI");
    $menu->send($player);
    $inv = $menu->getInventory();
    $lava = Item::get(Item::STILL_LAVA)->setCustomName("HotBlock");
    $axe = Item::get(Item::IRON_AXE)->setCustomName("Murder Mystery");
    $pearl = Item::get(Item::ENDER_PEARL)->setCustomName("The Bridge");
    $stone = Item::get(Item::STONE)->setCustomName("Hub");
    $inv->setItem(2, $lava);
    $inv->setItem(4, $axe);
    $inv->setItem(6, $pearl);
    $inv->setItem(8, $stone);
}

public function GUIListener(InvMenuTransaction $action) : InvMenuTransactionResult{
    $itemClicked = $action->getOut();
    $player = $action->getPlayer();
    if($itemClicked->getId() == 11){
        $action->getAction()->getInventory()->onClose($player);
        $player->sendMessage("Joining");
        \pocketmine\Server::getInstance()->dispatchCommand($player, "mw tp HotBlock");
        return $action->discard();
    }
    if($itemClicked->getId() == 258){
        $action->getAction()->getInventory()->onClose($player);
        $player->sendMessage("Joining");
        \pocketmine\Server::getInstance()->dispatchCommand($player, "mdr join MMHUB");
        return $action->discard();
    }
    if($itemClicked->getId() == 368){
        $action->getAction()->getInventory()->onClose($player);
        $player->sendMessage("Joining");
        \pocketmine\Server::getInstance()->dispatchCommand($player, "tb join");
        return $action->discard();
    }
    if($itemClicked->getId() == 1){
        $action->getAction()->getInventory()->onClose($player);
        $player->sendMessage("Joining");
        \pocketmine\Server::getInstance()->dispatchCommand($player, "mw tp Sea Temple");
        return $action->discard();
    }
    return $action->discard();
}

} `

callumrawlinson commented 3 years ago

@Muqsit do i need to put the musqit\invmenu folder included in src

callumrawlinson commented 3 years ago

this is the plugin https://github.com/callumrawlinson/GamesGUI

callumrawlinson commented 3 years ago

@Muqsit i just need to include the src musqit thank you

Muqsit commented 3 years ago

@callumrawlinson In case you run into further issues with virion installation, the wiki has a nice tutorial on how to use InvMenu in a plugin in both — a development environment and a production environment (i.e., with and without dev plugins such as DEVirion, DevTools) https://github.com/Muqsit/InvMenu/wiki/Using-InvMenu-in-a-plugin#running-invmenu-from-phar

callumrawlinson commented 3 years ago

@Muqsit is my plugin ok. It's on my profile