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

Command not work

Comments in 'Plugin Development' started by PolskiTHEPLAYER, Apr 27, 2016.

  1. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    ------------plugin.yml------

    name: CobblexKup
    main: Flsmers\Main
    api: 1.13.1
    version: 1.0.0
    author: Flsmers
    website: www.goldforest.pl

    commands:
    cobblex:
    usage: /skyblock
    description: Wyswietla informacje o cobblex
    permission: skyblock.command
    permissions:
    skyblock.command:
    default: true
    description: Uprawnia do uzywania komend

    --------------Main.php--------------

    <?php

    namespace Flsmers;

    use pocketmine\plugin\PluginBase;
    use pocketmine\item\Item;
    use pocketmine\Player;
    use pocketmine\utils\Config;
    use oocketmine\inventory\Inventory;
    use pocketminr\command\ConsoleCommandSender;
    use pocketmine\command\CommandSender;
    use pocketmine\command\Command;

    class Main extends PluginBase{
    public function onEnable(){
    }
    $this->getLogger()->info("§a[Cobblex] Włączony");
    }

    public function onCommand(CommandSender $sender, Command $command, $label, array $args){
    if(strtolower($command->getName('cobblex'))) {
    if(empty($args)) {
    $sender->sendMessage("");
    $sender->sendMessage("• §9>> §aZdobądz 64 cobblestona §9>> §a/skyblock 1");
    $sender->sendMessage("• §9>> §aZdobądz 32 złota §9>> §a/skyblock 2");
    $sender->sendMessage("• §9>> §aZdobądz 32 żelaza §9>> §a/skyblock 3");
    $sender->sendMessage("• §9>> §aZdobądz 64 diamenty §9>> §a/skyblock 4");
    $sender->sendMessage("• §9>> §cWięcej zadań wkrótce :)");
    return true;
    }
    if($args[0] == "kup") {
    }else{
    if($sender->getInventory()->contains(Item::get(4, 0, 64))){
    $sender->getInventory()->addItem(Item::get(388, 0, 1));
    $sender->sendMessage("§a • Kupiłeś cobblex • ");
    }
    else{
    $sender->sendMessage("§c • Nie masz cobblestone'a • ");
    }
    }
    return true;
    }
    }
    }
    }

    Plzz help me command not work

    Attached Files:

  2. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    You have to register events


    PHP:
    If ( $command->getName() == strtolower($commadname) ) :
    # strtolower small string
    #code -
    endif;
  3. PolskiTHEPLAYER
    Offline

    PolskiTHEPLAYER New Member

    Joined:
    Apr 1, 2015
    Posts:
    55
    Minecraft User:
    Flsmers
    Plzz editi for me that code
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It should be if(strtolower($command->getName()) === "cobblex"), not what you put. Please look into other plugins and threads for help, before creating such useless threads. :)
    It has nothing to do with events, did you even look at the code or did you type that out of muscle memory? Adding on to that. if/endif isn't necessary, just use curly braces ({}).
    applqpak and Vaivez66 like this.
  5. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    Yes I understand you its very difficulty
  6. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    i use if/endif in to function Becuse i hate use { } a lot
    applqpak likes this.
  7. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Everyone has their own opinions and favourites. You shall not force him to use if/endif...
    applqpak likes this.

Share This Page

Advertisement