0

If it isn't obvious by the way the title of this post is phrased, I understand what is going wrong, but I do not know the vocabulary necessary to phrase a question to get an answer through google.

Effectively what it boils down to is that I have a php main class that is registering an event listener as such:

class Main extends PluginBase {

public function onEnable(){
    $this->getServer()->getLogger()->info("Loading all the things");
    $pluginManager = $this->getServer()->getPluginManager();

    
    $pluginManager->registerEvents(new SimpleOverrides($this), $this);
    $pluginManager->registerEvents(new AntiGreifListeners($this), $this);

  }
}

The "SimpleOverrides.php" is in a seperate folder called "Listeners" and it's code looks like:

class SimpleOverrides implements Listener{

private $plguin;

public function __construct(Main $plugin){
    $this->plugin = $plugin;
    $this->plugin->getLogger()->info("SimpleOverrides setup!");
}

public function onPluginCommand(PlayerCommandPreprocessEvent $event){
    $message = $event.getMessage();
    $array = split(' ', $message);
    if(strtolower($array[0]) == "pl" || strtolower($array[0]) == "plugins"){
        $event->setCancelled(true);
        $event->getPlayer()->sendMessage(TextFormat::GREEN . "This server operates using 100% custom plugins!");
    }
  }
}

The issue is that in the constructor, its looking to be passed the main class. But the code throws a TypeError because its looking for a Main.php within the "Listeners" folder. How do I make it use the Main class from the main folder?

1 Answers1

0
use HubCore\Main;

the solution was to implement the Main class from the hubcore file, I had a typo preventing this from working from the get-go