Change a function of vanilla command

Discussion in 'Plugin Help' started by FresherGAMING, Aug 24, 2021.

  1. FresherGAMING

    FresherGAMING Silverfish

    Messages:
    18
    GitHub:
    FresherGAMING
    Example :
    When type /gamemode, It will not show a usage but it will show an ui or anything else
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    127
    You can use
    PHP:
    public function onCommandProcess(PlayerCommandPreprocessEvent $event){

    }
    check if it's the command you want to change and cancel the event and perform the function you want
     
  3. FresherGAMING

    FresherGAMING Silverfish

    Messages:
    18
    GitHub:
    FresherGAMING
    Ok, I'll try it
     
  4. minijaham

    minijaham Zombie Pigman

    Messages:
    737
    GitHub:
    minijaham
    Or instead, you can register your own command to override the already existing command!
     
    Agent likes this.
  5. FresherGAMING

    FresherGAMING Silverfish

    Messages:
    18
    GitHub:
    FresherGAMING
    Like this ?
    PHP:
           public function onCommandProcess(PlayerCommandPreprocessEvent $event){
               if(
    $event->getCommand()->getName() == "gamemode"){
                  
    $event->setCancelled(true);
               }
           }
     
  6. FresherGAMING

    FresherGAMING Silverfish

    Messages:
    18
    GitHub:
    FresherGAMING
    I've register command but It still show usage
     
  7. minijaham

    minijaham Zombie Pigman

    Messages:
    737
    GitHub:
    minijaham
    You must unregister the command first, iirc.
     
    Agent likes this.
  8. FresherGAMING

    FresherGAMING Silverfish

    Messages:
    18
    GitHub:
    FresherGAMING
    Ok
     

Share This Page

  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.