Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD COMMAND #100

Open
Pamela0215 opened this issue Oct 31, 2022 · 1 comment
Open

ADD COMMAND #100

Pamela0215 opened this issue Oct 31, 2022 · 1 comment

Comments

@Pamela0215
Copy link

Bonjour,
Les NPC spawn bien.
J'arrive à changer leurs noms.
Mais dans le edit la commande : ADD COMMAND ne fonctionne pas.
J'explique :
Dans ADD COMMAND j'ai tapé :
give @p dirt 64
/give @p dirt 64
Quand je clique sur le NPC la commande ne s'exécute pas.
J'ai essayé d'installer un plugin pour les @p e a s r etc mais le plugin fait crash mon serveur.
Pouvez vous m'aider svp ?

@funnycars
Copy link

funnycars commented Jan 18, 2023

I don't know if it's correct, but if you change "CommandManager.php" like this, the command will work normally.

<?php

declare(strict_types=1);

namespace brokiem\snpc\manager\command;

use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;

final class CommandManager {

    private array $commands = [];

    public function __construct(CompoundTag $nbt) {
        if (($commandsTag = $nbt->getTag('Commands')) instanceof ListTag) {
            foreach ($commandsTag as $stringTag) {
                $this->add($stringTag->getValue());
            }
        }
    }

    public function add($command): bool {
        if (!$this->exists($command)) {
            $this->commands[] = $command;

            return true;
        }

        return false;
    }

    public function exists(string $command): bool {
        if (in_array($command, $this->commands, true)) {
            return true;
        }

        return false;
    }

    public function getAll(): array {
        return $this->commands;
    }

    public function remove($command): bool {
        if ($this->exists($command)) {
            unset($this->commands[$command]);

            return true;
        }

        return false;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants