pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.28k stars 1.56k forks source link

New Player Functions ? #488

Closed MisteFr closed 7 years ago

MisteFr commented 7 years ago

This isn't an issue but i don't know where i can contact you. Can you add or can you give me the permission to add new Player functions to get the OS of the player, the game edition and other new things discovered in the LoginPacket like $player->getDeviceOs() ? Thanks.

dktapps commented 7 years ago

If you use the DataPacketReceiveEvent, you can access these fields in the clientData field, which is an associative array of json-decoded data from the packet.

MisteFr commented 7 years ago

Why you won't add them directly as functions ? It's the easiest way..

MisteFr commented 7 years ago

If you want i can do it (add them) @dktapps then you won't loose time

dktapps commented 7 years ago

I'm currently in the middle of networking rewrites on api3/network, and large amounts of Player.php are going to be stripped apart. I haven't decided how to handle authentication and client data yet, but these will be implemented in the future. Thank you for offering to help though.

MisteFr commented 7 years ago

No problem tell me if you need me to do it when it will be time to do it

TheDiamondYT1 commented 7 years ago

Stop spamming this issue incase dylan locks it.

ghost commented 7 years ago

Hello, I just checked the content of the DataPacketReceiveEvent, but there is no field stating wether the client is Android or Windows10, for example, in clientData. Are you sure that info is there? thanks

dktapps commented 7 years ago

@ealgueiroqb9 There's no explicit "Android", "Windows10" if that's what you're expecting. You're looking for the DeviceOS field. Up to you to figure out the values, I don't know them.

dktapps commented 7 years ago

Sample code

        public function onPacketReceived(\pocketmine\event\server\DataPacketReceiveEvent $e){
            if($e->getPacket() instanceof \pocketmine\network\mcpe\protocol\LoginPacket){
                safe_var_dump($e->getPacket()->clientData);
            }
        }

Sample output

array(13) {
  ["ADRole"]=>
  int(2)
  ["ClientRandomId"]=>
  int(4340844811939028985)
  ["CurrentInputMode"]=>
  int(2)
  ["DefaultInputMode"]=>
  int(2)
  ["DeviceModel"]=>
  string(11) "LGE LG-H955"
  ["DeviceOS"]=>
  int(1)
  ["GameVersion"]=>
  string(7) "1.0.6.0"
  ["GuiScale"]=>
  int(-1)
  ["ServerAddress"]=>
  string(17) "192.168.0.4:19132"
  ["SkinData"]=>
  string(21848) base64 mess
  ["SkinId"]=>
  string(13) "Standard_Alex"
  ["TenantId"]=>
  string(0) ""
  ["UIProfile"]=>
  int(1)
}
jasonw4331 commented 7 years ago

I guess 1 is android then...

ghost commented 7 years ago

No, it's actually blank :/

dktapps commented 7 years ago

Then you're doing something wrong.

sylvrs commented 7 years ago

1=> Android 2=> iOS 7=> Windows 10

JackNoordhuis commented 7 years ago

Android => 1 iOS => 2 OSX => 3 FireOS => 4 GearVR => 5 Hololens => 6 Win10 => 7 Win32 => 8 Dedicated => 9 A more complete list (as of 1.0.4) @IrishPacks

sylvrs commented 7 years ago

Win32? How in the... I'm not going to question it.

dktapps commented 7 years ago

@IrishPacks my best guess is EDU edition is w32, since (I assume) it's not a Windows Store app.

sylvrs commented 7 years ago

That'd make sense, same thing with OSX I assume.

MisteFr commented 7 years ago

How MaxOSX ?:0 @JackNoordhuis

robske110 commented 7 years ago

And it's not really called OSX anymore #blameapple. But where did you get that list from anyway? Decompiling(well, if you can call it that) minecraft shouldn't give such descriptive names.

HimbeersaftLP commented 7 years ago

Wait, that really makes no sense, MCPE doesn't run on macOS/OSX whatever you want to call it, does it?!

dktapps commented 7 years ago

@HimbeersaftLP Edu edition does.

HimbeersaftLP commented 7 years ago

@HimbeersaftLP Edu edition does.

Really?! Sorry didn't know that

acepro299 commented 7 years ago

maybe it returns all devices type because it's running in a language of programming...

NiclasOlofsson commented 7 years ago

Thanks @JackNoordhuis

sylvrs commented 7 years ago

maybe it returns all devices type because it's running in a language of programming...

what are you trying to say, because to me it sounds like one of the most idiotic things someone has said regarding programming in a while.

SOF3 commented 7 years ago

Why was this closed?

sero583 commented 7 years ago

@JackNoordhuis are these values still the same? Btw ty

MisteFr commented 7 years ago

@sero583 Here is the updated list of the os constant


const OS_ANDROID = 1;
const OS_IOS = 2;
const OS_OSX = 3;
const OS_FIREOS = 4;
const OS_GEARVR = 5;
const OS_HOLOLENS = 6;
const OS_WIN10 = 7;
const OS_WIN32 = 8;
const OS_DEDICATED = 9;
const OS_ORBIS = 10;
const OS_NX = 11;
Joshiiiii commented 4 years ago

Can anyone send an updated version of these constants? Or are they still the same? @MisteFr