105 Commits

Author SHA1 Message Date
Dylan K. Taylor
9df2ca3655 fixup some formatting issues 2019-06-18 14:12:37 +01:00
Dylan K. Taylor
7b049b6db1 NetworkSession: use a better check for timeout 2019-06-17 17:30:42 +01:00
Dylan K. Taylor
92e81e3298 Player: move some respawn net sync logic to NetworkSession 2019-06-17 16:27:04 +01:00
Dylan K. Taylor
b344427a30 Added a hack to allow dropping garbage serverbound packets sent by a buggy client 2019-06-17 14:20:29 +01:00
Dylan K. Taylor
93b83b4189 Player: Window system now only allows 1 window at a time 2019-06-15 18:19:09 +01:00
Dylan K. Taylor
8afea36919 Clean up some internal commands protocol handling 2019-06-12 19:35:14 +01:00
Dylan K. Taylor
1c69226187 NetworkSession: add an extra debug 2019-06-11 09:55:32 +01:00
Dylan K. Taylor
8e6f21afad clean up gamemode net sync 2019-06-10 19:58:14 +01:00
Dylan K. Taylor
f0d56f25b6 Moved creative inventory sync to NetworkSession 2019-06-10 19:54:24 +01:00
Dylan K. Taylor
dd45753fa9 NetworkSession: add some more debug 2019-06-10 19:47:02 +01:00
Dylan K. Taylor
3ac0c98199 De-spaghettify spawn notification handling 2019-06-10 19:31:54 +01:00
Dylan K. Taylor
32c832c87e Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/Server.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php
#	src/pocketmine/network/mcpe/RakLibInterface.php
#	src/pocketmine/network/query/QueryHandler.php
#	src/pocketmine/utils/Utils.php
2019-06-06 15:04:05 +01:00
Dylan K. Taylor
61afc7b62c NetworkSession: report the zlib error that happened 2019-06-06 14:16:04 +01:00
Dylan K. Taylor
9f0a184a5d Packet: Remove mayHaveUnreadBytes()
this was an old hack to prevent debug spam being emitted when we halted decoding of logins over breaking protocol changes. Since then, we've gone back to trying to decode the packet regardless, so this property is useless.
2019-06-05 15:37:35 +01:00
Dylan K. Taylor
287c8c2dd4 Added static create() functions for many packets
There are a few motivations here:
1) Less boilerplate code (this can be written inline)
2) It's possible to provide multiple constructors for different packet variations to reduce the chance of errors.
3) It makes things catch fire on updates in ways that static analysers can understand.
2019-06-05 15:00:08 +01:00
Dylan K. Taylor
cda565ba8c Merge branch 'stable'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/inventory/ArmorInventory.php
2019-06-04 18:19:47 +01:00
Dylan K. Taylor
6f29fe063f move PlayerListPacket sending responsibility to NetworkSession 2019-06-04 18:02:36 +01:00
Dylan K. Taylor
33d1203bfd Player: move sendAllInventories() to network layer 2019-05-26 15:58:03 +01:00
Dylan K. Taylor
85718e2750 Clean up a bunch of garbage in Furnace 2019-05-26 15:43:46 +01:00
Dylan K. Taylor
3ea8da2dd3 Use EnumTrait->equals() instead of direct comparison
It's not guaranteed that objects provided are the same as those in the enum registry, so they can't be directly compared.

Implementing comparison with === would require some kind of __equals() implementation or an extension to hook into such functionality.
2019-05-24 17:21:44 +01:00
Dylan K. Taylor
bca0833035 Clean up handling of armour sync 2019-05-19 16:56:10 +01:00
Dylan K. Taylor
67affcea32 move more packet logic to net session
it seems like net session is turning into a giant dumping ground for sending API ... this needs to be cleaned up somehow.
2019-05-19 15:48:01 +01:00
Dylan K. Taylor
c3c2dd3988 Rename SimpleSessionHandler -> InGameSessionHandler
the "simple" name comes from the early days of this refactor before I started splitting everything up into their own units. This handler is now in good enough condition to have a proper name.
2019-05-18 19:13:41 +01:00
Dylan K. Taylor
c1a483a36d move entity spawning logic back to Player 2019-05-07 18:35:04 +01:00
Dylan K. Taylor
d7a7ab5102 Move Entity despawn logic back to Player
this is not network-session specific, and different implementations will need to do this.
2019-05-07 18:01:23 +01:00
Dylan T
3cd6e12e71
Renaming "Level" -> "World" (#2907)
This has been a pain point for a long time due to the misleading nature of the name "level". It's also confusing when trying to do things like getting the XP level of the player or such, and also does not translate well to other languages.

This transition was already executed on the UI some time ago (language strings) and now it's time for the same change to occur on the API.

This will burn a lot of plugins, but they'll acclimatize. Despite the scary size of this PR, there isn't actually so many changes to make. Most of this came from renaming `Position->getLevel()` to `Position->getWorld()`, or cosmetic changes like changing variable names or doc comments.
2019-05-07 14:47:28 +01:00
Dylan K. Taylor
427e334426 rename PacketStream to PacketBatch 2019-05-06 19:58:02 +01:00
Dylan K. Taylor
c2771eba88 use the appropriate API for decoding packet batches 2019-05-06 17:46:17 +01:00
Dylan K. Taylor
82974e0271 NullSessionHandler: possibly premature optimization 2019-05-06 17:28:56 +01:00
Dylan K. Taylor
685481b172 NetworkSession: improve GC performance without crashing everything
this is necessary because some handlers have circular references to the session, which causes GC lag collecting them. This change allows them to be collected immediately without nuking internal state.
2019-05-06 16:43:05 +01:00
Dylan K. Taylor
5250a432d1 NetworkSession: add a dedicated PrefixedLogger, clean up some boilerplate code 2019-05-06 16:32:34 +01:00
Dylan K. Taylor
793f93afdb NetworkSession: sync with latest code generation changes 2019-04-25 14:49:20 +01:00
Dylan K. Taylor
fa70127241 1.11.0 protocol changes 2019-04-24 19:54:16 +01:00
Dylan K. Taylor
0dac982f16 Merge branch 'stable' 2019-04-21 16:56:53 +01:00
Dylan K. Taylor
939dfd9269 First look at separating chunk sending from Level 2019-04-17 19:33:37 +01:00
Dylan K. Taylor
0e3e984db9 Player: Disconnects no longer nuke player internals, (mostly) fixes #1239
there are some problems that haven't been accounted for yet, but this fixes all the direct crashes.
2019-04-03 17:44:34 +01:00
Dylan K. Taylor
e5756dbf0b Move a whole bunch of packet crap to NetworkSession 2019-04-02 18:31:16 +01:00
Dylan K. Taylor
9ec62643d5 Player construction now happens when we're ready to create the player entity
this fixes a wide range of bugs with the initial spawn sequence, and allows to simplify a whole lot of player setup logic.
2019-03-23 10:13:14 +00:00
Dylan K. Taylor
433dab078b DataPacket events now use network sessions instead of players 2019-03-23 09:52:03 +00:00
Dylan K. Taylor
cce99b07af 1.10.0 updates 2019-03-20 19:17:41 +00:00
Dylan K. Taylor
ebfe9caca3 Move too-early-send check to NetworkSession 2019-03-14 14:45:30 +00:00
Dylan K. Taylor
26a5d97499 Some cleanup to player net session handling for connect/disconnect 2019-03-14 14:32:43 +00:00
Dylan K. Taylor
f680a239f7 NetworkSession: some exception handling cleanup 2019-02-28 16:36:03 +00:00
Dylan K. Taylor
19f0d7f336 NetworkSession: Don't apply handlers to a disconnected session
closes #2756
2019-02-15 10:11:31 +00:00
Dylan K. Taylor
b8703d5dff Protocol changes for 1.9.0 2019-02-07 21:56:42 +00:00
Dylan K. Taylor
467caf347d NetworkSession: Consistently don't use 0x prefix 2019-01-20 11:06:47 +00:00
Dylan K. Taylor
5d8568b1a4 Add NetworkSession->getDisplayName(), clean up ip/port ad-hoc usages 2019-01-20 11:05:12 +00:00
Dylan K. Taylor
76f1ee1827 Add restrictions on packet send directions with interfaces
This prevents plugins sending wrong packets at the compiler level (or would, if we had a compiler). It's more robust than a getter for client/server and throwing an exception since a static analysis tool can detect faults created by sending wrong packets from the server. This is also used to deny service to dodgy clients which send wrong packets to the server to attack it.
2019-01-17 12:51:24 +00:00
Dylan K. Taylor
b82e00ffdf Extract a Packet interface from DataPacket
this is in preparation for clientbound/serverbound packet separation. I did this already on another branch, but the changeset was dependent on a massive refactor to split apart packets and binarystream which i'm still not fully happy with.
2019-01-17 12:21:56 +00:00
Dylan K. Taylor
23269da1a6 Fixed the disaster of packet receive error handling 2019-01-16 19:53:48 +00:00