189 Commits

Author SHA1 Message Date
Dylan K. Taylor
c2c529e2da
Include Snooze interrupts in timings results
fixes #5511

This requires any Timings instances to be updated to
pmmp/timings@5410f62436, otherwise the TPS
reported will be incorrect.
2023-01-16 17:40:39 +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
b74c092d9b
Server: removed reference to nonexistent API method 2022-10-15 15:06:43 +01: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
b3bda788d9
Server: Deprecated getPlayerByPrefix()
this is only used for commands anyway, but we can't get rid of it yet.
2022-10-14 21:45:09 +01:00
Dylan K. Taylor
2cc8a56e68
Server: fixed borked serverCommand timings 2022-10-14 20:02:44 +01:00
Dylan T
b87e4d8bd3
Introduce and use TextFormat::addBase() (#5268)
This function adds "base" format to a string. The given formats are inserted directly after any RESET code in the sequence.

An example of where this is needed is in the logger.

Without this change, the following code:
$logger->notice("I'm a " . TextFormat::RED . "special" . TextFormat::RESET . " cookie");

causes the "cookie" part of the message to show as grey, instead of the expected aqua for NOTICE level messages.

There are also many workarounds for this problem throughout the server, mostly in command outputs, being forced to use WHITE instead of RESET to avoid breaking the logger output.
2022-09-28 16:13:11 +01:00
Dylan T
83e5b0adb6
ConsoleCommandSender is no longer responsible for forwarding broadcast messages to the logger (#5311)
This is a step towards implementing #2543.
2022-09-27 20:58:33 +01:00
Dylan K. Taylor
441b06f6c7
Merge branch 'stable' into next-minor 2022-09-15 12:44:53 +01:00
Dylan K. Taylor
f3ca6de1eb
shut 2022-09-02 20:00:52 +01:00
Dylan K. Taylor
770cca2efa
Server: harden response handling for crash report submission
this eliminates some checkImplicitMixed errors in phpstan.
2022-09-02 19:13:54 +01:00
Dylan K. Taylor
033dac3d16
Server: be explicit about the player promise resolver type
since there's no way for phpstan to infer the type of this, it becomes implicit mixed, which can conceal bugs.
2022-09-02 19:13:16 +01:00
Dylan K. Taylor
ffb3af3e0d
fix CS 2022-09-02 00:59:58 +01:00
Dylan K. Taylor
b3f03d7ae6
Poll console on the main thread, instead of using a separate thread
There's no need to use an extra thread for this, since there's no concern of a socket getting stuck in a blocking read.

This is one less thing that can go wrong because of pthreads.
2022-09-02 00:58:49 +01:00
Dylan K. Taylor
14d3e6c7d5
Allow disabling the console reader via pocketmine.yml
Useful to save resources on headless servers where the console is never used (e.g. hosted server, Docker, etc.)
2022-09-01 23:43:54 +01:00
Dylan K. Taylor
237c2866e0
Merge branch 'stable' of github.com:pmmp/PocketMine-MP into stable 2022-06-04 17:35:18 +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
7355798e77
Exit with error code if the server failed to start
this ensures that external tools such as start.cmd actually see an error if there is one
2022-06-03 18:34:54 +01:00
Dylan K. Taylor
179cac45f5
Merge branch 'stable' into next-minor 2022-05-22 16:21:05 +01:00
Dylan K. Taylor
688be0a404
Server: apply server.properties difficulty to newly generated worlds
see #5057

jury is out on whether or not this should override difficulty on preexisting worlds, but it's non-controversial that it should apply at least to newly generated worlds.
2022-05-21 18:46:38 +01:00
Dylan K. Taylor
d4b7f66e15
Promote some constructors 2022-05-17 22:34:58 +01:00
Dylan T
52e74296de
Stop the server if any plugin failed to load or enable (#4951)
closes #3080 

If plugins fail to load for some reason, it's highly likely that some critical functionality of the server is compromised. For example:
- if an NPC plugin fails to load, all custom entities added by that plugin will be deleted from worlds
- if a world protection plugin fails, players will be able to grief your otherwise immutable lobby map
- if a worldgen plugin fails, worlds using custom generators won't load
- if a permission plugin fails, players might have access to commands and features they aren't supposed to have
- the list goes on...

This change makes the server commit graceful suicide if any plugin fails to load for error-related reasons, including (but not limited to):
- Incompatible API version
- Missing dependencies
- Invalid plugin.yml
- Invalid main class

Plugins prevented from loading by `plugin_list.yml` are not considered errors and **are not** included in this change. If a plugin is disallowed from loading due to the `plugin_list`, the server will continue to run as if the plugin was not present.
2022-05-11 20:43:38 +01:00
Dylan K. Taylor
3b7e274c34
Server: localize 'forcing server shutdown' message 2022-05-11 14:54:29 +01:00
Dylan K. Taylor
db6abfb227
Stop the server if generators specified for new worlds are not valid
I thought I did this already in eff856d8e513a1f01eca16ab55bacf6e83399527, but it looks like my brain slipped a gear.

Without this change, it's possible to crash the server by specifying an invalid generator for the default world if it doesn't yet exist.
2022-05-11 14:35:20 +01:00
Dylan K. Taylor
ded7e24f67
Merge branch 'stable' into next-minor 2022-04-19 15:27:55 +01:00
Dylan K. Taylor
f2e8824242
fix CS 2022-04-15 16:24:15 +01:00
Dylan K. Taylor
a0e47b5a64
phpstan 1.5.6 2022-04-15 16:21:05 +01:00
Dylan K. Taylor
eff856d8e5
Stop the server if any world listed by config fails to load or be generated during startup
closes #3162

this does not affect worlds loaded by plugins; they may continue to handle errors as they see fit
2022-03-03 18:40:11 +00:00
Dylan K. Taylor
4e956d5d1d
Replace remaining disallowed operators 2022-01-20 19:23:19 +00:00
Dylan K. Taylor
a5c0958adf
Filesystem::safeFilePutContents() now consistently throws RuntimeException in all expected failure cases
unexpected cases may still throw ErrorException (such as undefined variables) but we don't want to capture those.
2022-01-09 16:33:31 +00:00
Dylan K. Taylor
4466166f8b
Merge branch 'stable' into next-minor 2021-12-15 03:12:41 +00:00
Dylan K. Taylor
6e67c7532a
Bump default max render radius to 16 chunks
It's 2021, this is making PM look bad to new users (as if we need something else to make PM look bad...)
2021-12-15 01:46:50 +00:00
Dylan K. Taylor
5f8ebd81d7
it's MAX view distance, not fixed 2021-12-15 01:42:29 +00:00
Dylan K. Taylor
79b5109953
Move some configuration constants to .. well .. constants 2021-12-15 01:40:29 +00:00
Dylan K. Taylor
4d37b79ff7
Server: fixed not being able to deop players whose names were added to ops.txt with uppercase letters in them
same as iTXTech/Genisys#1204

why didn't anyone report this???
2021-12-15 01:08:59 +00:00
Matthew Jordan
a41404bd8a
Allow gamemode strings for gamemode property in server.properties (#4638)
closes #2692
2021-12-14 22:56:22 +00:00
Dylan K. Taylor
889d048ca3
Make use of Utils::assumeNotFalse() in a bunch of places
I've stuck to only doing this in the places where I'm sure we should never get false back. Other places I'm less sure of (and I found more bugs along the way).
2021-12-08 19:39:04 +00:00
Dylan K. Taylor
45b4fa0e96
Server: improve confusing condition in crashDump() 2021-12-07 23:08:06 +00:00
Dylan K. Taylor
bf29409a45
Server: fixed PHPStan level 7 error in crashDump() 2021-12-07 23:06:10 +00:00
Dylan K. Taylor
527e975fa9
shut 2021-12-05 00:45:23 +00:00
Dylan K. Taylor
8e37f86480
Avoid file_put_contents() when overwriting files
this fixes many cases of corruption during disk-full situations - file_put_contents() would write an empty file, destroying the original data.
fixes #3152
2021-12-05 00:26:48 +00:00
marshall
1b86355c40
Server: Suppress "Minecraft network interface running" messages if RakLibInterface registration is cancelled (#4603) 2021-12-02 20:29:01 +00:00
Dylan K. Taylor
4a8ca603a1
Log a message when forceShutdown() is called for anything other than a graceful shutdown 2021-11-28 18:53:34 +00:00
Dylan K. Taylor
c37c261c0f
Separate crashdump file generation from crashdump data collection
this allows CrashDump to be used just to generate data, which will come in useful for non-crash error reporting in the future (e.g. packet decoding errors).
2021-11-22 22:19:40 +00:00
Dylan K. Taylor
269231c228
Ban foreach(arrayWithStringKeys as k => v)
this is not as good as phpstan/phpstan-src#769 (e.g. array_key_first()/array_key_last() aren't covered by this, nor is array_rand()) but it does eliminate the most infuriating cases where this usually crops up.
2021-11-15 22:52:05 +00:00
Dylan T
cc4bb91fcb
Implemented IPv6 support (#4554) 2021-11-08 20:03:28 +00:00
Dylan K. Taylor
84f8b3eb2d
Move CrashDump to pocketmine\crash namespace 2021-11-04 19:23:45 +00:00
Dylan K. Taylor
8ac999cbd4
Use object models for crashdump generation 2021-11-04 16:55:04 +00:00
Dylan K. Taylor
d184838ba0
Move Promise classes to their own namespace 2021-11-02 17:10:07 +00:00
Dylan K. Taylor
275f145418
BedrockData is now a Composer dependency
this should put a stop to people nagging me about incorrect blocks (we have a check to make sure composer dependencies are up to date).
2021-11-02 16:45:45 +00:00