Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

The plugin is not responding... at all.

Comments in 'Plugin Development' started by minebuilder0110, Feb 14, 2016.

  1. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    PHP:
    use pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\inventory\PlayerInventory;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;

    class 
    Main extends PluginBase implements Listener{
        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TextFormat::AQUA "Enabled.");
        }
        public function 
    onEntityDamage(EntityDamageEvent $event){
            
    $victim $event->getEntity();
            
    $inv $victim->getInventory();
            
    $helmet $inv->getHelmet()->getID();
            
    $chestplate $inv->getChestplate()->getID();
            
    $leggings $inv->getLeggings()->getID();
            
    $boots $inv->getBoots()->getID();
            
    $damage $event->getDamage();
            
    $cause $event->getCause();
            
    $this->getLogger()->info("Detected.");
            
    $victim->sendMessage("You have been damaged by $cause.");
    }
    public function 
    onCommand(CommandSender $senderCommand $command$label, array $args){
            if(
    $command->getName() === "debug"){
                
    $sender->sendMessage("DEBUG");
        }
    }
    So this is part of the plugin I am working on, but it seems that literally nothing happens, including the console. I just don't understand what could possibly be wrong. The plugin seems loaded correctly in /plugins, but I tried damaging myself, using the registered command /debug, and even adding a message when the plugin is enabled. None of these happened. I just have no idea what could be causing this.
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    I can tell you: if you have another plugin where plugin.yml uses another plugin's namespace, the other plugin's main will be loaded, (only if the namespace on the another Main is correct)
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Is the plugin actually in red color in /plugins? That means that it has been disabled.

    Enable debug in pocketmine.yml (set debug.level to 2) and read every line of console output.
    PocketKiller likes this.
  4. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    So I should make namespace unique for each plugins?
    Yup, green, no debug messages...
  5. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    yes and directory of course.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Namespaces should be the unique identifier for a plugin. Every plugin should have its unique namespace so that its classes won't duplicate with other classes.

    In Android, apps are actually identified by their packages, and package is the counterpart of namespaces in Java. However, ironically, Android apps don't have the problem of duplicated package names technically because they are run in separate JVMs :p
    Last edited: Feb 14, 2016

Share This Page

Advertisement