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
    I'm making a plugin and when i start my server, the server doesn't crash, but the plugin doesn't load. The code folder is in the plugins folder. There is an error when I start the server. It says:

    [ERROR] Could not load '/home/max/plugins/MOTD_v0.1.0' in folder '/home/max/plugins/': yaml_parse(): parsing error encountered during parsing: did not find expected key (line 27, column 23), context while parsing a block mapping (line 23, column 5)

    If someone knows how to fix this please let me know. If you need to see the plugin.yml file (i think that's what is wrong but i'm not sure what key it needs when is says "did not find expected key (line 27, column 23)") i can post it. Thanks :D
  2. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    You have tabs in your plugin.yml file.
  3. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I don't have any tabs in the plugin.yml file, i'm using spaces instead. I'll leave the plugin.yml below so you can see it
    name: ServerMOTD
    version: 0.1.0
    api: 1.0.0
    main: Blubberboy333\MOTD\Main
    commands:
    motd:
    usage: "/motd"
    description: "Gives a list of all possible commands"
    permission: motd.command.motd
    motd set:
    usage: "/motd set"
    description: "Allows the player to set the MOTD"
    permission: motd.command.set
    motd read:
    usage: "/motd read"
    description: "Allows the player to read the MOTD"
    permission: motd.command.read
    permissions:
    motd.command:
    description: "Allows the player to use all of the MOTD functions
    default: op
    children:
    motd.command.set:
    description: "Allows the player to set the MOTD"
    default: op
    motd.command.read:
    description: "Allows the player to read the MOTD"
    default: true
    motd.command.motd:
    description: "Allows the player to see a list of possible commands" default: true
    Last edited: Apr 30, 2015
  4. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    PHP:
    motd.command:
    description"Allows the player to use all of the MOTD functions"
    default: op
    Your forgot a "
  5. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    You are missing a quote here:

    Code:
    description: "Allows the player to use all of the MOTD functions
    
  6. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    Here is the correct MOTD

    name: ServerMOTD
    version: 0.1.0
    api: 1.0.0
    main: Blubberboy333\MOTD\Main
    commands:
    motd:
    usage: "/motd"
    description: "Gives a list of all possible commands"
    permission: motd.command.motd
    motd set:
    usage: "/motd set"
    description: "Allows the player to set the MOTD"
    permission: motd.command.set
    motd read:
    usage: "/motd read"
    description: "Allows the player to read the MOTD"
    permission: motd.command.read
    permissions:
    motd.command:
    description: "Allows the player to use all of the MOTD functions"
    default: op
    children:
    motd.command.set:
    description: "Allows the player to set the MOTD"
    default: op
    motd.command.read:
    description: "Allows the player to read the MOTD"
    default: true
    motd.command.motd:
    description: "Allows the player to see a list of possible commands"
    default: true
  7. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Thanks, when i added a " the plugin loaded, but the server crashed... I guess it's time for some debugging
  8. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    I can help you with said crash. Show me the crashdump, and I can see what the cause is.
  9. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I'm pretty sure i know what caused the crash. I'll try to fix it and if i can't i'll show you
  10. Exxarion
    Offline

    Exxarion Active Member Plugin Developer

    Joined:
    Jan 5, 2014
    Posts:
    242
    Plugins:
    1
    Minecraft User:
    Notch
    k then.
  11. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Ok I need help. The crash dumps are telling me that i have an undefined variable, but the variable is defined in the onCommand() method. Here's the crash dump:
    PocketMine-MP Crash Dump Thu Apr 30 01:59:59 UTC 2015

    Error: syntax error, unexpected '$p' (T_VARIABLE)
    File: /ServerMOTD_v0.1.0/src/Blubberboy333/MOTD/Main
    Line: 41
    Type: E_PARSE

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [32] public function onDisable(){
    [33] $this->getLogger()->info("MOTD has been disabled successfully!");
    [34] }
    [35]
    [36] public function onCommand(CommandSender $p, Command $c, $commandLabel, array $args){
    [37] if(strtolower($c->getName()) === "set"){
    [38] if($p instanceof Player && $p->hasPermission("motd.command.set")){
    [39] $newMOTD = $this->getPlayerMessage();
    [40] $motd[0] = $newMOTD
    [41] $p->sendMessage("You have successfully set the MOTD.");
    [42] return true;
    [43] }else{
    [44] $p->sendMessage("Error: You don't have permission to set the MOTD!");
    [45] }
    [46] return false;
    [47] public function onCommand(CommandSender $p, Command $c, $commandLabel, array $args){
    [48] if(strtolower($c->getName()) === "read"){
    [49] if($p instanceof Player && $p->hasPermission("motd.command.read"){
    [50] if($motd != null){
    [51] $p->sendMessage("Today's MOT:eek:");

    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
  12. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Define $p
  13. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    You are missing the ";" is line 40.
    Falk likes this.
  14. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I fixed that but there's a new problem that i don't know how to fix. On the onCommand() function, it told me that i can't repeat is, so i started using the "case" line. But when the server crashes it tells me that there is an unexpected "case". Crash dump:
    PocketMine-MP Crash Dump Thu Apr 30 19:09:44 UTC 2015

    Error: syntax error, unexpected 'case' (T_CASE)
    File: /ServerMOTD_v0.1.0/src/Blubberboy333/MOTD/Main
    Line: 37
    Type: E_PARSE

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [28]
    [29] $this->getLogger()->info("MOTD has been loaded successfully!");
    [30] $this->getLogger()->info(TextFormat::BLUE . "Current MOT:eek:" . $motd);
    [31] }
    [32] public function onDisable(){
    [33] $this->getLogger()->info("MOTD has been disabled successfully!");
    [34] }
    [35]
    [36] public function onCommand(CommandSender $p, Command $c, $commandLabel, array $args){
    [37] case 'set':
    [38] if($p instanceof Player && $p->hasPermission("motd.command.set")){
    [39] $newMOTD = $this->getPlayerMessage();
    [40] $motd[0] = $newMOTD;
    [41] $p->sendMessage("You have successfully set the MOTD.");
    [42] return true;
    [43] }else{
    [44] $p->sendMessage("Error: You don't have permission to set the MOTD!");
    [45] return false;
    [46] }
    [47] case: 'read':

    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
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Syntax for a switch block:
    PHP:
    switch($value){
      case 
    "value1"// if $value == "value1" (see warning below)
        // do something
        
    break; // don't break if you want it to run the lines after this line (i.e. "value2"'s lines)
      
    case "value2"// if $value == "value2" (warning: switch-case checks with == not ===, so switching false would go to a case of 0)
        // do something
        
    break; // don't break if you want it to run the lines for default
      
    default: // if none of the above cases matched, or if you didn't break
        // do something
    }
  16. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    Ok, I fixed that problem but, of course, there is another one. This one is pretty bad. When i start the server it crashes and sends a bunch of lines to the console. Here's the crash dump:
    PocketMine-MP Crash Dump Fri May 1 02:59:20 UTC 2015

    Error: Declaration of Blubberboy333\MOTD\Main\MOT: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/MOTD/Main
    Line: 21
    Type: E_COMPILE_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code:
    [12]
    [13] namespace Blubberboy333\MOTD\Main;
    [14]
    [15] use pocketmine\plugin\PluginBase;
    [16] use pocketmine\event\Litsener;
    [17] use pocketmine\event\player\PlayerRespawnEvent;
    [18] use pocketmine\command\ComandSender;
    [19] use pocektmine\command\Command;
    [20]
    [21] class MOTD 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("MOTD 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

    Thanks for all of your help guys I really appreciate it :D
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The declaration of your onCommand function is incorrect. The parameter names may be different, but the number of parameters and their types must be the same as that in CommandExexutor.
  18. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I've checked the code from other plugins, and used the same onCommand parameter names and it still crashes. Here is the onCommand function I use:
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args){
  19. 64FF00
    Offline

    64FF00 Active Member Plugin Developer

    Joined:
    May 11, 2014
    Posts:
    297
    Plugins:
    2
    Minecraft User:
    64FF00
    Fix the typos on line 16 and 18.
    Code:
    use pocketmine\event\Litsener; // Listener
    use pocketmine\command\ComandSender; // CommandSender
    
    PEMapModder and RekkuzaRage like this.
  20. BlubberBoy333
    Offline

    BlubberBoy333 Active Member

    Joined:
    Aug 31, 2014
    Posts:
    177
    Minecraft User:
    Blubberboy333
    I fixed those but it's still crashing

Share This Page

Advertisement