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

There's an error on my plugin, and I don't know how to fix it

Comments in 'Plugin Development' started by BlubberBoy333, Apr 29, 2015.

  1. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Also, when it crashes it sends a bunch of messages to the console. Here's what they say:
    Warning: Uncaught exception 'ClassNotFoundException' with message 'Class Blubberboy333\ServerMOTD\Main\pocketmine\command\CommandSender not found' in phar:///home/max/PocketMine-MP.phar/src/spl/BaseClassLoader.php:144
    Stack trace:
    #0 [internal function]: BaseClassLoader->loadClass('Blubberboy333\\S...')
    #1 /home/max/plugins/ServerMOTD_v0.1.0/src/Blubberboy333/ServerMOTD/Main.php(21): spl_autoload_call('Blubberboy333\\S...')
    #2 phar:///home/max/PocketMine-MP.phar/src/spl/BaseClassLoader.php(128): include('/home/max/plugi...')
    #3 [internal function]: BaseClassLoader->loadClass('Blubberboy333\\S...')
    #4 [internal function]: spl_autoload_call('Blubberboy333\\S...')
    #5 phar:///home/max/plugins/DevTools_v1.10.0.phar/src/FolderPluginLoader/FolderPluginLoader.php(64): class_exists('Blubberboy333\\S...', true)
    #6 phar:///home/max/PocketMine-MP.phar/src/pocketmine/plugin/PluginManager.php(152): FolderPluginLoader\FolderPluginLoader->loadPlugin('/home/max/plugi...')
    #7 phar:///home/max/PocketMine-MP.phar/src/pocketmine/plugin/Pl in phar:///home/max/PocketMine-MP.phar/src/spl/BaseClassLoader.php on line 144

    Fatal error: Declaration of Blubberboy333\ServerMOTD\Main\ServerMOT:eek::eek:nCommand() must be compatible with pocketmine\command\CommandExecutor::eek:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args) in /home/max/plugins/ServerMOTD_v0.1.0/src/Blubberboy333/ServerMOTD/Main.php on line 21
  2. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I found a typo on line 21 (I spelled listener wrong again) so I fixed that, but it still crashes. Does anyone know why it's crashing?
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Full code again?
  4. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    The code for the entire plugin, or just the onCommand function?
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Entire plugin + Crashlog
  6. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Plugin code:
    PHP:
    ?php

    namespace Blubberboy333\ServerMOTD\Main;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\command\CommandSender;
    use 
    pocektmine\command\Command;

    class 
    ServerMOTD extends PluginBase implements Listener {
      

      
        public function 
    onEnable(){
          
        
    // Setting up the variables
        
    $motd = array("Original MOTD");
      
            
    $this->getLogger()->info("ServerMOTD has been loaded successfully!");
            
    $this->getLogger()->info(TextFormat::BLUE "Current MOTD:" $motd);
        }
        public function 
    onDisable(){
            
    $this->getLogger()->info("ServerMOTD has been disabled successfully!");
        }
      
        
    //onCommand(CommandSender $sender, Command $command, $label, array $args)
      
        
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
            switch(
    $command->getName()){
                case 
    "set":
                    if(
    $sender instanceof Player && $sender->hasPermission("motd.command.set")){
                        
    $newMOTD $this->getPlayerMessage();
                        
    $motd[0] = $newMOTD;
                        
    $sender->sendMessage("You have successfully set the MOTD.");
                    return 
    true;
                    }else{
                        
    $sender->sendMessage("Error: You don't have permission to set the MOTD!");
                return 
    false;
                    }
                break;
                case 
    "read":
                    if(
    $sender instanceof Player && $sender->hasPermission("motd.command.read")){
                        if(
    $motd != null){
                            
    $sender->sendMessage("Today's MOTD:");
                            
    $sender->sendMessage($motd);
                        return 
    true;
                        }elseif(
    $motd == null){
                            
    $sender->sendMessage("There isn't a MOTD yet!");
                  
                        return 
    false;
                    }
                    }else{
                        
    $sender->sendMessage("You don't have permission to read the MOTD!");
                    return 
    false;
                    }
                break;
                case 
    "motd":
                    if(
    $sender instanceof Player && $sender->hasPermission("motd.command.motd")){
                        
    $sender->sendMessage("Usage: /motd read, /motd set");
                    return 
    true;
                    }
                    else{
                        
    $sender->sendMessage("You don't have permission to do that!");
                return 
    false;
                    }
                }
            }
        public function 
    onEntityRespawnEvent(EntityRespawnEvent $event){
            if(
    $entity instanceof Player && $entity->hasPermission("motd.command.read")){
                
    $entity->sendMessage("Today's MOTD:");
                
    $enitity->sendMessage($motd);
            }else{
                
    $entity->sendMessage("You don't have permission to view the MOTD!");
            }
        }
    }
    Crash dump:
    PocketMine-MP Crash Dump Sat May 2 16:10:13 UTC 2015

    Error: Declaration of Blubberboy333\ServerMOTD\Main\ServerMOT:eek::eek:nCommand() must be compatible with pocketmine\command\CommandExecutor::eek:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args)
    File: /ServerMOTD_v0.1.0/src/Blubberboy333/ServerMOTD/ServerMOTD
    Line: 21
    Type: E_COMPILE_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [12]
    [13] namespace Blubberboy333\ServerMOTD\Main;
    [14]
    [15] use pocketmine\plugin\PluginBase;
    [16] use pocketmine\event\Listener;
    [17] use pocketmine\event\player\PlayerRespawnEvent;
    [18] use pocketmine\command\CommandSender;
    [19] use pocektmine\command\Command;
    [20]
    [21] class ServerMOTD extends PluginBase implements Litsener {
    [22]
    [23]
    [24]
    [25] public function onEnable(){
    [26]
    [27] // Setting up the variables
    [28] $motd = array("Original MOTD");
    [29]
    [30] $this->getLogger()->info("ServerMOTD has been loaded successfully!");
    [31] $this->getLogger()->info(TextFormat::BLUE . "Current MOT:eek:" . $motd);

    Backtrace:
    #0 (): pocketmine\Server->crashDump()

    PocketMine-MP version: 1.4.1 #980 [Protocol 20; API 1.11.0]
    Git commit: 0000000000000000000000000000000000000000
    uname -a: Linux benjamin-CF-T8EWATZAM 3.2.0-80-generic-pae #116-Ubuntu SMP Mon Mar 23 17:29:27 UTC 2015 i686
    PHP Version: 5.6.6
    Zend version: 2.6.0
    OS : Linux, linux

    Stuff it says before the server crashes:
    Warning: Uncaught exception 'ClassNotFoundException' with message 'Class Blubberboy333\ServerMOTD\Main\pocketmine\command\CommandSender not found' in phar:///home/max/PocketMine-MP.phar/src/spl/BaseClassLoader.php:144
    Stack trace:
    #0 [internal function]: BaseClassLoader->loadClass('Blubberboy333\\S...')
    #1 /home/max/plugins/ServerMOTD_v0.1.0/src/Blubberboy333/ServerMOTD/ServerMOTD.php(21): spl_autoload_call('Blubberboy333\\S...')
    #2 phar:///home/max/PocketMine-MP.phar/src/spl/BaseClassLoader.php(128): include('/home/max/plugi...')
    #3 [internal function]: BaseClassLoader->loadClass('Blubberboy333\\S...')
    #4 [internal function]: spl_autoload_call('Blubberboy333\\S...')
    #5 phar:///home/max/plugins/DevTools_v1.10.0.phar/src/FolderPluginLoader/FolderPluginLoader.php(64): class_exists('Blubberboy333\\S...', true)
    #6 phar:///home/max/PocketMine-MP.phar/src/pocketmine/plugin/PluginManager.php(152): FolderPluginLoader\FolderPluginLoader->loadPlugin('/home/max/plugi...')
    #7 phar:///home/max/PocketMine-MP.phar/src/pocketmine/plu in phar:///home/max/PocketMine-MP.phar/src/spl/BaseClassLoader.php on line 144

    Fatal error: Declaration of Blubberboy333\ServerMOTD\Main\ServerMOT:eek::eek:nCommand() must be compatible with pocketmine\command\CommandExecutor::eek:nCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args) in /home/max/plugins/ServerMOTD_v0.1.0/src/Blubberboy333/ServerMOTD/ServerMOTD.php on line 21
    16:12:47 [EMERGENCY] An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    16:12:47 [EMERGENCY] Please submit the "/home/max/CrashDump_Sat_May_2-16.12.47-UTC_2015.log" file to the Bug Reporting page. Give as much info as you can.
    16:12:47 [INFO] Disabling DevTools v1.10.0
  7. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I think I found the problem...
  8. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    What code would I use if I wanted to broadcast a message to the entire server?
  9. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    PHP:
    $this->getServer()->broadcastMessage("This is one f-ing awesome broadcast.");
    BlubberBoy333 likes this.
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Just look through the API documentation, sheesh.
  11. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Ok, now i'm getting this:
    ClassNotFoundException: "Class Blubberboy333\ServerMOTD\ServerMOTD not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 131
    I've seen that before, and I've been able to fix it, but this time I don't know what's wrong. The main class, and the namespace in the main code are the same. I could fix this problem by making sure the main class in the plugin.yml file, the namespace in the main code, and the filename of the main code are the same (which they are in this case) but it isn't working

Share This Page

Advertisement