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

[General Improvement] Make chat override plugins inter-reacting

Comments in 'Plugin Development' started by PEMapModder, Mar 30, 2014.

?

Will you make your plugins handle chat by reference?

  1. Yes, the PocketMine community needs improvement.

    100.0%
  2. No, the major API rewrite is coming soon and I'm too lazy to make anything.

    0 vote(s)
    0.0%
  3. No, I won't update because I want to monopolize the plugins downloads.

    0 vote(s)
    0.0%
  4. No, I don't know what is passing by reference.

    0 vote(s)
    0.0%
  5. No, because I don't even make a plugin that does this!

    0 vote(s)
    0.0%
  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It seems that these days many plugins like the idea of overriding the chat with something like world name, ranks, kills, or etc.

    In the player.chat event, $data["message"] is passed with reference, I.e. with the ampersand sign "&". If, in your handler of the event, add the sign at the parameter, like this:
    PHP:
     public function chatEventHandler(&$data$event){
      
    $speaker $data["player"];
      
    $msg =& $data["message"];
    }
    Then, if you change $msg directly by storing data into variables (e.g.
    PHP:
    $msg "[$world]" $msg;
    ) or assignments (e.g.
    PHP:
    $msg .= "[$rank]";
    ), if you don't return false, the changed message will be broadcasted instead.

    Presently, many plugins, including my plugin NumericRanks, override chat by broadcasting new message and returning false, but it has an adverse effect of racing priorities.

    I shall update my plugin when I have time. Hope you will too.

    P.S. please vote in the poll!
    Last edited: Mar 30, 2014
    xktiverz and iJoshuaHD like this.
  2. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
  3. xktiverz
    Offline

    xktiverz Active Member

    Joined:
    Dec 20, 2013
    Posts:
    61
    Minecraft User:
    64FF00
    THANK YOU VERY MUCH, THIS IS AWESOME! xD

    (IDK why I didn't think about those references in PHP...)

Share This Page

Advertisement