349 Commits

Author SHA1 Message Date
Frago9876543210
e506c7f7de Call BlockTeleportEvent when dragon egg teleports (#2840) 2019-04-14 17:46:22 +01:00
Dylan K. Taylor
42a263a9df GameMode is now an enum 2019-03-31 16:19:36 +01:00
Dylan K. Taylor
ca22223b62 PlayerDeathEvent: fixed constructor signature, closes #2835
can we ban multi-type parameters already? this is tiresome...
2019-03-25 14:55:25 +00:00
Dylan K. Taylor
23071d257e Extract process-related functions from Utils into a separate Process class 2019-03-24 18:57:32 +00:00
Dylan K. Taylor
a753c1342d Clean up Query cache handling, remove useless timeouts
the timeout was entirely useless, because:
- when shorter than 25.6 seconds (512 ticks) it would cause caches to be needlessly destroyed and regenerated
- when longer than 25.6 seconds, just made outdated caches persist for longer, even after the query info was regenerated.

This now uses a mark-dirty model to deal with caches, which means that plugin modifications to the query data will be reflected immediately, regardless of when they are made. Previously, modifying the result of Server->getQueryInformation() would have inconsistent results.
2019-03-24 17:43:02 +00:00
Dylan K. Taylor
2a3e6dcf00 Rename BlockIds -> BlockLegacyIds 2019-03-23 19:46:31 +00:00
Dylan K. Taylor
79ef8e0803 Replace all legacy blockID references with BlockIds:: 2019-03-23 19:44:33 +00:00
Dylan K. Taylor
034bd716c8 Clean up WritableBook hierarchy 2019-03-23 14:36:03 +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
b8d1eb20b0 EntityDeathEvent: add XP amount API, closes #2690 2019-03-21 19:53:14 +00:00
Dylan K. Taylor
b9208eb1fb Merge branch '3.6' 2019-03-09 19:04:37 +00:00
Dylan T
8f1bc5d497
Flatten wall_banner and wall_sign into single blocks (#2798)
This comes with some problems, but the problems are more bearable than the previous code.
2019-03-08 16:37:26 +00:00
Thunder33345
c0bed03a2a Update PlayerRespawnEvent.php (#2797)
removed obsolete comment
2019-03-05 16:28:58 +00:00
Dylan K. Taylor
6c8fa8ae28 More nullable and void typehints 2019-03-02 10:29:11 +00:00
Dylan K. Taylor
5cca4b5e31 Revamp Sign API, flatten API into blocks 2019-02-28 17:10:37 +00:00
Dylan K. Taylor
c26544475e More PHP 7.1 nullables 2019-02-22 12:55:34 +00:00
Dylan K. Taylor
646fea5a4e Effect: Introduce a bunch of static getters, change a bunch of API to use objects
This introduces static getters for every currently-known effect type. At some point in the near future, the magic number constants (which are really network IDs, by the way) will disappear.

Migrating:
- If you used constants (like any sensible person would): for the most part it's just a case of adding a () anywhere you used an Effect constant.
- If you hardcoded magic numbers: ... well, have fun fixing your code, and I reserve the right to say "I told you so" :)

This achieves multiple goals:
1) creating an EffectInstance for application is much less verbose (see diff for examples, especially the Potion class)
2) plugin devs cannot use magic numbers to apply effects anymore and are forced to use type-safe objects. :)

This is a warning shot for plugin devs who use magic numbers. More changes like this are coming in the not-too-distant future.
2019-02-20 12:05:17 +00:00
Dylan K. Taylor
3e58708130 Add some missing @throws annotations 2019-02-04 19:50:43 +00:00
Dylan K. Taylor
78dfcc5f2d Move Effect and EffectInstance to entity\effect namespace 2019-01-28 15:41:07 +00:00
Dylan K. Taylor
d378371cc8 Transition to spl_object_id() 2019-01-26 15:06:38 +00:00
Dylan K. Taylor
e341f3dce2 Level: rename getName() to getDisplayName() 2019-01-17 16:46:56 +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
9c0ebb6350 Minor formatting fixes 2019-01-16 22:14:40 +00:00
Dylan K. Taylor
38afe22b79 Move Event cancellable parts to trait 2019-01-16 22:14:25 +00:00
Dylan K. Taylor
9c53b41851 Added PlayerInfo, Player is no longer accessible during PlayerPreLoginEvent 2019-01-13 19:32:30 +00:00
Dylan K. Taylor
5052b75565 Separate Level management functionality from Server, clean up a bunch of mess 2019-01-12 19:11:05 +00:00
Dylan K. Taylor
adc1069ed2 Merge branch '3.5' 2019-01-04 23:28:44 +00:00
Dylan K. Taylor
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
Dylan K. Taylor
7a4e2371e6 master-specific PHPStan nits 2019-01-04 00:40:09 +00:00
Dylan K. Taylor
e1064a9e36 Merge branch '3.5' 2019-01-04 00:37:48 +00:00
Dylan K. Taylor
d71a543d10 Fixed a bunch of things PHPStan finds unpalatable
close #2614, fix a bunch of docs bugs, fix sendCreativeContents() crash on Human holders, move some inline variable declarations
2019-01-04 00:23:09 +00:00
Dylan K. Taylor
171be946c6 Network: burn some deprecated stuff 2019-01-01 20:53:33 +00:00
Dylan K. Taylor
c6a32ccf2a Merge branch 'release/3.5' 2019-01-01 14:08:20 +00:00
Dylan K. Taylor
f7de6eb59f Network: Deprecate some garbage
Deprecations on a patch version breaks release protocol, but I don't care at this point. Nobody should have been using this shit anyway.
2018-12-31 22:52:39 +00:00
Dylan K. Taylor
3b183447b0 Merge branch 'release/3.5' 2018-12-31 21:52:48 +00:00
Dylan K. Taylor
9ed1b5ca7f Event: More detailed errors for non-cancellable events 2018-12-31 21:29:22 +00:00
Dylan K. Taylor
9f4bb440bd Move server-full/banned/whitelisted controls into PlayerPreLoginEvent
This allows plugins to more easily control the behaviour of server-full, whitelisting and banning. A message can be assigned for each, with a plugin custom reason taking the final priority if set.

This system solves several edge case problems in the Bukkit version by allowing kick reasons to be combined, so that removing one kick reason will roll back the final reason to the next highest, instead of just allowing the player through completely.
Only one message will be shown at point of disconnection, for consistency with the old behaviour.
The message priority is as follows (for all cases, only if set):
- Plugin reason
- Server full
- Whitelist enabled
- Player is banned

This also brings us one step closer to separating Player and NetworkSession.
2018-12-26 13:46:44 +00:00
Dylan K. Taylor
02efa93e3a PlayerPreLoginEvent: New, more elegant way to control authentication requirement
Previously the only way to deal with this was to cancel the PlayerKickEvent generated by lack of authentication. Now, plugins can decide whether auth should be required for a specific player. The default is whatever xbox-auth is set to in server.properties.

cc @Johnmacrocraft
2018-12-23 18:24:33 +00:00
Dylan K. Taylor
f313d06070 Merge branch 'release/3.5' 2018-12-23 14:04:29 +00:00
Dylan K. Taylor
c242d6213a Rewrite documentation for PlayerPreLogin, PlayerLogin and PlayerJoin events
this is some of the most awful documentation I've ever seen. No documentation would have been better.
2018-12-23 14:03:19 +00:00
Dylan T
5d7feaaf21
Remove EventExecutor, event handlers now use closures (#2525)
This cleans up some cargo-cult code poorly copied from Bukkit, which has negative performance effects and also makes internal event handling more complex than necessary.

## API changes
- Removed `EventExecutor` and `MethodEventExecutor`.
- A listener is no longer required for an event handler to be registered. Closure objects can now be used directly provided that they meet the conditions for registration.
- `PluginManager->registerEvent()` signature has changed: the `Listener` and `EventExecutor` parameters have been removed and a `\Closure $handler` has been added in its place.
- `RegisteredListener` now requires a `Closure` parameter instead of `Listener, EventExecutor`.

## Behavioural changes
These changes reduce the execution complexity involved with calling an event handler. Since event calls can happen in hot paths, this may have visible positive effects on performance.

Initial testing reveals a performance improvement of ~15% per event handler call compared to the old method.
2018-11-13 21:04:47 +00:00
Dylan K. Taylor
90482e79bc Merge branch 'release/3.4' 2018-10-21 18:23:54 +01:00
Dylan K. Taylor
6dd2597934 Merge branch 'release/3.3' into release/3.4 2018-10-21 18:17:07 +01:00
Dylan K. Taylor
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
Dylan K. Taylor
cfee0a4e0b Merge branch 'release/3.3' 2018-10-14 11:08:50 +01:00
Dylan K. Taylor
ba68192206 Fixed bad event handlers (whose errors get caught) breaking recursion protection for future event calls
This was observed in a recent crashdump where a plugin triggered a recursion error, but the stack trace did not contain any sign of a recursive event call. I conclude that this must have been caused by previous event handlers triggering errors 50 times in order to make the recursion detection break, because the recursion detection did not decrement the counter in cases where an exception was thrown.
2018-10-14 11:07:16 +01:00
Dylan K. Taylor
acb794e728 Remove garbage from Entity(De)SpawnEvent
These methods:
a) add concrete dependencies
b) are pointless (event->getEntity() instanceof Creature, anyone? an IDE can better understand this as well...)
c) encourage bad code (they don't enforce type contracts the same way an instanceof check does - oh, and why not let's add an is*() for every new mob that gets added ever?
2018-10-12 16:35:51 +01:00
Dylan K. Taylor
97c836f199 Remove nasty network crap from API 2018-10-12 16:31:17 +01:00
Dylan K. Taylor
cc876b0e03 Merge branch 'release/3.3' 2018-10-07 16:36:43 +01:00