1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Coding Plugin

Discussion in 'Plugin Help' started by GeistFan, Jul 20, 2021.

  1. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Your code is also wrong.
    What have you even learned from our previous attempts to guide you through a WHOLE plugin?
    I don't think anyone is willing to walk you through the whole process AGAIN that took more than a month man.
    Seriously, just have at least basic knowledge on coding in general before asking. Please.
    If you're willing to take your time for US to fix your code, why not take time to actually learn coding?
    C'mon man, I'm not even trying to be mean. I'm just telling you what you are supposed to be doing.

    If you're offended by this, you seriously might want to consider giving up on developing for pocketmine-mp, or anything in general.

    Reference: https://forums.pmmp.io/threads/use-player-name-in-config-yml.10959/#post-78398
     
    Agent and Primus like this.
  2. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Oh
    Sorry for this
     
  3. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Code:
    Fatal error: Cannot redeclare GameMode\main::onCommand() in /home/minecraft/plugins/GameMode/src/gamemode/main.php on line 31 
    Why?
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
  5. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    That doesn't exactly help me.
    There it says that if you have "a" aaa is displayed, otherwise bbb
    But I want to do 4 different commands
     
  6. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Look others' examples. There are plenty out there!
     
    Agent likes this.
  7. Primus

    Primus Zombie Pigman

    Messages:
    749
    It exactly says what your problem is if you could read. You dumb ass declared the same function more than once!

    PHP:
    class Main extends PluginBase {
        public function 
    onCommand(): bool {}

        public function 
    onCommand() : bool {}
        
    # That is not allowed ^
    }
     
    minijaham likes this.
  8. Primus

    Primus Zombie Pigman

    Messages:
    749
    Screenshot_6.png
     
  9. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Thank you all you help me so much. The plugin runs.
    Thank you, thank you, thank you
     
  10. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    But the commands doesn't function
     
  11. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Can this code work?
    Code:
       public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args):bool
        {
            switch($cmd)
            {
                case "gm0":
                if($sender->hasPermission("pocketmine.command.gamemode"))
                {
                    $sender->setGamemode(0);
                }
                break;
                case "gm1":
                if($sender->hasPermission("pocketmine.command.gamemode"))
                {
                    $sender->setGamemode(1);
                }
                break;
                case "gm2":
                if($sender->hasPermission("pocketmine.command.gamemode"))
                {
                    $sender->setGamemode(2);
                }
                break;
                case "gm3":
                if($sender->hasPermission("pocketmine.command.gamemode"))
                {
                    $sender->setGamemode(3);
                }
                break;
            }return true;
        }
     
  12. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Did you specify them in plugin.yml?
     
    Agent and Primus like this.
  13. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    Did you mean this?
    Code:
    name: GameMode
    version: Beta 1.0
    main: gamemode\main
    api: [3.0.0, 4.0.0]
    author: GeistFan
    commands:
      gm0:
        description: Set to Survival
        permission: pocketmine.command.gamemode
      gm1:
        description: Set to Creative
        permission: pocketmine.command.gamemode
      gm2:
        description: Set to Adventure
        permission: pocketmine.command.gamemode
      gm3:
        description: Set to Spectator
        permission: pocketmine.command.gamemode
    
    permissions:
      pocketmine.command.gamemode:
        default: op
    
     
    Last edited: Jul 24, 2021
  14. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    ?
     
  15. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
    I fixed it. I forgot te "s" by commands
     
  16. GeistFan

    GeistFan Slime

    Messages:
    86
    GitHub:
    GeistFan
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.