37 Commits

Author SHA1 Message Date
Dylan K. Taylor
8b9d7d6390
Support for nested TranslationContainers 2021-08-14 20:57:13 +01:00
Dylan K. Taylor
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
Dylan K. Taylor
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
Dylan K. Taylor
94e16f416d
Added KnownTranslationKeys (generated) and start using it 2021-06-29 22:46:04 +01:00
Dylan T
32d7b1e6af
Start using webmozart/pathutil for joining paths (#4287) 2021-06-29 19:40:43 +01:00
Dylan K. Taylor
02fab77e55
World: change 'closed' to 'unloaded'
this makes more sense overall from a reader's perspective.
and also provide a rug-jerk for any idiots using World->close() when they aren't supposed to? ....
2021-06-26 21:54:18 +01:00
Dylan K. Taylor
2ce6a87d05
getSafeSpawn() may throw if the target terrain is not generated 2021-05-08 16:22:13 +01:00
Dylan K. Taylor
e9f3cefe94
Default world might be null 2021-05-08 16:21:34 +01:00
Dylan K. Taylor
027109075c
WorldManager: don't recalculate the spawn point for every player teleported during world unload 2021-05-08 16:19:22 +01:00
Dylan K. Taylor
8af6b112d2
WorldManager: log after first chunk's generation has been completed
this is as close as we can get to the actual start of generation.
2021-04-15 14:01:28 +01:00
Dylan K. Taylor
7b21fc8e9d
WorldCreationOptions are now mandatory during creation of worlds 2021-04-15 13:54:58 +01:00
Dylan K. Taylor
ecf6de3430
WorldManager: Pre-generate a radius of 8 chunks
3 is absurdly small. 8 is a more realistic estimation of what the average player's render distance will be (it's also the default server.properties limit).
3 doesn't even fill the default spawn-radius setting, meaning that delays during player connection would occur anyway due to generation.
2021-04-13 22:15:47 +01:00
Dylan K. Taylor
0f3147f49b
WorldManager: Log progress of spawn terrain generation 2021-04-13 21:28:17 +01:00
Dylan K. Taylor
9c1b274499
WorldManager::createWorld() now accepts WorldCreationOptions instead of mixed[] 2021-04-13 21:03:25 +01:00
Dylan T
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
Dylan K. Taylor
5a59afbe2c
Place world conversion backups in <pwd>/backups/worlds instead of <pwd>/world_conversion_backups 2021-03-17 01:21:11 +00:00
Dylan K. Taylor
c21ec614fc
Fixed PHPStan 0.12.74 error in WorldManager 2021-02-11 16:54:14 +00:00
Dylan K. Taylor
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
Dylan K. Taylor
1e737644de
World: split populateChunk() into two functions
requestChunkPopulation() respects the queue size, orderChunkPopulation() does not.
requestChunkPopulation() should be used for non-essential generation (which mainly includes generation for player use).
orderChunkPopulation() should probably be used by plugins.
2020-12-17 23:49:37 +00:00
Dylan K. Taylor
ef542880de WorldManager: allow different World instances to have different AsyncPool instances
instead of being forced to use the Server async pool
right now the intent of this is to reduce (and ultimately eliminate) the dependency of World on Server, but it might come in useful for other stuff too, for example a chunkserver-based generator implementation which blocks on network instead of eating CPU (it would just waste CPU for other tasks).
2020-11-01 15:21:15 +00:00
Dylan K. Taylor
7b02cc3efd Implemented #3836: Replace setCancelled() in events with cancel() and uncancel()
The motivation for this is to prevent passing a dynamic argument to cancellation, which in almost all cases is a bug in user code. This same mistake also appears in a few places in the PM core (as seen in this commit), but in those cases the mistakes were mostly harmless since they were taking place before the event was actually called.
closes #3836
2020-09-26 14:31:56 +01:00
Dylan K. Taylor
91b028c208 WorldManager: use ChunkSelector to find stuff to pre-generate 2020-07-10 20:06:26 +01:00
Govdim
4ce5f2a6c6
WorldManager: Add access to WorldProviderManager (#3527)
* WorldProvider: Add access to WorldProviderManager

* WorldManager: Updated getProvider method

Co-authored-by: Govdim <govdim.govorek@gmail.com>
2020-05-26 06:59:19 +01:00
Dylan K. Taylor
c93038f574 Inject WorldProviderManager to WorldManager's constructor, no longer singleton 2020-05-24 19:22:04 +01:00
Dylan K. Taylor
c9af5ce7a9 Convert GeneratorManager to singleton 2020-05-23 10:13:03 +01:00
Dylan K. Taylor
640428c415 Convert WorldProviderManager to singleton 2020-05-23 10:02:09 +01:00
Dylan K. Taylor
e2232dd8d4 WorldManager: reduce code duplication for world path discovery 2020-05-23 09:50:25 +01:00
Dylan K. Taylor
8d9759288c WorldManager: don't hard-depend on server configuration for autosave settings 2020-05-23 09:43:59 +01:00
Dylan K. Taylor
fcea7da183 WorldManager: allow dataPath to be injected via constructor 2020-05-23 09:37:37 +01:00
Dylan K. Taylor
aac7da6c96 eliminate remaining empty() usages 2020-02-07 21:51:50 +00:00
Dylan K. Taylor
fb1126797a Merge branch 'stable' 2020-02-07 18:13:55 +00:00
Dylan K. Taylor
ff63f6d055 fill in more iterable types (master) 2020-02-01 20:19:57 +00:00
Dylan K. Taylor
f65bf76fd8 Merge commit '799183e13e61e89cc6820ad3132a4147454017c6'
# Conflicts:
#	resources/vanilla
#	src/Server.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/level/format/io/LevelProviderManager.php
#	src/pocketmine/tile/Tile.php
#	src/world/generator/GeneratorManager.php
2020-01-31 21:26:40 +00:00
Dylan K. Taylor
055b13a6cf strip extra blank lines (php-cs-fixer) 2020-01-22 15:14:10 +00:00
Dylan K. Taylor
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
Dylan K. Taylor
39d5903c3e Remove INT32_MIN and INT32_MAX global constants 2019-08-25 16:09:51 +01:00
Dylan K. Taylor
5499ac620c Removed pocketmine subdirectory, map PSR-4 style 2019-07-30 19:14:57 +01:00