Commit Graph

20 Commits

Author SHA1 Message Date
2559f5ec2b Moved Player-related classes to pocketmine\player namespace 2019-06-18 18:51:36 +01:00
858f440bcf TimingsHandler: return the result of $closure() for easier usage
this isn't type safe, but it doesn't matter a whole lot, and there's nothing we can do about it without generics.
2019-06-11 15:04:30 +01:00
de6053de11 TimingsHandler: use a try/finally block in time() 2019-06-11 14:54:54 +01:00
f349a58f2b TimingsHandler: added time(Closure) function
I find myself often using try/finally blocks to avoid accidentally forgetting to stop a timer. This allows a cleaner more concise way of doing it.
2019-06-11 14:46:19 +01:00
b329cac3d2 Move pocketmine\tile\* to pocketmine\block\tile\* 2019-05-25 19:23:43 +01:00
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
6c8fa8ae28 More nullable and void typehints 2019-03-02 10:29:11 +00:00
c26544475e More PHP 7.1 nullables 2019-02-22 12:55:34 +00:00
d378371cc8 Transition to spl_object_id() 2019-01-26 15:06:38 +00:00
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
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
5052b75565 Separate Level management functionality from Server, clean up a bunch of mess 2019-01-12 19:11:05 +00:00
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
488c03c200 Make timings for player network more detailed 2018-07-31 16:34:15 +01:00
695793795e PluginManager: Remove dead $pluginParentTimer left over from 9e4d88a852 2018-07-26 10:25:01 +01:00
05af87e1d4 Strip empty lines at the end of classes 2018-06-11 13:19:23 +01:00
51f43fb375 Removed global ServerScheduler - plugins now get their own isolated schedulers
This change breaks pretty much all API pertaining to synchronous task scheduling.

Significant changes:
- Server->getScheduler() has been removed
- Plugin->getScheduler() has been added - every plugin now has its own scheduler
- Because schedulers are now per-plugin, it is now unnecessary for PluginTask to exist because stopping plugin tasks on plugin disable is as simple as destroying the plugin's scheduler. Therefore PluginTask has now been removed and it is expected for things to now use the base Task class instead.

For the most part, plugins will simply need to change Plugin->getServer()->getScheduler()->... to Plugin->getScheduler()->...
Another highlight is that plugin tasks now no longer have global IDs - they are unique to each scheduler.
2018-05-30 14:11:11 +01:00
2eaba7c936 Timings: added timings for Player->checkNearEntities() 2018-05-28 16:27:03 +01:00
73e09392b6 Timings: Clean up some terrible code, move namespaces 2018-03-19 19:05:51 +00:00