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

Help me with a code

Comments in 'Plugin Development' started by KingDeadKnight, Mar 16, 2016.

  1. KingDeadKnight
    Offline

    KingDeadKnight New Member

    Joined:
    Oct 18, 2015
    Posts:
    33
    Minecraft User:
    KingDeadKnight
    Hi, i'm a beginner in this domain.
    I'm making a little plugin to train me but i don't know how to do to make a list of rules for example with pages.
    Now I have this:
    PHP:
    public function onCommand(CommandSender $senderCommand $cmd$label, array $args){
           if(
    $cmd->getName() == "regle"){
          
    $this->args $this->getConfig()->get("regles");
         
    $sender->sendMessage($this->translateColors("&"$this->args));
         }
         return 
    true;
       }
    Someone can help me?
    Thank a lot
  2. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    PHP:
    public function onCommand(CommandSender $senderCommand $command$label, array $args) {
    switch (
    strtolower($command->getName())) {
    case 
    "MAINCOMMAND":
    if (
    $sender instanceof Player) {
    if (!(isset(
    $args[0]))) {
    if (
    $sender->hasPermissions("PERMISSION.PERMISSION")) {
    $sender->sendMessage("YOUR MESSAGE");
    return 
    true;
    } else {
    $sender->sendMessage("You don't have permission");
    return 
    true;
    }
    }
    $arg array_shift($args);
    switch (
    $arg) {
    case 
    "2":
    if (
    $sender->hasPermission("PERMISSION.PERMISSION")) {
    $sender->sendMessage("This is the command '/maincommand 2'");
    return 
    true;
    } else {
    $sender->sendMessage("NO PERMISSION");
    }
    return 
    true;
    break;
    case 
    "3":
    if (
    $sender->hasPermission("PERMISSION.PERMISSION"))
    {
    $sender->sendMessage("This is '/maincommand 3'");
    return 
    true;
    } else {
    $sender->sendMessage("NO PERMISSION");
    }
    return 
    true;
    break;
    }
    }
    }
    }
    Hope it helps.
    Last edited: Mar 16, 2016
    ImagicalGamer likes this.
  3. KingDeadKnight
    Offline

    KingDeadKnight New Member

    Joined:
    Oct 18, 2015
    Posts:
    33
    Minecraft User:
    KingDeadKnight
    I'll try it in 1 or 2 hours, when I come back home
  4. KingDeadKnight
    Offline

    KingDeadKnight New Member

    Joined:
    Oct 18, 2015
    Posts:
    33
    Minecraft User:
    KingDeadKnight
    It doesn't work for me :/

Share This Page

Advertisement