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

Change a function of vanilla command

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

  1. FresherGAMING

    FresherGAMING Spider Jockey

    Messages:
    42
    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:
    137
    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 Spider Jockey

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

    minijaham Skeleton

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

    FresherGAMING Spider Jockey

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

    FresherGAMING Spider Jockey

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

    minijaham Skeleton

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

    FresherGAMING Spider Jockey

    Messages:
    42
    GitHub:
    FresherGAMING
    Ok
     
  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.