Related to #4174, #4717.
As it stands, `JsonList` throws an NPE on `jsonarray.iterator()` when
the reader given is at EOF. This means there is an unintelligible
message shown to the player:
```
[16:44:31 ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: Cannot invoke "com.google.gson.JsonArray.iterator()" because "jsonarray" is null
at net.minecraft.server.v1_16_R2.JsonList.load(JsonList.java:192) ~[patched_1.16.3.jar:git-Paper-248]
at net.minecraft.server.v1_16_R2.DedicatedPlayerList.y(SourceFile:95) ~[patched_1.16.3.jar:git-Paper-248]
...
```
This is clearly not understandable to the untrained eye: what is
`jsonarray`? What is `DedicatedPlayerList.y`?
This rather does a proper exception message:
```
[16:42:59 ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: The file "banned-players.json" is either empty or corrupt
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787) ~[paper-1.16.3.jar:git-Paper-"8e6d90c2d"]
at net.minecraft.server.v1_16_R2.JsonList.load(JsonList.java:190) ~[paper-1.16.3.jar:git-Paper-"8e6d90c2d"]
at net.minecraft.server.v1_16_R2.DedicatedPlayerList.y(SourceFile:95) ~[paper-1.16.3.jar:git-Paper-"8e6d90c2d"]
...
```
It is still an exception, which server owners may or may not understand,
but the message now says exactly what went wrong, and who would've
known, now we know what `DedicatedPlayerList.y` is, and we know what
file was broken.
This is more of a quality of life change, but it is certainly useful to
the server owners that come into `#paper-help` and the issue tracker
(#4174) to ask for help with unintelligible messages we need to open a
patched Paper project to make any sense out of.
Check state of jsonarray instead of checkNotNull
Co-authored-by: Riley Park <riley.park@meino.net>
The behavioural nearby sensors are validated every tick on the entities
that registered the respective sensors and are therefore a good subject
to performance improvements.
More specifically this commit replaces the Stream#filter usage with
ArrayList#removeIf as the removeIf method on an array list is heavily
optimized towards a single internal array re-allocation without any
further overhead on the removeIf call.
The only negative of this change is the rather agressive diff these
patches introduce as the methods are basically being reimplemented
compared to the previous stream-based implementation.
See: https://nipafx.dev/java-stream-performance/
Note: Updated LICENCE.md to release this commit under MIT
A lot of plugins seem to use reflection to determine this, so this could be a bit of a starter-patch as future PR'ers could also exposed tracked entities as well.
For some reason, this doesn't always seem to capture all states of shutdown,
either the logger is just being fun, or, potentially, the thread is already
marked as dead when we're getting called so the trace is not generated through
the method on Thread
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
95ff95ed #588: Add Player#sendBlockDamage()
CraftBukkit Changes:
ea050e6e9 #807: Add Player#sendBlockDamage()
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
fcbd2266 #587: Fix various javadoc typos