7856 Commits

Author SHA1 Message Date
Dylan K. Taylor
4e3e807741 Biome: Added UnknownBiome class to avoid astonishing behaviour on unknown biomes 2018-06-08 10:19:08 +01:00
Dylan K. Taylor
8c6161a4f2 Biome: make biomes list use an SplFixedArray 2018-06-08 10:19:08 +01:00
Dylan K. Taylor
c8a87b14d5
PopulationTask: actually fix locks not getting released in generation errors 2018-06-07 23:53:59 +01:00
Dylan K. Taylor
8fca7cc68d Apply some typehints to generators 2018-06-07 20:22:35 +01:00
Dylan K. Taylor
45f940681a Make Normal->pickBiome() private 2018-06-07 20:21:26 +01:00
Dylan K. Taylor
e3c97d7d5e Flat: clean up more garbage 2018-06-07 20:18:04 +01:00
Dylan K. Taylor
172abef2a7 Flat: clean up generation of base chunk 2018-06-07 20:11:29 +01:00
Dylan K. Taylor
709abb02e6 Generator: remove more dead incomplete code
again, this can be added when and if it's actually implemented.
2018-06-07 19:54:51 +01:00
Dylan K. Taylor
428ca29e4b Remove dead bedrockDepth fields from generator
yes, this is not implemented yet. fields for this can be added when proper bedrock generation is implemented. For now, it's just dead code.
2018-06-07 19:52:56 +01:00
Dylan K. Taylor
f61ad20f6b Remove a whole bunch of dead copy-pasted code from Nether generator 2018-06-07 19:51:27 +01:00
Dylan K. Taylor
3c9af5cd6d Generator: small reduction of code duplication 2018-06-07 19:49:51 +01:00
Dylan K. Taylor
996935e9b2 Cleaned up level seed handling 2018-06-07 19:39:24 +01:00
Dylan K. Taylor
3707a41b67 Server: small cleanup to seed handling 2018-06-07 18:25:44 +01:00
Dylan K. Taylor
354b2dc5d1 and an extra note just in case 2018-06-07 15:20:51 +01:00
Dylan K. Taylor
0c70b83d81 LevelProvider: workaround bug fixed in b54197904d6c23c5babe2857d0107d9d0fc8bd68 for previously-affected worlds 2018-06-07 15:18:42 +01:00
Dylan K. Taylor
083a1e1ff6 GeneratorManager: Make addGenerator() throw exceptions instead of returning false 2018-06-07 14:34:26 +01:00
Dylan K. Taylor
17b58357fb GeneratorManager: add documentation for functions 2018-06-07 14:30:19 +01:00
Dylan K. Taylor
96a4dbb7d8 GeneratorManager: add typehints 2018-06-07 14:24:01 +01:00
Dylan K. Taylor
5eec683110 Generator: Moved generator registering things to a separate GeneratorManager class
this isolates the concerns of the Generator class, and also removes cyclic dependencies between the Generator class and its descendents.
2018-06-07 13:48:01 +01:00
Dylan K. Taylor
0bca3cd481 Generator: Move static noise functions to Noise instance methods 2018-06-07 13:40:10 +01:00
Dylan K. Taylor
b54197904d Fixed imported worlds getting PM classpaths written into their level.dat for generator
This will not fix existing worlds affected by this bug.
2018-06-07 13:20:50 +01:00
Dylan K. Taylor
fb484087a8 Entity: Remove unnecessary scheduleUpdate() call from initEntity()
this is already done by the constructor
2018-06-07 12:53:59 +01:00
Dylan K. Taylor
14914781fc Added exception throws when a closed tile or entity attempts to schedule itself for updating
I can't believe it took so long to find what was causing these stdClass bugs.
2018-06-07 12:37:26 +01:00
Dylan K. Taylor
fdd5b7b9c9 Entity: Fixed despawn flagging not kicking in until scheduling updates on entities 2018-06-07 12:34:23 +01:00
Dylan K. Taylor
c83c0eb935 Entity: Move responsibility of checking for despawn to Level
this ensures that flagging for despawn will always work as intended, including when onUpdate() is overridden.
2018-06-07 12:31:21 +01:00
Dylan K. Taylor
b331f8e1c9 AsyncWorker: added removeFromThreadStore()
and use it instead of overwriting with null things, which still occupies memory
2018-06-07 10:12:50 +01:00
Dylan K. Taylor
ee787974f2 AsyncWorker: Use statics for thread-local worker storage instead of globals 2018-06-07 09:59:32 +01:00
Dylan K. Taylor
73e56c8a36 Utils: Make kill() use static MainLogger instead of global variable 2018-06-07 09:29:53 +01:00
Dylan K. Taylor
5f7c884255 Reduce AsyncWorker default memory limit to 256MB
a worker shouldn't be using as much memory as the main server thread would, so 1024MB is extremely excessive.
2018-06-06 18:49:48 +01:00
Dylan K. Taylor
2b5e6b790f BanList: rename poorly-named parameter 2018-06-06 18:18:06 +01:00
Dylan K. Taylor
1a21041d00 AsyncPool: Parameterize worker memory limit instead of calling back into Server 2018-06-06 18:00:56 +01:00
Dylan K. Taylor
7b17a83227 Level: fix chunk locks not getting released on generation errors 2018-06-06 11:42:29 +01:00
Dylan K. Taylor
edd150971e CommandReader: Use statics for thread-local storage instead of globals 2018-06-06 10:06:52 +01:00
Dylan K. Taylor
38f4afb17c Make sure that test failures kill the build 2018-06-05 19:49:22 +01:00
Dylan K. Taylor
9d16863b1a Convert some TesterPlugin tests into PHPUnit tests, add PHPUnit configuration 2018-06-05 19:33:21 +01:00
Dylan K. Taylor
41a179e6e1 BlockFactory: fix bug in light filters which could result in negative light levels (and therefore wraparounds) 2018-06-05 18:12:45 +01:00
Dylan K. Taylor
3a31c531af Level: remove unused import 2018-06-05 13:04:24 +01:00
Dylan K. Taylor
e081b7dffa PermissibleBase: fix typehints of calculateChildPermissions() 2018-06-05 11:14:36 +01:00
Dylan K. Taylor
0233ae1eb6 Updated TesterPlugin submodule 2018-06-04 21:17:48 +01:00
Dylan K. Taylor
dce8ed9dd1 Eliminate more hard dependencies on MainLogger 2018-06-04 16:52:03 +01:00
Dylan K. Taylor
35eaf38ca1 MemoryManager: parameterize an abstract \Logger to remove dependency on MainLogger 2018-06-04 13:30:48 +01:00
Dylan K. Taylor
1d71f0cf43 AsyncWorker: added getLogger() 2018-06-04 13:29:38 +01:00
Dylan K. Taylor
9644766df3
Merge pull request #2213: Scheduler API refactor, plugins now have their own schedulers
- Removed `Server->getScheduler()`. All plugins now have their own scheduler which is accessible using `Plugin->getScheduler()`. Aside from being syntactically more concise and pleasant, this also allows much more effective management of tasks when plugins are disabled.
- Removed `PluginTask` class. Before this PR it was necessary for plugin tasks to descend from `PluginTask` to ensure that the server could clean them up correctly on plugin disable. This is no longer necessary, so the `PluginTask` class has been removed. Plugins may now utilize the `Task` class as a base if they like.
- Added `Server->getAsyncPool()`. Since the global scheduler does not exist any more, it does not manage the server's `AsyncPool` any more. Additionally, `ServerScheduler` was previously bloated by a lot of `AsyncTask` related methods, which are now not necessary because direct access to `AsyncPool` is granted instead.

- `ServerScheduler`:
  - `ServerScheduler` has been renamed to `TaskScheduler` since it is now a general-purpose task scheduler which is non-dependent on the user. This allows much greater flexibility and also makes it possible to unit-test.
  - All `AsyncTask`/`AsyncPool` related methods have been removed - the task scheduler does not manage the async pool anymore.
    - Calls to `Server->getScheduler()->scheduleAsyncTask()` should be replaced with `Server->getAsyncPool()->submitTask()`.
    - Calls to `Server->getScheduler()->scheduleAsyncTaskToWorker()` should be replaced with and `Server->getAsyncPool()->submitTaskToWorker()`.

## Backwards compatibility
This poses significant backwards compatibility breaks for any plugins utilizing Tasks or AsyncTasks. These breaks are described above, along with basic upgrade steps. The upgrade process is quite straightforward.

## Follow-up
A large part of the goal with this pull request is to modularize these parts of the code so that they can be reused and also unit-tested. I would like to remove the existing test set from TesterPlugin at some stage when the AsyncPool can operate without a Server.

Because of the above, I am considering making further backwards incompatible changes directly to `AsyncTask` to remove the `Server` parameters from `onCompletion()` and `onProgressUpdate()`. These shouldn't be too difficult to upgrade from and can be prepared for in advance.
2018-06-04 11:54:43 +01:00
Dylan K. Taylor
857f6dd5df Chunk: Share EmptySubChunk instance with other chunks on the same thread 2018-06-04 11:44:18 +01:00
Dylan K. Taylor
0d177d5219 Entity: Clear dirty properties at the end of the constructor
this prevents sending duplicate properties immediately after entity spawn (due to properties getting set in the constructor).
2018-06-04 11:18:42 +01:00
Dylan K. Taylor
fe21f0e916 Spawnable: change visibility of addAdditionalSpawnData() 2018-06-03 19:58:48 +01:00
Dylan K. Taylor
4c1d29cdf7 Tile: remove unnecessary removeTag() calls
these CompoundTags are now ephemeral, so it's not necessary to remove potential garbage from them anymore.
2018-06-03 18:31:23 +01:00
Dylan K. Taylor
fa21cd96c5 Tiles no longer store their NBT at runtime
This is a significant breaking change for anything utilizing Tiles as they now do not store their NBT at runtime anymore.
This is another step in the process of ridding PocketMine-MP of runtime NBT.

It can be noticed that all tiles are now using class fields to store properties instead of NBT, which is much faster, uses less memory and is also more concise when written in code.

Highlights:
- Tile->namedtag has been removed.
- Tile->saveNBT() now accepts a CompoundTag() parameter. Typically it's expected that this will be fed a newly-created CompoundTag (this part may be improved in the future).
- New internal methods Tile->readSaveData() and Tile->writeSaveData() have been added. Instead of overriding __construct() and saveNBT() to load and save properties from NBT, you should now implement these methods instead.

This is not final and will see further changes before it's done.
2018-06-03 18:29:08 +01:00
Dylan K. Taylor
a22e5616f6 Fixed tile and furnace custom names not being visible
This is caused by the Spawnable constructor calling spawnToAll() before the tile is fully initialized. I really really really hate constructors that _DO_ things by themselves.
2018-06-03 17:02:00 +01:00
Dylan K. Taylor
b6317fa7ce Sign: remove non-standard broken bad solution for editing
this never really worked properly and is a bad idea anyway. This was the cause of many sign-going-blank bugs before it was broken (by me), and since it's broken it's now useless. I don't think there's any practical way to make this work properly, so I leave it up to plugins to decide whether or not they want to cancel sign editing in protected areas. PocketMine-MP built-in spawn protection will already block this by default anyway.
2018-06-03 16:45:26 +01:00