287 Commits

Author SHA1 Message Date
Dylan K. Taylor
e04dfe96af
Merge branch 'stable' into next-minor 2022-01-01 17:55:17 +00:00
xxAROX
193a1b3f4e
TextFormat: Added MINECOIN_GOLD (§g) color code support (#4670) 2021-12-30 23:53:05 +00:00
Dylan K. Taylor
38b6b39cb3
Filesystem: workaround a stupid Windows issue in safeFilePutContents()
occasionally Windows will randomly decide to deny us access to rename the file for no reason whatsoever. If this happens, we attempt an old-style copy and delete.
If the rename failed for a legit reason, the copy and delete should also fail and generate an error message. If it was Windows being a spaz, it should work normally without errors.
2021-12-29 15:26:34 +00:00
Dylan K. Taylor
65dabefa3b
Config: improve config loading and parsing error handling
closes #4654
closes #3454
2021-12-19 16:53:29 +00:00
Dylan K. Taylor
482bc462d3
VersionString: Use multiplication instead of bitshift for version IDs
this makes them more recognizable, and also fixes #4630.

This is technically a BC break (behavioural change), but since nothing appears to use this functionality anyway except PM itself, I don't think it matters.
2021-12-15 14:32:50 +00:00
Dylan K. Taylor
60938c8c9d
Random: fixed nextSignedInt() not actually returning signed ints
closes #4646
closes #4645

Impact assessment by core usage search and poggit suggests that the impact of this change will be close to zero.
However, since it changes behaviour which plugins might be unknowingly relying on, it's going into 4.1 rather than a patch release.
2021-12-15 00:59:10 +00:00
Dylan K. Taylor
dbad5dd611
Merge branch 'stable' into next-minor 2021-12-14 23:16:01 +00:00
Dylan K. Taylor
ea1fceece2
Merge branch 'legacy/pm3' into stable 2021-12-14 23:15:53 +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
c6466a6da9
Utils: added crutch assumeNotFalse()
this can be used to get PHPStan to shut up about stuff that will never return false in normal contexts.
It's more fine-grained than @phpstan-ignore-line and less hassle than ignoreErrors (and works in PhpStorm too).
In addition, it's easy to search for references.
2021-12-08 18:58:39 +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
Dylan K. Taylor
8e8cee45b8
Config: use JSON_THROW_ON_ERROR for encoding 2021-12-04 21:44:12 +00:00
Dylan K. Taylor
b784a04e08
Utils: fixed parseDocComment() ignoring tags containing hyphens 2021-11-24 16:38:37 +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 K. Taylor
18f5fb66bb
Abstract the base functionality of StringToItemParser 2021-11-08 18:37:05 +00:00
Dylan K. Taylor
d184838ba0
Move Promise classes to their own namespace 2021-11-02 17:10:07 +00:00
Dylan K. Taylor
e34364412b
Replace InvalidStateException usages with InvalidArgument or LogicException 2021-11-02 16:05:54 +00:00
Dylan K. Taylor
4eef458d29
Config: throw AssumptionFailedError if config type is invalid or DETECT during save()
this should never happen ... it was already checked in load()
2021-11-02 16:03:43 +00:00
Dylan K. Taylor
f2912fcdd8
Updated pocketmine/log and pocketmine/log-pthreads (BC breaks included)
AttachableLogger deals with Closures now instead of LoggerAttachment objects
ThreadedLoggerAttachment no longer implements LoggerAttachment
2021-11-01 22:22:22 +00:00
Dylan K. Taylor
f827a555d5
Merge branch 'stable' 2021-11-01 18:13:24 +00:00
Dylan K. Taylor
08636d079d
Promise: expose isResolved() 2021-10-31 22:48:52 +00:00
Dylan K. Taylor
f1a791ef75
Improved Promise API - separate resolver and consumer APIs
this makes creating a promise slightly more cumbersome, but I'm more concerned about people who might try to call 'new Promise' directly.
2021-10-31 19:49:57 +00:00
Dylan K. Taylor
1d99cd329a
CS again 2021-10-26 00:50:43 +01:00
Dylan K. Taylor
24d4daec90
Utils::testValidInstance() now accepts interfaces for the baseName 2021-10-26 00:32:32 +01:00
Dylan K. Taylor
4178c81209
Utils: fixed testValidInstance() not accepting the same valid class for both className and baseName
this caused problems in PlayerCreationEvent because plugins set the base class and then set the player class to the same thing.
2021-10-26 00:31:30 +01:00
Dylan K. Taylor
06e7338ff9
Move exception printing utilities from MainLogger to Utils
where they can be useful to other stuff apart from just the logger
2021-10-14 15:54:20 +01:00
Dylan K. Taylor
7a4af7a0bc
SignalHandler: fix CS
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
2021-10-14 15:14:27 +01:00
Dylan K. Taylor
34b1392598
Cross-platform signal handler 2021-10-14 15:03:11 +01:00
Dylan K. Taylor
4bf6205a6c
Merge commit '289553fa46fc26b03db73db23481a98d6ddb12a5' 2021-10-12 23:28:35 +01:00
Dylan K. Taylor
b5699679ef
Merge commit 'e38866c4ba90f8efd5630dbe674fd7ca15f586ff' 2021-10-12 23:23:27 +01:00
Dylan K. Taylor
912e612743
Utils: allow validateCallableSignature() to accept a manually constructed CallbackType instead of a closure
this allows more fine-grained control without PHPStan yelling at us.
2021-10-10 23:27:09 +01:00
Dylan K. Taylor
4910250a81
Config: fixed writeList() 2021-10-07 21:47:09 +01:00
Dylan K. Taylor
e0d2e24698
fix CS (again\!) 2021-10-07 21:19:44 +01:00
Dylan K. Taylor
d5f02a0bf8
Config: expose APIs to parse/emit list configs 2021-10-07 21:18:42 +01:00
Dylan K. Taylor
2a3a57c519
Enable parsing/emitting .properties without creating a Config object
this is useful when the contents are just going to get passed straight into a model, making Config object redundant anyway.
2021-10-07 20:53:15 +01:00
Dylan K. Taylor
5115387feb
fix CS (again) 2021-10-07 20:43:55 +01:00
Dylan K. Taylor
dd0aaf59b5
MainLogger: Log exceptions as a single block message 2021-10-07 20:40:20 +01:00
Dylan K. Taylor
a555f21b18
MainLogger: write messages before calling logger attachments 2021-10-07 20:32:02 +01:00
Dylan K. Taylor
1be9b2f037
Config: drop packing of arrays
we don't handle arrays on decode, so there's no reason to support them on encode either.
2021-10-07 20:30:56 +01:00
Dylan K. Taylor
90800a4124
Config: Try to coerce types, similar to YAML 2021-10-06 21:09:23 +01:00
Dylan K. Taylor
7d06b76aaf
PluginManager: account for possible invalid format of API version
we're seeing a lot of crashes because of this.
2021-10-05 18:36:00 +01:00
Dylan K. Taylor
0108888450
Process: silence taskkill complaining that it can't commit suicide
since taskkill is a subprocess of the server process, it gets included in taskkill's own attempted killing spree, but taskkill (wisely) won't kill itself.
2021-10-02 17:23:26 +01:00
Dylan K. Taylor
dd0c2fed82
Process: add subprocess parameter to kill()
fix CommandReader subprocess lingering on a crash and fucking up the console
2021-10-02 16:56:24 +01:00
Dylan K. Taylor
da0482d330
Solidify version comparison 2021-09-07 12:24:16 +01:00
Dylan K. Taylor
ed1e7322dd
be quiet phpstan 2021-09-03 21:16:37 +01:00
Dylan K. Taylor
62435fe935
Standardize clone denying 2021-09-03 21:07:39 +01:00
Dylan K. Taylor
b026ada489
Standardize serialize denying 2021-09-03 21:07:10 +01:00
Dylan K. Taylor
270ee5c085
Simplify registry method generation 2021-08-22 23:02:36 +01:00
Dylan K. Taylor
cd9af7f9f6
Utils: be explicit about class existence checking in testValidInstance() 2021-08-21 15:57:57 +01:00
Dylan K. Taylor
4d73c93886
fix CS 2021-08-21 15:54:11 +01:00