Commit Graph

117 Commits

Author SHA1 Message Date
d488c25a1a Rename AutoUpdater -> UpdateChecker 2021-08-20 19:54:08 +01:00
a012e7ccc0 VersionInfo: make static methods more constant-like
if we could have class constants declared at runtime, these would be constant.
2021-08-16 16:37:36 +01:00
60ac76a3bc Remove more usages of hardcoded translation keys 2021-08-15 19:22:40 +01:00
789a669395 Rename TranslationContainer -> Translatable 2021-08-15 16:17:46 +01:00
804d02b086 TranslationContainer: added prefix(), postfix() and format() 2021-08-14 16:08:22 +01:00
2ca7fc7254 Server: add native return types to getters that were skipped first time 2021-08-12 23:56:43 +01:00
0e0bbdfb70 Use typed properties in Server 2021-08-12 23:52:39 +01:00
b4c0ddd155 Use native union types for TranslationContainer|string 2021-08-10 15:17:26 +01:00
2293bd948d Added KnownTranslationFactory and use it in as many places as possible
this makes translation usage much more statically analysable.
The only places this isn't used are:
- places that prefix translations with colours (those are still a problem)
- places where server/client translations don't match (e.g. gameMode.changed accepts different parameters in vanilla than in PM)
2021-08-10 14:50:40 +01:00
676bacbee1 Improve the flexibility of WorldProvider registration
WorldProviders now have the following requirements removed:
- __construct() is no longer required to have a specific signature
- static isValid() no longer needs to be implemented (you will still need it for registering, but it can be declared anywhere now)
- static generate() no longer needs to be implemented

This paves the way for more interesting types of world providers that use something other than local disk to store chunks (e.g. a mysql database).

WorldProviderManager no longer accepts class-string<WorldProvider>. Instead, WorldProviderManagerEntry is required, with 2 or 3 callbacks:
- ReadOnlyWorldProviderManager must provide a callback for isValid, and a callback for fromPath
- WritableWorldProviderManagerEntry must provide the same, and also a generate() callback

In practice, this requires zero changes to the WorldProviders themselves, since a WorldProviderManagerEntry can be created like this:
`new WritableWorldProviderManagerEntry(\Closure::fromCallable([LevelDB::class, 'isValid']), fn(string ) => new LevelDB(), \Closure::fromCallable([LevelDB::class, 'generate']))`

This provides identical functionality to before for the provider itself; only registration is changed.
2021-07-13 16:55:21 +01:00
94e16f416d Added KnownTranslationKeys (generated) and start using it 2021-06-29 22:46:04 +01:00
32d7b1e6af Start using webmozart/pathutil for joining paths (#4287) 2021-06-29 19:40:43 +01:00
902ea515f7 Separate ID handling from GameMode
the aliases of 0,1,2,3 remain for user-interface level compatibility.
2021-06-27 20:32:35 +01:00
ede4d58394 Automatic permission calculation on PermissibleBase construction
thanks to the PermissibleInternal/PermissibleBase architectural change, there's no longer any concern regarding cyclic refs.
2021-06-26 22:15:22 +01:00
8cd7cc7c00 pacify php-cs-fixer 2021-06-26 19:32:05 +01:00
e14bad4ea6 Rename CommandReader and friends to ConsoleReader 2021-06-26 19:29:58 +01:00
a70bd115f1 Moved console-specific stuff to its own namespace
this stuff has different functionality than everything else in the
command namespace (specifically console handling), so it doesn't belong
in here.

I know that this will probably break some plugins, but I don't care,
because plugins shouldn't have been abusing ConsoleCommandSender in the
first place.
2021-06-26 19:24:46 +01:00
981b0285d1 Isolate config casting nastiness in one place
this doesn't solve the underlying problem, but it does reduce the amount of noise made by PHPStan about it, as well as avoiding code litter.
2021-06-19 19:14:02 +01:00
2ee86f0edf Improved UPnP exception handling 2021-06-13 23:02:42 +01:00
80bf948588 Separate UPnPNetworkInterface from UPnP implementation 2021-06-13 22:41:36 +01:00
0402e7e697 Separate CommandReader impl from CommandReaderThread 2021-05-29 23:41:11 +01:00
624495f4d3 Added a generic Promise type
I anticipate increasing demand for promises, and since all the libraries I could find suck, we'll stick to our own impl for now.
2021-05-08 15:57:30 +01:00
9c1b274499 WorldManager::createWorld() now accepts WorldCreationOptions instead of mixed[] 2021-04-13 21:03:25 +01:00
1898d4b42c Fixed corner case with player spawning in ungenerated terrain
we can't get the safe spawn location of a set of coordinates if the coordinates are in an ungenerated chunk. This can happen if doing /setworldspawn <somewhere ungenerated> and then having a new player join the server.
2021-04-03 22:20:19 +01:00
f047ecfd2d Fixed player spawning in ungenerated terrain (#4087)
fixes #4044
fixes #2724

this is significantly more complex than I hoped for, but it's a start... and it works.
2021-03-26 21:36:27 +00:00
72de45f0e9 Drop pocketmine/uuid for ramsey/uuid 2021-03-16 23:03:00 +00:00
c1e5dd2a4e Merge branch 'stable' 2021-03-07 20:15:11 +00:00
c05779314d Allow offline player data to be provided from a custom source 2021-02-07 20:29:37 +00:00
bcc3e87730 Timings: rename core timers to remove 'timer' from the names
this makes them shorter and more consistent.
2020-12-23 17:52:25 +00:00
9228f006d4 Merge remote-tracking branch 'origin/stable'
# Conflicts:
#	composer.json
#	composer.lock
#	resources/vanilla
#	src/CrashDump.php
#	src/PocketMine.php
#	src/pocketmine/Server.php
#	src/pocketmine/item/Bucket.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/Chunk.php
#	src/pocketmine/level/format/io/leveldb/LevelDB.php
#	src/pocketmine/level/format/io/region/McRegion.php
#	src/pocketmine/network/mcpe/protocol/BatchPacket.php
#	src/pocketmine/tile/Furnace.php
#	src/pocketmine/utils/UUID.php
#	src/utils/ServerKiller.php
2020-12-20 20:54:13 +00:00
9e11cc03de Server: get rid of matchPlayer()
the functionality of this API method is too specialized to be of any practical use.
In addition, a search on Poggit reveals that the only uses of this API method are abuses or incorrect uses anyway.
2020-12-13 21:38:11 +00:00
c0438f1ddb Move player creation out of NetworkSession 2020-12-13 21:20:37 +00:00
5f4ef84d52 Clean up imports 2020-12-12 19:48:00 +00:00
03b1ea766a Added a DedicatedQueryNetworkInterface to ensure Query functionality when RakLibInterface is disabled (#3942) 2020-12-04 21:21:25 +00:00
29f6ed3f68 Use Snooze to improve AsyncTask collection times
regardless of how long an async task takes to run, it will take a multiple of 50ms to get the result processed. This delay causes issues in some cases for stuff like generation, which causes locking of adjacent chunks, and async packet compression, which experiences elevated latency because of this problem.
This is not an ideal solution for packet compression since it will cause the sleeper handler to get hammered, but since it's already getting hammered by every packet from RakLib, I don't think that's a big problem.
2020-12-02 19:34:34 +00:00
687ad28fa6 Added a PacketBroadcaster interface
this gives a bit more control over how packets are broadcasted, which might be useful if the batch format changes (e.g. adding a length prefix) for multi version.
This really ought to be unique to a protocol context instead of a network interface, but for now this is the best we can do.
2020-12-02 16:34:14 +00:00
6d8833ccd3 Removal of permission defaults (in favour of permission cascading) (#3937) 2020-12-01 17:13:54 +00:00
d56cf35385 Permissions are now always false when permission calculation hasn't been done yet
lack of permission calculation means that child permissions might not have been set correctly, so this might lead to users being able to access things they aren't supposed to.
2020-11-28 21:55:26 +00:00
97a4d80854 PlayerDataSaveEvent: provide online player if possible, otherwise don't load offline data from disk for no reason (we already have it, that's the whole point of the event ...) 2020-11-28 21:43:23 +00:00
614891f8a2 OfflinePlayer no longer depends on Server
it also doesn't provide stuff like isOnline() (you had to have a Server reference to get an OfflinePlayer anyway, just ask the Server if the player is online ...) and getPlayer().
2020-11-28 21:29:41 +00:00
dd200ca8cd Rewrite message broadcasting system to not depend on PermissionManager subscriptions
relying on permission subscriptions for this was unreliable (a permissible is not always subscribed to a permission even when it does have it), and also difficult to control (for example there have been various bugs in the past where a Player ended up subscribed to broadcast permissions when it didn't expect to be, thanks to permission recalculation happening too early).
In addition, we might in the future want to have broadcast receivers which are not permissibles (i.e. a more general interface than CommandSender (why does a broadcast receiver need to also be a command sender, anyway?)), which the permission system wouldn't be suitable for.
2020-11-28 19:28:47 +00:00
c7961bfe90 Toss ServerOperator; PermissibleBase now tracks its own op status
as well as being simpler, this also allows some nice features, such as granting memory-only op state that goes away when the player quits the server.
2020-11-28 18:22:59 +00:00
70b0d83258 Removed Server->broadcast()
this method has an explicit dependency on permission subscriptions, which I plan to eradicate.
The method's functionality can be replaced using Server->broadcastMessage() with a custom recipients array.
2020-11-28 13:01:10 +00:00
5142281cfa [ci skip] Server: remove misleading comment 2020-11-27 17:57:52 +00:00
4d42f0c3db Timings: added timers for player data I/O 2020-11-27 00:02:34 +00:00
0be60fe1eb NetworkSession: Force use of async compression during the login sequence when latency doesn't matter
closes #3907
this reduces the impact of compression on the login sequence by about 90%; however, since compression only accounted for about 30% of said overhead at most, it's not really a massive difference.
2020-11-26 23:39:19 +00:00
7469f28f24 Server: rename getPlayer() to getPlayerByPrefix()
closes #3910

the existing naming was misleading, and many plugin devs assumed that it returns an exact match. However, this is not guaranteed, and it's possible for two different players to match the same prefix.

- There is no defined behaviour for what happens when multiple players can equally match a prefix (e.g. 'fr' could match 'fred' or 'frog' equally, because the name lengths are the same)
- A prefix might match a different player at a different time (e.g. 'fr' could match 'freddie' before 'fred' joins, after which it will match 'fred' instead)

With these flaws in mind, it's better to break compatibility on this to make the intent more clear, and to make plugin developers reassess their usages of this method. In most non-command use cases, they should likely be using getPlayerExact() instead.
2020-11-14 15:49:41 +00:00
31089ce3b2 Timings: added broadcastPackets timer
the body of this function is potentially very expensive and isn't currently recorded by any timer.
2020-11-12 17:53:07 +00:00
5efd0eba13 Imports cleanup 2020-11-12 17:11:34 +00:00
463bc044df Rename PluginLoadOrder -> PluginEnableOrder
this more accurately describes its real purpose.
2020-11-09 20:28:08 +00:00