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

Cannot use this command here, plugin

Comments in 'Plugin Development' started by Jon, Jul 23, 2014.

  1. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    i need a code that when a player is in x y z cannot use a certain of commands...any strings?
    new API pls
    LDX likes this.
  2. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    Any ideas?
  3. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Which command ? A command of your plugin or a default command ?
  4. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    PHP:
    public function onEvent(PlayerCommandProcess  $event){
    $player $event->getPlayer();
    if(
    $player->getX === $x and $player->getY === $y and $player->getZ === $z){
    $event->setCancelled(true);
    }
    Last edited: Jul 24, 2014
    Guillaume351 likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. It is PlayerCommandPreprocessEvent.
    2. onCommand() is a member function in class PluginBase, so you can't name it onCommand() in the main class.
    3. Chat messages with or without slashes are always sent here.
    Tuff likes this.
  6. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    1.ok
    2.ok
    3.i don't know what you mean
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PlayerCommandPreprocessEvent is not necessarily a command issue. It can just be a normal chat line.
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    then why did they make that event?
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Because PlayerCommandPreprocessEvent is an event to fully control when a player sends a chat message. In the protocol, command or not, it is sent as a chat message. Therefore, this may serve as a controller so you can detect a message whether it begins with a slash.
    swagboy47 likes this.
  10. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    okay , got it
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    For example, when you want to allow players to input via password.
  12. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    So this can work or not?
    If not other strings?
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Add line if(substr($event->getMessage(), 0, 1) !== "/") return;
  14. Jon
    Offline

    Jon Active Member Plugin Developer

    Joined:
    Sep 1, 2013
    Posts:
    201
    Plugins:
    3
    Minecraft User:
    Heromine14
    thx

Share This Page

Advertisement