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

/command Player

Comments in 'Plugin Development' started by MyAJVideo, Jun 29, 2015.

  1. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Du wolltest ja wissen, wie man dem Spieler aus dem Befehl eine Nachricht schickt, das geht mit
    PHP:
    $player $args[1];
    if(
    $player $this->getServer()->getPlayer($player)){
       
    // Spieler ist auf dem Server
       
    $player->sendMessage("Nachricht");
    } else{
       
    // Spieler ist nicht auf dem Server
    }
    Die anderen haben aber gesagt, dass du eine Nachricht mit
    PHP:
    $sender->sendMessage();
    schicken kannst, die würde dann aber nur dir angezeigt, also ist es nicht das was du wolltest und das hab ich ihnen gesagt^^
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    For what reason to you believe that he only understands the meaning of $player and not $sender? It's just the same...
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    What?
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
  5. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    After reading this thread I can see you need help so I rewrote the plugin so it works

    Main.php:
    PHP:
    <?php

    namespace name\space;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    class 
    Main extends PluginBase {
       
        public function 
    onEnable(){
            
    $this->getLogger()->info("plugin is on");
        }
       
        public function 
    onDisable() {
            
    $this->getLogger()->info("plugin is now disabled");
        }
       
        public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args) {
            if(
    strtolower($cmd->getName()) === "staff") {
                if(isset(
    $args[0])) {
                    switch(
    strtolower($args[0])) {
                        case 
    "a":
                            
    $sender->sendMessage("Administrator's");
                        break;
                        case 
    "m":
                            
    $sender->sendMessage("Moderator's");
                        break;
                        case 
    "o":
                            
    $sender->sendMessage("Owner's and Co-Owner;s");
                        break;
                    }
                    return 
    true;
                }
                else {
                    
    $sender->sendMessage("Plese specify your Staff:\n- Admins: /staff a\n- Moderators: /staff m\n- Owners: /staff o");
                    return 
    true;
                }
            }
        }

    }
    plugin.yml:
    Code:
    name: Plugin-Name
    author: Your-NAme
    version: 1.0
    description: Plugin description
    main: to\your\main
    api: [1.12.0]
    
    commands:
        staff:
            description: "Displays Command usage"
        staff a:
            description: "Displays a list of Admins"
            staff m:
                description: "Displays a list of Mods"
            staff o:
                description: "Displays a list of Owners and Co-Owners"
    
  6. GmWM
    Offline

    GmWM Active Member Plugin Developer

    Joined:
    Sep 8, 2013
    Posts:
    181
    Plugins:
    3
    That is his job to define $player or $sender and good job. Now he is confused.

Share This Page

Advertisement