Commit Graph

1209 Commits

Author SHA1 Message Date
653fa1213e Added an event for handling duplicate logins (#2430) 2018-09-12 11:23:48 +01:00
ebc1524f9a Merge remote-tracking branch 'origin/release/3.3' 2018-09-12 10:39:49 +01:00
a9fc67663c Strip anti flight out of the core (#2428)
This may later be developed into a plugin if it is a desired feature, but having it in the core is unnecessary and a pain in the ass.
2018-09-12 10:06:57 +01:00
034472bfe7 Merge branch 'release/3.3' 2018-09-04 11:58:19 +01:00
e621cde8f1 Player: Tighten validity checks for addWindow() (#2419)
- Don't allow the same window ID to be used when another window is already using it
- Detect window ID collisions when selecting IDs for regular containers (should never happen, but anything is possible)
2018-09-01 15:25:46 +01:00
888dba704b Merge branch 'mcpe-1.6' into release/3.2 2018-08-29 16:23:53 +01:00
d6376a236d Player: assign allowFlight directly instead of using setter
fixes #2397

This was changed by a4939b6bf1 without apparent reason. It causes AdventureSettings to be sent too early.
2018-08-22 19:20:21 +01:00
9ca38ba868 Protocol changes for 1.6.0.8 + resource packs "fix" 2018-08-21 17:36:55 +01:00
986077e03c Protocol changes for 1.6.0.1 2018-08-21 17:14:53 +01:00
1177a381c8 Merge branch 'release/3.2' 2018-08-19 11:45:16 +01:00
0dc4bd36e1 Form: change handleResponse() return type to void
this returning is counter intuitive and doesn't make any sense without the queuing mechanism. Instead it's simpler to just use Player->sendForm().
2018-08-19 11:44:59 +01:00
06d7ee283d Player: Don't use iusername in cases where it's useless
these calls all do strtolower() anyway, so having iusername here just makes it confusing.
2018-08-18 13:42:00 +01:00
a306421737 Entity: remove lastX lastY lastZ lastYaw lastPitch, replace with lastLocation object field 2018-08-18 13:38:19 +01:00
d32b9ec5dc Player: remove useless write to NBT
the parent constructor doesn't care about this tag, and the tag is discarded afterwards.
2018-08-15 14:56:02 +01:00
b3d8d10bec Player: move flight toggling to its own method 2018-08-14 19:21:13 +01:00
d8198d8130 Fixed setItemInHand() regressions when placing or breaking blocks
this was causing any items set into the hand during these events _at all_ to get overwritten, rather than just tools. That's a bit of a problem for buckets because buckets rely on a bad hack to handle the modified items.

This doesn't fix the tools bug, but that's a job for another time.
2018-08-14 16:44:14 +01:00
cef1fe9524 Merge branch 'release/3.2' 2018-08-14 16:11:42 +01:00
df8e10cad9 Forms API, part 1: add Player->sendForm() and Form interface
There's no implementation here yet, but that can come later. This lays the ground for allowing plugins to have an integrated method to send forms, as well as a solution to the ID conflict problem.

A built in implementation should not be a concretion and it should be able to be swapped for third party implementations. This enables the possiblity to do so.
2018-08-14 16:06:55 +01:00
0273e2484e Kill entity runtime NBT (#2361) 2018-08-14 13:33:02 +01:00
15bac8c58a Implement send buffering and queuing for network sessions (#2358)
Async compression and broadcasts are now reliable and don't have race condition bugs.
This features improved performance and significantly reduced bandwidth wastage.

Reduce Level broadcast latency by ticking network after levels. This ensures that session buffers get flushed as soon as possible after level tick, if level broadcasts were done.
2018-08-13 14:37:18 +01:00
ec9ef891ee Player: clean up some runtime usages of NBT
the goal is to get rid of this completely, but that's slightly complicated by the mess that is player creation right now.
2018-08-07 18:27:22 +01:00
16b789a528 Player: remove useless checks from save()
this should never be called for a player with an empty username (because data isn't saved unless the player was spawned) and the instanceof is laughable.
2018-08-07 17:37:55 +01:00
55ac1c80c9 Player: replace redundant usage of Server->broadcast() 2018-08-07 17:33:57 +01:00
ff6d590d0c PlayerInventory: Send updates to viewers automatically on setItemInHand() 2018-08-05 19:31:21 +01:00
c90e3e351d PlayerBlockPickEvent: remove setResultItem()
the same behaviour can be achieved by cancelling the event and setting the held item manually. Allowing this to be changed increases the complexity of dealing with survival block picking.
2018-08-05 19:07:23 +01:00
6fcb221453 Remove useless crap from ChunkLoader interface
these methods are not used anywhere and are unnecessary extra baggage for any implementation.
2018-08-05 18:38:51 +01:00
90f80782d4 Player: remove useless return value from dropItem() 2018-08-05 12:55:12 +01:00
ea9415961b Player: remove useless check from dropItem()
the transaction system will deal with this now, and if a plugin wants to make a player drop a null item, they are free to do so.
2018-08-05 12:53:31 +01:00
5df56a1bac Clean up some AnimatePacket boilerplate code 2018-08-05 12:39:36 +01:00
d81388f62c Merge branch 'release/3.2' 2018-08-05 12:21:06 +01:00
ca541032ae Move Player death message derivation to PlayerDeathEvent static method
This now no longer requires a Player to operate, only a player name.
2018-08-05 12:19:16 +01:00
a5383b4a82 Use SetLocalPlayerAsInitializedPacket for spawning, fixed a bunch of bugs
this should fix forms not working during PlayerJoinEvent, and also removes the spurious PlayerItemHeldEvent firing on spawn bug.

The player MUST now send this packet. Bots take note.
2018-08-05 10:45:41 +01:00
25660843c5 Player: Obliterate InventoryTransactionPacket handler, add some new methods 2018-08-04 20:01:32 +01:00
af6b279e54 Player: Ensure we always get flagged as closed when parent constructor was never called
This was causing unexpected bugs when players got disconnected during the login sequence.
2018-08-01 17:28:30 +01:00
809b33033e Player: Use connected status instead of Entity->closed flag 2018-08-01 17:27:32 +01:00
47cf6e4833 Fixed not being able to disable encryption 2018-07-31 18:51:57 +01:00
2bf6764112 Implemented network encryption (#2343)
For those who fuss about performance, you can disable the `network.enable-encryption` option to use sessions without encryption.
2018-07-31 15:54:18 +01:00
bdd42d6a78 Added NetworkSession->sendEncoded(), clean up some code 2018-07-27 18:39:14 +01:00
7541a6070f Player: clean up handling of authentication 2018-07-27 18:04:13 +01:00
e6cbdd090e Merge branch 'release/3.2' 2018-07-26 10:25:25 +01:00
9a2845640b Permissions management cleanup (#2332)
* Added a new PermissionManager, remove ridiculous cyclic dependencies of Permissions on Server

Aside from all the other ridiculous design problems with the permission system, the biggest problems are its API. This is, once again, a result of poor API design copied from Bukkit.

This pull request removes all permission-related functionality from `PluginManager` and moves it to the `pocketmine\permission\PermissionManager` class.

As can be observed from the removed code in the diff, the permissions system was previously entirely dependent on the Server, because it needed to get the PluginManager for registering permissions. This is utterly ridiculous. This refactor isolates _most_ permission-related functionality within the `permission` namespace.

As mentioned above, this stupid API is a direct result of copying from Bukkit. If you look at the API documentation for Bukkit for `PluginManager` you will see that the methods I'm deprecating here are also in there.

## Changes
- Added a new `PermissionManager` class. This can be accessed via its singleton `getInstance()` static method.
- Deprecated the following `PluginManager` methods - these will be removed no later than 4.0.0:
  - `getPermission()`
  - `addPermission()`
  - `removePermission()`
  - `getDefaultPermissions()`
  - `recalculatePermissionDefaults()`
  - `subscribeToPermission()`
  - `unsubscribeFromPermission()`
  - `getPermissionSubscriptions()`
  - `subscribeToDefaultPerms()`
  - `unsubscribeFromDefaultPerms()`
  - `getDefaultPermSubscriptions()`
  - `getPermissions()`
2018-07-26 10:21:41 +01:00
fe1df70923 Player: be less horrible and leave a deprecated proxy for dataPacket() 2018-07-22 12:20:13 +01:00
c1843ac2d4 Player: remove dataPacket() and directDataPacket()
I considered renaming sendDataPacket() to dataPacket() to reduce the BC breaks, but the parameter set has changed, which might cause astonishing behaviour, so it's better to break it in a loud way. Also, this has a clearer name.
2018-07-22 12:04:53 +01:00
85105ed066 Inseparable set of network changes - these all need each other to work
- Separated player handling and creation from network interfaces
- Rewire disconnects to make them not be recursive
- Batching now uses sessions instead of players
- Fixed DisconnectPacket getting sent to players who disconnect of their own accord
2018-07-21 20:03:05 +01:00
ca1a0c8643 Move responsibility for ping handling to NetworkSession 2018-07-21 16:33:12 +01:00
30c044f028 Unwrap more code from packet handlers 2018-07-20 18:48:46 +01:00
015ee90571 Split PlayerActionPacket handling into two classes, death is now a session state 2018-07-20 18:11:29 +01:00
f626b9e8a0 Initial mass migration to session handlers
This introduces several new session handlers, splitting up session handling into several new states:

- Login: Only allows handling the LoginPacket. This is the only time LoginPacket can be sent, and it'll be discarded when sent at any other time.
- Resource packs: Handles only the resource packs sequence (downloading packs and such). This is the only time ResourcePackClientResponse and ResourcePackChunkRequest will be handled.
- Pre-spawn: Only chunk radius requests are accepted during this state.

SimpleNetworkHandler handles all the "rest" of the logic that hasn't yet been separated out into their own dedicated handlers. There's also a NullNetworkHandler which discards all packets while it's active.

This solves a large number of issues with the security of the login sequence. It solves a range of possible DoS attacks and crashes, while also allowing great code simplification and cleanup.
2018-07-20 17:09:04 +01:00
97a1483f75 Player: remove useless crap from "constructor"
1. this isn't really the player constructor
2. this shit isn't needed until we start using the player as an actual player
2018-07-20 15:38:53 +01:00
a4939b6bf1 Player: re-structure a whole bunch of construction mess
This consolidates the Player entity construction and makes it more organized and consistent. There is of course a lot more work to do apart from this on player construction.
2018-07-20 15:34:47 +01:00