58 Commits

Author SHA1 Message Date
DiamondStrider1
c8da9dea95
WorldManager: Remove unused if in unloadWorld() (#6203) 2023-12-20 10:38:00 +00:00
Dylan K. Taylor
ee9ce8a4f4
Merge branch 'minor-next' into major-next 2023-05-17 15:45:03 +01:00
Dylan K. Taylor
077fac84bf
Added aggregate timers for all world timings
this allows timings list view to display totals for these sections. It does make the tree view a bit more annoying in some cases though.
2023-05-08 16:27:46 +01:00
Dylan K. Taylor
f29e2f7110
WorldProviders now accept Loggers 2023-05-02 15:41:11 +01:00
Dylan K. Taylor
ba62e0f9cb
WorldManager: fixed borked pre-generation for new worlds' spawn terrain
perhaps directly altering the behaviour of selectChunks() wasn't a good
idea? ...
2023-04-11 23:55:53 +01:00
Dylan K. Taylor
2ed48c8469
... 2023-01-13 17:46:16 +00:00
Dylan K. Taylor
d786ed5ebf
WorldManager: fixed debug spam 2023-01-13 17:43:02 +00:00
Dylan K. Taylor
dff3f45d22
Constify more tick-related things 2023-01-13 16:29:09 +00:00
Dylan K. Taylor
99996b62d6
Align PhpDoc @param tags according to PHP-CS-Fixer 2022-12-06 13:21:20 +00:00
Dylan K. Taylor
7bcc663b60
Migrate core code to using symfony/filesystem
webmozart/path-util is retained for plugin compatibility, but is dropped in 5.0
2022-10-14 21:51:29 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
5cf572892f
WorldManager: fixed missing initializer for $defaultWorld 2022-04-28 15:38:20 +01:00
Dylan K. Taylor
b88a47929f
Modernize property declarations in src/world/* 2022-04-28 15:06:17 +01:00
Dylan K. Taylor
7ddd547190
Merge remote-tracking branch 'origin/stable' into staging/4.1 2022-02-06 23:55:52 +00:00
Dylan K. Taylor
1dc0d5f96a
WorldManager: do not calculate safe spawn if there are no players in the unloaded world 2022-02-04 19:24:51 +00:00
Dylan K. Taylor
712ffb3e31
WorldManager: fixed loading the default world's spawn chunk when unloading the default world
yo dawg
I heard you like loading and unloading
so I put some loading inside your unloading
so you can load while you unload
2022-02-04 19:22:37 +00:00
Dylan K. Taylor
aae5962f6a
Replace disallowed operators in src/world/ 2022-01-20 19:05:23 +00:00
Dylan K. Taylor
8fd475f87b
WorldManager: Check generator options of worlds before loading them, too 2021-10-11 17:44:38 +01:00
Dylan K. Taylor
7b6632941d
GeneratorManager::getGenerator() now returns null for unknown generator aliases
instead of returning Normal::class (indistinguishable from successful match) or throwing an exception (pain in the ass to handle).
2021-10-11 16:04:36 +01:00
Dylan K. Taylor
d63b9d1648
WorldManager: localize strings for world loading, generation and conversion 2021-10-02 20:33:32 +01:00
Dylan T
4111d92b98
Stop hardcoding chunk dimensions everywhere (#4443) 2021-09-10 16:13:25 +01:00
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