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

Change [Server] to something else

Comments in 'Plugin Development' started by Andrey Nazarchuk, Jun 25, 2014.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Simple test to judge the fact (don't follow @Intyre's "shoghi is always right!").
    Run this code to spawn a dummy player when the player joins.

    PHP:
    public function init(){
    $this->api->addHandler("player.spawn", array($this"onJoin"));
    }
    public function 
    onJoin($data$e){
    $this->api->schedule(100, array($this"spawnDummy"), $data);
    }
    public function 
    spawnDummy($data){
    $pk = new AddPlayerPacket;
    $pk->eid 0// this EID is reserved; I think I remember that @shoghicp said this would be the EID sent to a client about the client himself or something like this; just a test, never mind.
    $pk->clientID 0// idk why they set it to 0 not the real clientID. To avoid hacking? https://github.com/PocketMine/PocketMine-MP/blob/c09bc259fcc472df1a592ad471a9988ec6f4c3b5/src/world/Entity.php#L666
    $pk->username "Our dummy";
    $pk->$data->entity->x;
    $pk->$data->entity->y;
    $pk->$data->entity->z;
    $pk->yaw 0;
    $pk->pitch 0;
    $pk->unknown1 0;
    $pk->unknown2 0;
    $pk->metadata $data->entity->getMetadata(); // this will set it such that if the joining player is crouching atm, the dummy will crouch too; same for fire and other things
    $data->dataPacket($pk);
    }
    This code should spawn a dummy player in front of the newly joined player, whilst doing nothing else. (It is impossible for the server to send another message, because the only called functions are $Entity->getMetadata() and $Player->dataPacket(), where none of either would send another message packet. If a message called <server> Our dummy joined the game appears on your client, you will be proved wrong, @jython234.

    However, it can be proved that @player left the game is server-side sent.


    And finally, I would want to point out that basically all API-related PocketMine-MP activities that affects the client can be blocked or modified. If you register a handler at DataPacketSendEvent, you can block all message packets (e.g. block a message packet where preg_match("#<server> [^ ]{1,} joined the game\$#", $packet->message).
    Andrey Nazarchuk likes this.
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I think there is a function in the PlayerJoinEvent like setJoinMessage() in the New API. For the Old API PEMapModder is right, they are fully client side.
    Andrey Nazarchuk and PEMapModder like this.
  3. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    I said it was client-side first. :(
    Falk and SpiderPig like this.
  4. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Wait, if you add a player, no message pops up right? I'm away from my computer can't test.
    Andrey Nazarchuk likes this.
  5. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Umm... so is it possible?
    And if so, How???
    :D:D:D:D:D:D
  6. PluginMastered
    Offline

    PluginMastered Active Member

    Joined:
    Mar 1, 2014
    Posts:
    161
    Minecraft User:
    Flexa33
    I don't really know what they are say either :D
    Andrey Nazarchuk likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The answer is that messages pop up, which proves you are wrong.
    Andrey Nazarchuk likes this.
  8. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    So apparently I started an argument, sorry :)
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Don't worry, you encouraged us to carry out a proof of theory, which is affirmative.
  10. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Remember that you are using the API, that's not vanilla :) To truly test, we need to write our own server ( *cough BlockServer).
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    strtoupper ( " I am not using the API! I am sending raw packets! " );

    When I send an AddPlayerPacket, it is directly put into the socket as a packet. Unless some plugins or what handle the DataPacketSendEvent, no extra packets will be sent.
  12. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    You may not cancel the PlayerJoinEvent! Just use
    PHP:
    $event->setJoinMessage($event->getPlayer()->getName()." has joined FreeBuild!")
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You can cancel it, but it will affect nothing because cancelling an event only affects when there are higher-priority handlers that ignore cancelled and that the event implements Cancellable, which is not the case for PlayerJoinEvent. In the other hand, PocketMine does not check if that event is cancelled.
    In fact, just blame @shoghicp for not making Cancellable a trait/class or implement it in every event class.

    As for the old API, returning false would only avoid it going on the next handlers. If you want to avoid letting the player join, return false in "player.connect" event. And again, it is impossible to get rid of that message for vanilla clients unless you hack in and modify the apps in those clients.

    And also, look at the above example. It doesn't use the PocketMine API. It is just a function that puts a packet into the socket communicating with the client. You are a server developer, and you must know that there is not a single packet that adds a player entity and sends a message that is customizable by the server together. Otherwise, look at the official documentation (wherever it is and whether it exists :D) for AddPlayerPacket.
  14. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    Oh, I thought it would prevent the user from connecting to the server.
    And you can set name tags and join messages in 0.9.0.
  15. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    Ok @PEMapModder, you win this one. But still, You are sending the packet through the API, and not through the actuall socket. Also, it is server side, compile and run Intrye's PocketServer, when you join it says "Hello World!".
  16. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    That's the MOTD............
  17. jython234
    Offline

    jython234 Notable Member Plugin Developer

    Joined:
    Nov 4, 2013
    Posts:
    324
    Plugins:
    1
    Minecraft User:
    jython234
    But no "@player joined the game", this proves it's server side!
  18. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Do the players ever get spawned??
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Look at the code for dataPacket(). I believe @shoghicp doesn't want to make his own code doing things plugin do (handle an event) in the new event system.
  20. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Except DataPacketSendEvent, there are no other things that could modify it.

Share This Page

Advertisement