Commit graph

1259 Commits

Autor SHA1 Nachricht Datum
Aikar
bbfb696f30
Avoid Chunk Lookups for Entity/TileEntity Current Chunk
In many places where we simply want the current chunk the entity
is in, instead of doing a hashmap lookup for it, we now have access
to the object directly on the Entity/TileEntity object we can directly grab.

Use that local value instead to reduce lookups in many hot places.
2018-07-04 03:58:56 -04:00
Aikar
18c3716c49
Current Chunk for Entity and Block Entities, counts by entity type
This enables us a fast reference to the entities current chunk instead
of having to look it up by hashmap lookups.

We also store counts by type to further enable other performance optimizations in later patches.
2018-07-04 03:58:56 -04:00
Aikar
f534210885
InventoryCloseEvent Reason API
Allows you to determine why an inventory was closed, enabling plugin developers
to "confirm" things based on if it was player triggered close or not.
2018-07-03 21:57:33 -04:00
Brokkonaut
e19ed02025
Add World.getEntity(UUID) API
This is the best way to get an entity when the world and its UUID are known.
It is faster than Server.getEntity(UUID) because it does not have to iterate all worlds
2018-07-03 14:53:28 -05:00
BillyGalbreath
8f1e26286f
Add config to disable ender dragon legacy check (#1167) 2018-07-03 14:48:54 -05:00
Brokkonaut
2ed792d699
Improve ProjectileHitEvent to include the BlockFace where the projectile has hit (#1182) 2018-07-03 14:34:42 -05:00
Shane Freeder
aedf167268
Cleanup allocated favicon ByteBuf (fixes #1191)
Cleanups a bytebuffer which was allocated during the encoding of the
favicon to be sent to the client.
2018-07-03 19:19:47 +01:00
Shane Freeder
a48b6064a8
Extend Player Interact cancellation to handle FlowerPots 2018-07-03 04:45:52 +01:00
Aikar
2adb879802
Add Critical missing Bukkit API - setTarget/getTarget moved down to SentientNPC
This fixes a CRITICAL missing part of the Bukkit API due to mistakes on upstream
refusing to implement the Sentient NPC baseclass of all NPC's.

Until now, the Bukkit API has not provided a way for accessing and setting
a non creature entities target.

Although Flying, Slime, Ambient, and Water mobs all supported targets internally,
you were unable to get/set it.

Now with the SentientNPC API and these API's moved down, every sentient NPC has
access to target data.
2018-07-01 22:10:21 -04:00
Aikar
b922ff9886
Fix issues with getBlockState(false) not loading Tile Entity data
This only impacted people who used our useSnapshots new API in a plugin,
which obviously was no one as the data result was completely broken.

Merged the NPE check patch into mine since it has to handle it too.
2018-06-30 01:40:52 -04:00
Aikar
98555e9b90
LivingEntity Hand Raised/Item Use API
How long an entity has raised hands to charge an attack or use an item

Also aliased isHandsRaised for isChargingAttack in RangedEntity
2018-06-29 00:55:29 -04:00
Aikar
7abf2eeeac
RangedEntity API
Allows you to determine if an entity is capable of ranged attacks,
and to perform an attack.
2018-06-26 22:08:01 -04:00
Minecrell
eb7341f821 Disable JLine event expansion. Fixes #1171 2018-06-25 17:40:35 +02:00
Aikar
f0cb089a24
Fix another case where villages load chunks 2018-06-21 22:58:09 -04:00
Aikar
9b1e9b43ff
Update Upstream 2018-06-20 23:29:33 -04:00
Aikar
980d53d156
Expand Explosions API
Add Entity as a Source capability, and add more API choices, and on Location.
2018-06-20 23:19:46 -04:00
Brokkonaut
a5285de480 Add EntityKnockbackByEntityEvent (#1162)
This event is called when an entity receives knockback by another entity. The knockback can be modified in the event. If the event is cancelled the entity is not knocked back.
2018-06-20 21:59:11 -04:00
Aikar
d5817e9910
Fire EntityShootBowEvent for Illusioner 2018-06-18 22:19:59 -04:00
Zach Brown
384059607e
Tie PlayerList#moveToWorld safety to existing config
Also renames patch file to better express what it's doing.

It is presumed that those using this config option intend for
suffocation checks to be disabled in all instances. In doing so, they
inherently assume the advantages and issues associated with removing
said safety check.

If the community expresses a desire for more specific options regarding
the handling of this safety feature, we can investigate providing them.

Fixes GH-1149
2018-06-18 16:27:33 -05:00
Aikar
c92fa14d36
PlayerReadyArrowEvent
Called when a player is firing a bow and the server is choosing an arrow to use.
Plugins can skip selection of certain arrows and control which is used.
2018-06-18 01:13:16 -04:00
Aikar
76d60b167f
EntityShootBowEvent consumeArrow and getArrowItem API
Adds ability to get what arrow was shot, and control if it should be consumed.
2018-06-18 00:39:04 -04:00
Aikar
9fee3b6963
accidently set the wrong collection on last commit
copy pasting...
2018-06-16 16:32:26 -04:00
Aikar
708d52ca03
Ignore Missing Recipes in RecipeBook to avoid data errors
This code was causing NPE's in saving player data, potentially related to reloads.
2018-06-16 16:30:29 -04:00
BillyGalbreath
1ae07ecf52 Make shield blocking delay configurable (#1154)
Resolves #1153
2018-06-16 15:54:35 -04:00
Aikar
4f29a0ce0a
Print Error details when failing to save player data 2018-06-15 20:40:39 -04:00
Aikar
50a23d5ea3
Configurable Alternative LootPool Luck Formula
Rewrites the Vanilla luck application formula so that luck can be
applied to items that do not have any quality defined.

See: https://luckformula.emc.gs for data and details
-----------

The rough summary is:
My goal was that in a pool, when luck was applied, the pool
rebalances so the percentages for bigger items is
lowered and smaller items is boosted.

Do this by boosting and then reducing the weight value,
so that larger numbers are penalized more than smaller numbers.
resulting in a larger reduction of entries for more common
items than the reduction on small weights,
giving smaller weights more of a chance

-----------

This work kind of obsoletes quality, but quality would be useful
for 2 items with same weight that you want luck to impact
in varying directions.

Fishing still falls into that as the weights are closer, so luck
will invalidate junk more.

This change will result in some major changes to fishing formulas.

-----------

I would love to see this change in Vanilla, so Mojang please pull :)
2018-06-15 00:32:35 -04:00
Aikar
1127a49ced
If we remove a corrupt TE, ensure we save the chunk 2018-06-15 00:11:39 -04:00
Black Hole
ea8801ce28 Actually call EntityTeleportEndGatewayEvent (#1147) 2018-06-13 16:29:49 -05:00
Brokkonaut
8b371226fb Avoid int overflow in lootable refill time calculations (#1146)
Fixes https://github.com/PaperMC/Paper/issues/1141
2018-06-13 14:15:31 -04:00
Shane Freeder
179439e48e
[CI-SKIP] Fix comment on unlit chunk sending patch 2018-06-12 15:46:08 +01:00
Aikar
84d350c24c
Fix CraftEntity hashCode
hashCodes are not allowed to change, however bukkit used a value
that does change, the entityId.

When an entity is teleported dimensions, the entity reference is
replaced with a new one with a new entity ID.

For hashCode, we can simply use the UUID's hashCode to keep
the hashCode from changing.

equals() is ok to use getEntityId() because equals() should only
be true if both the left and right are the same reference.

Since entity ids can not duplicate during runtime, this
check is essentially the same as this.getHandle() == other.getHandle()

However, replaced it too to make it clearer of intent.
2018-06-10 20:29:15 -04:00
Aikar
ca0ec24d64
Properly remove entities on dimension teleport
To teleport an entity between dimensions, the server makes a copy
and puts the copy in the new location, and marks the old one dead.

If this method got called for the same world in the same tick,
the entity would not have been removed from the UUID map, and the
world readd would fail.

This can be triggered even with a plugin if the entity is teleported
twice in the same tick, from world A to B, then back from B to A.

The re-add to A will fail to add the entity to the world. It will
actually be there, but it will not be visible on the client until
the server is restarted to re-try the add to world process again.

This bug was unlikely to be seen by many due to the double teleport
requirement, but plugins (such as my own) use this method to
trigger a "reload" of the entity on the client.
2018-06-10 20:09:56 -04:00
Shane Freeder
939ca17007
Fix missed change inside of CraftSkullMeta 2018-06-10 12:45:04 +01:00
Aikar
4fbed1adab
Unset Ignited flag on cancel of Explosion Event
Otherwise the creeper infinite explodes
2018-06-10 01:29:20 -04:00
Shane Freeder
5913a2cc1a
Add EntityTeleportEndGatewayEvent for entities (closes #1124) 2018-06-09 14:21:40 +01:00
Shane Freeder
ecc9347238
Allow plugins to replace texture if already set on skulls 2018-06-09 12:09:21 +01:00
Aikar
2e423c8954
ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item
2018-06-05 23:01:16 -04:00
Aikar
b97e5124e4
WitchReadyPotionEvent
Control what potion the witch readies to use
2018-06-05 22:48:48 -04:00
Aikar
1e3de9e936
Don't load chunks for villager door checks
This avoids villages spam loading chunks sync
2018-06-05 00:33:24 -04:00
Aikar
a082f773cb
Allow spawning Item entities with World.spawnEntity
This API has more capabilities than .dropItem with the Consumer function

Item can be set inside of the Consumer pre spawn function.
2018-06-04 20:48:14 -04:00
Kyle Wood
df8f9f0f30
Report issues to the issue tracker 2018-06-04 01:54:22 -05:00
Aikar
0570490d2a
Closes #1138 2018-06-04 01:54:38 -04:00
Aikar
727f932d05
add Escape Reason Drown for EndermanEscapeEvent
to detect rain specifically from every other armor ignoring hit
2018-05-31 18:16:26 -04:00
Zach Brown
7fea752ffc
Fix config key on last commit 2018-05-30 15:38:27 -05:00
Mark Vainomaa
e74e4584d6 Skip Entity and Tile Entity ticking in chunks scheduled for unload (#1132)
Fixes #1131
2018-05-30 15:31:55 -05:00
Aikar
3eb1cdef72
Fix Witch Throw Potion error - Resolves #1129 2018-05-23 23:08:04 -04:00
Aikar
340908d328
Fix Reason = Player for Experience Orb drop 2018-05-18 19:40:33 -04:00
Aikar
5e644e2637
WitchThrowPotionEvent
Fired when a witch throws a potion at a player
2018-05-16 20:49:47 -04:00
Aikar
dc7680211c
WitchConsumePotionEvent
Fires when a witch consumes the potion in their hand
2018-05-16 20:49:43 -04:00
Aikar
390f9bb913
Improve Profile API to directly extend Yggdrasil, Resolves #1117
This improves plugins like Citizens that rely on direct instance of Yggdrasil implementations.

Instead of wrapping, directly extend and override the methods.

Went ahead and wrapped all of the services in prep in the base patch, then features modify what they need
2018-05-10 23:01:52 -04:00
Zach
bd0335acaa
Merge pull request #1105 from stonar96/hotfix/anti-xray-cme
Fix Anti-Xray ConcurrentModificationException
2018-05-03 17:37:57 -04:00
Aikar
ef8ad1941f
fix inverted logic on enderman attack 2018-05-01 20:37:52 -04:00
Aikar
bd603371bf
EndermanAttackPlayerEvent
Allow control over whether or not an enderman aggros a player.

This allows you to override/extend the pumpkin/stare logic.
2018-05-01 20:19:47 -04:00
Aikar
f69fabeb55
Fix EndermanEscapeEvent RUNAWAY being cancelled should also keep target
This will allow you to keep the enderman attacking the player instead
of running away.
2018-05-01 17:03:12 -04:00
Aikar
00f24317ff
Expand World.spawnParticle API and add Builder
Adds ability to control who receives it and who is the source/sender (vanish API)
the standard API is to send the packet to everyone in the world, which is ineffecient.

This adds a new Builder API which is much friendlier to use.
2018-04-30 20:32:15 -04:00
Aikar
9c7cc4bfb2
Block Enderpearl Travel Exploit
Players are able to use alt accounts and enderpearls to travel
long distances utilizing the pearls in unloaded chunks and loading
the chunk later when convenient.

This disables that by not saving the thrower when the chunk is unloaded.

This is mainly useful for survival servers that do not allow freeform teleporting.
2018-04-30 17:23:58 -04:00
Aikar
d38e9dcf0e
Enderman.teleportRandomly()
Ability to trigger the vanilla "teleport randomly" mechanic of an enderman.
2018-04-30 13:30:00 -04:00
Aikar
30bc4df0a9
EndermanEscapeEvent
Fires an event anytime an enderman intends to teleport away from the player

You may cancel this, enabling ranged attacks to damage the enderman for example.

Resolves #1101
2018-04-30 13:16:42 -04:00
stonar96
fba6addb82 Fix Anti-Xray ConcurrentModificationException 2018-04-30 15:21:07 +02:00
0x22
f7166948d8
Fix exploit that allowed colored signs to be created (#1098) 2018-04-28 20:19:29 +01:00
Aikar
33a6de0f13
Add Ban Methods to Player Objects
Allows a more logical API for banning players.

player.banPlayer("Breaking the rules");
2018-04-28 11:31:26 -04:00
Zach Brown
2120696fcf
Remove patches that got added back in merge
Fix build
2018-04-22 15:29:03 -04:00
stonar96
3340e81425 Make Anti-Xray Update Radius configurable (#1094) 2018-04-22 10:45:56 -04:00
Aikar
4316e8f59d
Configurable Allowance of Permanent Chunk Loaders
This disables the behavior that allows players to keep chunks permanently loaded
by default and allows server operators to enable it if they wish.
2018-04-22 10:40:49 -04:00
Aikar
a72fc26fc1
Update upstream 2018-04-22 10:40:36 -04:00
Brokkonaut
a144c203fc Configurable sprint interruption on attack (#1085)
If the sprint interruption is disabled players continue sprinting when they attack entities.
2018-04-18 09:46:48 -04:00
Shane Freeder
bacc2bbec0
re-revert Better reloading of pending unload chunks 2018-04-18 13:03:59 +01:00
Aikar
bbc31e2bd8
Revert SPIGOT-3894 to restore vanilla behavior
reporter of this issue was incorrect and did not verify vanilla logic

vanilla logic only skips ticks if the flag is set

spigots change causes bugs as it now skips ticking and processing
chunk teleportation, which was a bug I fixed many many years ago...
2018-04-18 01:44:24 -04:00
Zach Brown
d49c6a296e
Update upstream CB/S 2018-04-17 22:25:50 -04:00
Zach Brown
52befd0a68
Be more specific with prior fix 2018-04-17 22:06:24 -04:00
Zach Brown
e1c412846a
Handle bad chunks more gracefully
Prior to this change the server would crash when attempting to load a
chunk from a region with bad data.

After this change the server will defer back to vanilla behavior. At
this time, that means attempting to generate a chunk in its place
(and occasionally just not generating anything and leaving small
holes in the world).

Should Mojang choose to alter this behavior in the future, this change
will simply defer to whatever that new behavior is.
2018-04-17 22:00:51 -04:00
Kyle Wood
35b4136815
Track previous version and report in command
It is often difficult to diagnose new issues server admins get when
upgrading to a new server version because the only information they are
able to tell us regarding the server version they are running is
"latest". This commit attempts to mitigate this by keeping track of the
previous version of Paper they were running, which is then reported by
the `/version` or `/paper version` command. This gives us a better idea
of the commits included in the upgrade, which may help diagnose new
issues easier.
2018-04-11 23:02:20 -04:00
Aikar
dc772289f8
Fix profile requests being made on offline mode servers
Closes #1076
2018-04-08 12:28:04 -04:00
Shane Freeder
8cca54c0e3
remove warning for custom entities in precreaturespawn (closes #1069)
There can be no survivors.
2018-04-08 01:44:14 +01:00
Shane Freeder
280e8b14ca
revert "Better reloading of pending unload chunks"
This change by spigot ensures that many interactins with chunks,
e.g. getting a list of TEs will cause the chunk to be marked for not
unloading and will block their unload. This is especially true for
servers using Timings (it needs to access the TE list of chunks), or
any plugins which need to access entity/TE lists periodically.
2018-04-08 01:26:37 +01:00
Mark Vainomaa
c6ac33816b
Add method to open already placed sign 2018-04-05 06:48:24 +03:00
Zach Brown
c178b3931a
Update upstream CB 2018-04-04 21:05:09 -04:00
Zach Brown
4e98da175b
Silly rabbits, eggs are for chickens 2018-04-02 16:30:24 -04:00
Zach Brown
594b647cce
> not even using java8 time API
Gotta get this rocketship up to speed I guess...
2018-03-31 23:30:19 -04:00
Zach Brown
5bad6ba5b6
Easter and April Fools fall on the same day
¯\_(ツ)_/¯
2018-03-31 22:50:11 -04:00
Zach Brown
6f2009754d
Stop explicitly blocking Vanilla Method Profiler
At the time this was re-added, there was concern around how the JIT
would handle the system property that enabled it.

This shouldn't be a problem, and as such we no longer need to block
access to it.

The Vanilla Method Profiler will not provide much to most users however
there is no harm in providing it as an option. For most users, the
recommended and supported method for determining performance issues with
Paper will continue to be Timings.
2018-03-31 14:55:42 -04:00
Shane Freeder
d09826faf2
Flag to disable the channel limit
In some enviroments, the channel limit set by spigot can cause issues,
e.g. servers which allow and support the usage of mod packs.

provide an optional flag to disable this check, at your own risk.
2018-03-31 18:56:49 +01:00
Shane Freeder
ad2cf784b0
Delay initial ping sent to the client 2018-03-31 15:27:41 +01:00
Shane Freeder
fad15a6acc
Update CB/S 2018-03-31 14:30:29 +01:00
Minecrell
16869992a8 Call PaperServerListPingEvent for legacy pings (#1057)
* Make the legacy ping handler more reliable

The Minecraft server often fails to respond to old ("legacy") pings
from old Minecraft versions using the protocol used before the switch
to Netty in Minecraft 1.7.

Due to packet fragmentation[1], we might not have all needed bytes
available when the LegacyPingHandler is called. In this case, it will
run into an error, remove the handler and continue using the modern
protocol.

This is unlikely to happen for the first two revisions of the legacy
ping protocol (used in Minecraft 1.5.x and older) since the request
consists of only one or two bytes, but happens frequently for the
last/third revision introduced in Minecraft 1.6.

It has much larger, variable packet sizes due to the inclusion of
the virtual host (the hostname/port used to connect to the server).

The solution[2] is simple: If we find more than two matching bytes,
we buffer the remaining bytes until we have enough to fully read and
respond to the request.

[1]: https://netty.io/wiki/user-guide-for-4.x.html#wiki-h3-11
[2]: https://netty.io/wiki/user-guide-for-4.x.html#wiki-h4-13

* Add legacy ping support to PaperServerListPingEvent

Add a new method to StatusClient check if the client is a legacy
client that does not support all of the features provided in the
event.
2018-03-30 13:00:01 -04:00
Minecrell
604192da0c Avoid negative server ping player sample counts. Fixes #1067 (#1068) 2018-03-30 12:53:15 -04:00
Mark Vainomaa
aa6c4f29fd Make player data saving configurable (#1063) 2018-03-27 10:45:54 -04:00
Aikar
658eca0c22
Add Setters for ID/Name and add completeByCache for Profile API 2018-03-25 21:50:46 -04:00
Aikar
9b12f54b69
Update upstream 2018-03-25 20:06:44 -04:00
Aikar
c00a8a7a2b
Don't try to complete profile on creation from cache, only on complete()
For one, the wrong API was used that would trigger a network call.
2018-03-25 20:05:30 -04:00
Aikar
cff8ae9644
Use copies for PlayerProfile in PaperServerList and SkullMeta
Don't want to risk mutating players properties in server list (unlikely, but lets be proper)

and Skull also has a setter API, so that should be used too.
2018-03-22 23:32:55 -04:00
Minecrell
e15167251b Add extended PaperServerListPingEvent (#980)
* Drop original implementation for old player sample API

* Add extended PaperServerListPingEvent

Add a new event that extends the original ServerListPingEvent
and allows full control of the response sent to the client.

* Implement deprecated player sample API
2018-03-22 23:19:59 -04:00
Aikar
3f4fa0e839
More improvements to PlayerProfile code
.equals() was wrong
clean up createPlayerProfile code
don't set profile to null if the complete call fails
2018-03-22 21:57:11 -04:00
Aikar
b8a672dd94
Fix Profile Textures and expand PlayerProfile .complete() API
I mistakenly thought .complete() also checked for textures, which was not the case

So the logic was not working as desired.

Also some undesired logic paths lead to textures of the logging in player being dropped, forcing
us to always load the textures immediately again on login, leading to rate limits.

Everythings now good

the .complete() api now will default specify to also complete textures, but you may
pass false to it to skip loading textures.
2018-03-22 21:40:57 -04:00
Aikar
b29f5c05c1
getPlayerUniqueId API
Gets the unique ID of the player currently known as the specified player name
In Offline Mode, will return an Offline UUID

This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer
2018-03-22 01:41:44 -04:00
Aikar
b63ac711e0
Check Profile Cache for PlayerProfile API
This ensures we look up the name for ID only Profiles

If the profile is in the UserCache, we can get those details quickly

This should avoid some unnecessary round trips.

Additionally, handle profiles for offline mode to use offline UUID's
2018-03-22 01:28:22 -04:00
Aikar
75640df894
Fix Dragon Server Crashes
If the dragon tries to find "ground" and hits a hole, or off edge,
it will infinitely keep looking for non air and eventually crash.
2018-03-21 20:55:46 -04:00
Aikar
fd54eb21e9
Configurable Unrestricted Signs - Resolves #1054
Bukkit restricts command execution of signs to test if the sender
has permission to run the specified command. This breaks vanilla
maps that use signs to intentionally run as elevated permission.

Bukkit provides an unrestricted advancements setting, so this setting
compliments that one and allows for unrestricted signs.

We still filter sign update packets to strip out commands at edit phase,
however there is no sanity in ever expecting creative mode to not be
able to create signs with any command.

Creative servers should absolutely never enable this.
Non creative servers, enable at own risk!!!
2018-03-21 19:59:54 -04:00
Aikar
723109fa84
Only complete incomplete profiles - Resolves #1053 2018-03-21 19:12:02 -04:00
MiniDigger
9aa5d9ec9b Call PortalCreateEvent for exit portals (#1047) 2018-03-20 14:56:44 -04:00