Commit Graph

4919 Commits

Author SHA1 Message Date
Mariell
9bb4e93090
Fix piston dupe patch creating ghost blocks (#3603)
The 2 flag (send change to clients) must always be set. If it is only set
when the `map.replace` call before it does something, as was suggested
on Discord, the issue will not change whatsoever.

Fixes #3593
2020-06-22 19:00:00 -04:00
PatoTheBest
e9c332ddb6
Fix NPE on TileEntitySkull (#3598)
The setGameProfile method on TileEntitySkull is annotated with the @nullable annotation,
but the skull didn't check for null profiles before attempting to retrieve cached skin.
This bug was introduced by the commit making the skull use spigot's User Cache.

Additionally, CraftMetaSkull also had the same issue with a null GameProfile, so this also
ensures it doesn't break.

The whole CraftPlayerProfile class is not null-safe, it requires a GameProfile that isn't
null so we add a Validation on the constructor, that way it is easier to catch this kind
of issue in the future.
2020-06-21 22:59:34 -04:00
Nesaak
b6a25a5356
Expose getItemStack in Arrows 2020-06-20 16:34:06 -04:00
kickash32
246af15ddc
Track Ender Dragon at current (no tick) view distance 2020-06-20 16:20:00 -04:00
Mariell Hoversholm
29a96bc1c5
Add clear reputation API 2020-06-20 16:02:28 -04:00
Aikar
ab2e8a853c
Add note to use Personal Forks and not Organization forks for PR's
Paper will routinely modify your PR for you to rebase it on latest or take care of any minor nitpicks that we can
just solve for you instead of making you go back for a trivial item.

However, if you use an Organization for the PR, this prevents Paper from doing this, and will require us to manually
merge it and close the PR instead of it being marked as the purple merged.

We much prefer to have merged PR's show as merged, so please do not use organizations repo's for PR as GitHub sadly
does not support maintainers pushing to them.

See [https://github.com/isaacs/github/issues/1681](https://github.com/isaacs/github/issues/1681)
2020-06-20 15:51:03 -04:00
ㄗㄠˋ ㄑㄧˊ
b2afcf1194
Add history file for terminal 2020-06-20 15:46:25 -04:00
Max Lee
c7e4c45f26
Add Inventory getHolder methods without creating new block snapshots (#3535) 2020-06-20 15:34:56 -04:00
Techcable
87e3c18093
Make enableTreasureMaps apply to shipwreck loot generation
Fixes #3480
Previously it only controlled whether villagers could trade treasure maps.
Now it should apply to loot generated in treasure maps.

We don't unregister treasure maps from the loot table,
since this option is per-world and the table is global.
Instead I just replaced the implementation with a NOP.
2020-06-20 15:26:38 -04:00
HeartPattern
7d256d659f
Remove useless warn logging while disconnecting
Remove useless "handleDisconnection() called twice" logging.
This warning log every time player kicked by server.
2020-06-20 15:23:02 -04:00
Spottedleaf
0d8594ae94
Fix enderdragon exp dupe
Properly track death stage when unloading/loading in the dragon
2020-06-20 15:04:50 -04:00
Spottedleaf
1cf1ebdc5d
Prevent position desync in teleporting during movement
Caused the server to revert to the player's overworld coordinates
after teleporting into the end.

Sidenote: The underlying issue is that the move call can teleport
entities and do other things like kill the entity. In the future,
to fix all exploits derieved from this usually unexpected
behaviour, we need to move all of this dangerous logic outside
of the move call and into an appropriate place in the tick method.
2020-06-20 14:59:49 -04:00
Spottedleaf
8f28f22ccf
Fix sand not dying correctly
If the falling block dies during teleportation (entity#move), then we need
to detect that by placing a check after the move.
2020-06-20 14:58:35 -04:00
Spottedleaf
96feb68ad9
Fix carpet and rail duping by pistons under same TNT duping config
This renames the config from enable tnt duping to enable piston duping

Normally we would not have a config for rails and carpet duping, but
the fix for TNT is the same fix for rails and carpet, so they are
having to be covered under that same config.
2020-06-20 14:56:08 -04:00
Spottedleaf
3e75d90810
Fix more cases of Bedrock breaking
This is still covered under the setting to re-enable this.
2020-06-20 14:54:17 -04:00
Mariell
01ce3cb0a5
Only complete from cache if ID is given (#3591)
As it stands, one can complete from the cache if no ID is given. If
there is no ID, it will throw an NPE, as ConcurrentHashMap (which is used
in UserCache) does not support null keys. This should fix any current
and future issues where exceptions are thrown just because a UUID is not
currently given on the profile due to a plugin or server bug/issue.

Fixes #3590.
2020-06-20 14:46:57 -04:00
Aikar
b68ae39f9a
Revert a change made to getChunkFuture for isUnloading
Talked with leaf on it and understand what its going now even though
it was a hack fix by Spigot, but seems ok.

I had orig made this change thinking it was the source of another
issue but that came out to not be true.

Fixes #3573
2020-06-20 14:37:25 -04:00
Aikar
1f181040dd
Ensure we load chunks for Entity getCubes
Was some other code paths missing the set for loading chunks

Fixes #3582
Fixes #3368

Probably helps with "falling through world" issues too.
2020-06-20 14:25:11 -04:00
Aikar
2a3cb3753f
Optimize Network Manager Closed channel handling and flushing
Adds Netty Channel Flush Consolidation to reduce the amount of flushing
This improves performanceo of netty event loop.

If a problem is encountered with this, you can disable it by adding the java flag:
  -DPaper.disableFlushConsolidate=true

Also avoids spamming closed channel exception by rechecking closed state in dispatch
and then catch exceptions and close if they fire.

This should resolve connections getting stuck spamming ChannelClosed in logs and
let them clean up and close correctly.
2020-06-20 14:25:11 -04:00
Aikar
3dc5ad343f
Improvements to chunk priority / bug fixes
ensure we add missing player tickets even if already full status
remove the player ticket throttler entirely... causes a lot of issues and
our system handles the role that it was serving now too.

increase max delays on farther out chunks load delay

remove -5 priority delay for distant chunks seemed it applied at weird times.

ensure if delay distance manager tick ever got left lingering it unsets on a chunk load.

Fixes #3572
2020-06-20 02:38:59 -04:00
Aikar
a70618cd5c
Make Skull Texture Lookup use the User Cache
Spigots cache only cached by name which really was not correct...

Additionally, user cache exposes a cache of any player who has logged in
once this session too even if offline.

Also fixed some quirks with Profile API where we might of had textures
in the cache that we didn't even try to look up.

So this should overall help reduce API calls to Mojang.

Sadly, the User Cache doesn't cache textures, but if that ever
changes in future, we would gain benefit there too.
2020-06-19 22:07:19 -04:00
Aikar
92d1247ee3
Improve light optimizations and fix bugs
Rewrites the Threaded task logic to no longer use 2 queues and instead
keep a single prioritized queue and do all of a chunks light tasks in a single batch

Fix a math issue in one place (Thankfully didn't seem to really be a common place since didn't notice anything)
2020-06-19 19:10:38 -04:00
Zach Brown
9ffaa44ae1
Also restrict height in the vanilla teleport command
Uses the same ridiculously large limit as before,
just now also applied to the Y coord.

Fixes GH-3575
2020-06-17 17:46:45 -05:00
Josh Roy
f860969175
Add unsupported-settings section to config (piston tnt dupe config option) (#3565) 2020-06-15 12:29:39 -04:00
MiniDigger
d7bb893c02
Document fixup commit way of modifing patches (#3423) 2020-06-15 11:20:28 -04:00
Shane Freeder
83e832b44c
[CI-SKIP] Rebuild patches 2020-06-14 20:46:12 +01:00
Spottedleaf
91459fe514
Fix piston physics inconsistency (fix tnt dupers) (#3544)
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2020-06-12 03:30:30 -04:00
David Slovikosky
8c41ac1c98
Fix missing chunks due to integer overflow (#3527)
This patch fixes a bug in the WorldChunkManagerTheEnd class where the distance
from 0,0 squared overflows the maximum size of an integer. The overflow leads
to hard chunk borders around 370,000 blocks from 0,0. After this cutoff there
is a few hundred thousand block gap before end land resuming to generate at
530,000 blocks from spawn. This is due to the integer flipping back and forth.

The fix for the issue is quite simple, casting chunk coordinates to longs
allows the distance calculation to avoid overflow and work as intended.
2020-06-12 03:30:18 -04:00
avaruus1
cffe4c075e
Scheduling an async task timer creates a non-repeating task (#3543) 2020-06-11 19:32:48 -04:00
Aikar
e224f0bdab
Fix issues with SIGTERM not shutting down gracefully - Fixes #3062
We had 2 issues.
1) Log4J2 Shutdown hook seemed to be causing issues as it shutdown logger while we still needed it
2) ServerShutdownThread needs to stay alive until server is shutdown to keep jvm open.

It appears SIGINT is handled differently than SIGTERM, as SIGINT worked correctly.

But this will make both methods work.
2020-06-10 23:40:28 -04:00
Spottedleaf
c7112d0661
Ensure chunk gen tasks return to main thread before completing futures 2020-06-10 23:40:23 -04:00
Aikar
a72d4bb2ab
Improve chunk loading speed and prioritization further - Fixes #3530 2020-06-10 09:24:17 -04:00
Aikar
64666dc8b6
Improve Chunk Priority, Frustum Priority and Load Speed Algorithms
Fix bug where mojang has a -90 modifier in yaw resulting in us calculating
chunks to the players left rather than in front of them.

Drastically improve Frustum Prioritization function to reduce lag from its
calculations (Found it was being spammed really heavy on world add/teleport)

Also improved the logic behind choosing chunks to prioritize.

Add Priority tickets to a radius of 3 on any login, world chnge or teleport

This should help improve world load / chunk sending upon a player changing
locations by loading those chunks faster.

Improved the Player Ticket Delayer to be a little bit smarter about delays to
let closer chunks load a bit faster and only delay the farther out ones more.

This update will provide significant improvements to priority of chunks and
reduce the cpu cost of doing these calculations.

Fixes #3530
2020-06-10 01:20:57 -04:00
Aikar
146b99080c
Improve ChunkMapDistance.b crash fix to clean up properly
There is some vanilla level bug where this tracking state appears
to get messed up and player doesn't exists in chunk its trying to untrack.

We returned early to prevent crashing, but I suspect if there was a level being
tracked for the chunk, it got leaked due to the early return.

So going to ensure we clean up the level tracker when this state occurs.

This may help with any leaked chunk issues.
2020-06-09 23:05:43 -04:00
Aikar
2c4499b71c
Show Plugins Event Listeners under Combined Total in Timings 2020-06-09 21:48:35 -04:00
Aikar
c5c909c9af
Improve Plugin Ticket Management
Now supports async chunk access even though doing that is bad
and shouldn't be done anyways since we force you back to main, itll
now just delay the ticket add to main the same way.

Now only add the ticket if the plugin CAUSED the chunk load, so no longer
adds ticket if the chunk was already loaded.

Additionally, cap chunk ticket limits to 1 second (Effectively ignoring chunk-gc config
unless the config is lower than 20 ticks)

Fixes #3533
2020-06-09 21:15:36 -04:00
Luracasmus
b20529f3d3
Update to HTTPS in README (#3460)
Update URLs to HTTPS in README.md.
2020-06-09 04:12:43 -04:00
stonar96
de6dfedfef
Make Anti-Xray multithreaded (#3520)
Obfuscate multiple chunks at a time over the server thread pool.

Will speed up chunk processing when anti xray is enabled.

Co-authored-by: Aikar <aikar@aikar.co>
2020-06-09 04:12:20 -04:00
Aikar
531c4b3fd1
Add PluginTickets to API Chunk Methods
Like previous versions, plugins loading chunks kept them loaded until
they garbage collected to avoid constant spamming of chunk loads

This adds tickets to a few more places so that they can be unloaded.

Additionally, this drops their ticket level to BORDER so they wont be ticking
so they will just sit inactive instead.

Using .loadChunk to keep a chunk ticking was a horrible idea for upstream
when we have TWO methods that are able to do that already in the API.

Not adding it to .getType() though to keep behavior consistent with vanilla.
2020-06-09 03:43:11 -04:00
Aikar
b2d81e21c5
Improve Chunk Prioritization and Internal Scheduler
In previous MC versions, we had a rather simple internal scheduler
for delayed tasks that would just keep pushing task back until desired
tick was reached.

The method it called to schedule the task changed behavior in 1.14, and now
this scheduler is not working nowhere near what it was supposed to be doing.

This was causing long delayed task to eat up CPU (In Oversleep for example)

Rewrite this to just use the CraftScheduler for scheduling delayed tasks.

Once this was fixed, it became quite clear the code that delayed ticket
additions for chunks based on distance was clearly not right, as it was
tested on the previous broken logic.

So the ticket delay process has been vastly revamped to be even smarter.
Chunks behind the player can load slower than the chunks in front of the player.
We also can delay ticket adding until one of its neighbors has loaded, as
this lets us get a smoother spiral out for the chunks (minus frustum intent).

Additionally on frustum previous commit inadvertently broke frustum trying to
fix an issue when the real fix lied elsewhere, so restore chunk priority so
it works again.
2020-06-09 03:17:25 -04:00
Aikar
24a2e80431
Improve Login to use Urgent priority - improves login chunk load times 2020-06-08 21:47:39 -04:00
Aikar
9dfe1321d5
Delay Chunk Unloads based on Player Movement
When players are moving in the world, doing things such as building or exploring,
they will commonly go back and forth in a small area. This causes a ton of chunk load
and unload activity on the edge chunks of their view distance.

A simple back and forth movement in 6 blocks could spam a chunk to thrash a
loading and unload cycle over and over again.

This is very wasteful. This system introduces a delay of inactivity on a chunk
before it actually unloads, which will be handled by the ticket expiry process.

This allows servers with smaller worlds who do less long distance exploring to stop
wasting cpu cycles on saving/unloading/reloading chunks repeatedly.
2020-06-08 18:17:11 -04:00
Aikar
f0409edcd7
Drop Close region files patch, doesn't add any value.
Upon further knowledge of the system, it is known that region files
are closing properly, as well as this didn't help native memory use anyways.

This patch also caused issues compiling on a newer JDK being able to
release the jar to java 8 users.
2020-06-08 17:07:23 -04:00
Aikar
700070c5e6
Fix undesirable behavior around world level changes due to priority
priority tickets being added at 33 was hurting sync EMPTY and lesser requests.

this was likely the source of recent treasure map issues.

This then further hurt nether portal travel too. lots of oddness around.

This also avoids scheduling a level change on ticket removal when the level
is unchanged, as well as ditches CB's horrible change to not letting
you access an unloading chunk which should be valid to cancel the unload
2020-06-08 17:03:42 -04:00
Aikar
34e5942bf0
Fix timings task name generation for extreme cases - Fixes #3499
I'm going make a class, and in that class i'm going to
make a method. And in that method, I'm going to make a local class.

And then in that local class, I'm going to make another inner class.

I heard you like complex class trees.
2020-06-08 12:22:40 -04:00
Aikar
5e3bacbced
Ensure ThreadDeath propagates fully - Fixes #3521 2020-06-08 11:54:12 -04:00
Aikar
9fa6ba267c
Optimize Light Engine
Massive update to light to improve performance and chunk loading/generation.

1) Massive bit packing/unpacking optimizations and inlining.
  A lot of performance has to do with constant packing and unpacking of bits.
  We now inline a most bit operations, and re-use base x/y/z bits in many places.
  This helps with cpu level processing to just do all the math at once instead
  of having to jump in and out of function calls.

  This much logic also is likely over the JVM Inline limit for JIT too.
2) Applied a few of JellySquid's Phosphor mod optimizations such as
  - ensuring we don't notify neighbor chunks when neighbor chunk doesn't need to be notified
  - reduce hasLight checks in initializing light, and prob some more, they are tagged JellySquid where phosphor influence was used.
3) Optimize hot path accesses to getting updating chunk to have less branching
4) Optimize getBlock accesses to have less branching, and less unpacking
5) Have a separate urgent bucket for chunk light tasks. These tasks will always cut in line over non blocking light tasks.
6) Retain chunk priority while light tasks are enqueued. So if a task comes in at high priority but the queue is full
   of tasks already at a lower priority, before the task was simply added to the end. Now it can cut in line to the front.
   this applies for both urgent and non urgent tasks.
7) Buffer non urgent tasks even if queueUpdate is called multiple times to improve efficiency.
8) Fix NPE risk that crashes server in getting nibble data

Fixes #3489
Fixes #3363
2020-06-07 20:31:29 -04:00
Aikar
dfd3848ee6
Use seed based lookup for Treasure Maps - Fixes lag from carto/sunken maps 2020-06-07 19:28:58 -04:00
Aikar
74dcb3c923
Revert "Fix enchantment costs (#3519)"
This reverts commit 6d72ea1659.
2020-06-07 19:13:41 -04:00
Alexander
6d72ea1659
Fix enchantment costs (#3519) 2020-06-07 17:53:49 -04:00