Commit graph

238 commits

Author SHA1 Message Date
Shane Freeder
88409ad861 Break up and make tab spam limits configurable
Due to the changes in 1.13, clients will send a tab completion request
for all bukkit commands in order to factor in the lack of support for
brigadier and provide backwards support in the API.

Craftbukkit, however; has moved the chat spam limiter to also interact
with the tab completion request, which while good for avoiding abuse,
causes 1.13 clients to easilly be kicked from a server in bukkit due
to this. Removing the spam limit could cause issues for servers, however,
there is no way for servers to manipulate this without blindly cancelling
kick events, which only causes additional complications. This also causes
issues in that the tab spam limit and chat share the same field but different
limits, meaning that a player having typed a long command may be kicked from
the server.

Splitting the field up and making it configurable allows for server owners
to take the burden of this into their own hand without having to rely on
plugins doing unsafe things.
2018-07-29 05:02:15 +01:00
Mark Vainomaa
30f16143ba Add TNTPrimeEvent 2018-07-16 00:05:05 +03:00
BillyGalbreath
f20fbf5477 AnvilDamageEvent 2018-07-20 23:37:03 -05:00
BillyGalbreath
da011362dc SkeletonHorse Additions 2018-07-27 22:36:31 -05:00
Riley Park
c0a3a0d12c Allow disabling armor stand ticking 2018-08-15 01:26:09 -07:00
Hugo Manrique
510b8187c7 Vanished players don't have rights 2018-07-23 14:22:26 +02:00
Hugo Manrique
1549b076df Option to prevent armor stands from doing entity lookups 2018-07-23 12:57:39 +02:00
Techcable
85be8cc620 Improve BlockPosition inlining
Normally the JVM can inline virtual getters by having two sets of code, one is the 'optimized' code and the other is the 'deoptimized' code.
If a single type is used 99% of the time, then its worth it to inline, and to revert to 'deoptimized' the 1% of the time we encounter other types.
But if two types are encountered commonly, then the JVM can't inline them both, and the call overhead remains.

This scenario also occurs with BlockPos and MutableBlockPos.
The variables in BlockPos are final, so MutableBlockPos can't modify them.
MutableBlockPos fixes this by adding custom mutable variables, and overriding the getters to access them.

This approach with utility methods that operate on MutableBlockPos and BlockPos.
Specific examples are BlockPosition.up(), and World.isValidLocation().
It makes these simple methods much slower than they need to be.

This should result in an across the board speedup in anything that accesses blocks or does logic with positions.

This is based upon conclusions drawn from inspecting the assenmbly generated bythe JIT compiler on my microbenchmarks.
They had 'callq' (invoke) instead of 'mov' (get from memory) instructions.
2016-11-30 20:56:58 -06:00
BillyGalbreath
925d397466 PlayerLaunchProjectileEvent 2018-07-21 03:11:03 -05:00
BillyGalbreath
a949eef7aa PlayerElytraBoostEvent 2018-07-21 01:59:59 -05:00
BillyGalbreath
e054d501fb EnderDragon Events 2018-07-21 01:51:27 -05:00
Aikar
eb528f5f37 add more information to Entity.toString()
UUID, ticks lived, valid, dead
2018-07-19 01:13:28 -04:00
Aikar
3430a002d1 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:56:23 -04:00
BillyGalbreath
b7f23ee86d Add config to disable ender dragon legacy check 2018-06-22 10:38:31 -05:00
Aikar
dddd41ac34 Expand Explosions API
Add Entity as a Source capability, and add more API choices, and on Location.

Co-authored-by: Esoteric Enderman <90862990+EsotericEnderman@users.noreply.github.com>
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
2018-06-20 23:17:24 -04:00
Brokkonaut
991875920d Add entity knockback events
- EntityKnockbackEvent
- EntityPushedByEntityAttackEvent
- EntityKnockbackByEntityEvent

Co-authored-by: aerulion <aerulion@gmail.com>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
2018-06-18 15:46:23 +02:00
Aikar
d68fcd321f 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:12:53 -04:00
Aikar
26ade76848 Improve EntityShootBowEvent
Adds missing call to Illagers and also adds Arrow ItemStack to skeletons

== AT ==
public net.minecraft.world.entity.projectile.AbstractArrow getPickupItem()Lnet.minecraft.world.item.ItemStack;
2013-06-15 19:51:17 -04:00
BillyGalbreath
2d9d74f9a9 Make shield blocking delay configurable 2018-06-16 01:18:16 -05:00
Aikar
4ec0188c4d Print Error details when failing to save player data 2018-06-15 20:37:03 -04:00
Aikar
d50334d6e8 Configurable 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:30:32 -04:00
Aikar
809fa1fbea Unset Ignited flag on cancel of Explosion Event
Otherwise the creeper infinite explodes
2018-06-10 01:18:49 -04:00
Shane Freeder
d6d2d75fe6 Add EntityTeleportEndGatewayEvent 2018-06-09 14:08:39 +02:00
Aikar
b64e7f96d3 WitchReadyPotionEvent 2018-06-05 22:47:26 -04:00
Aikar
a3b5f969ed WitchThrowPotionEvent
Fired when a witch throws a potion at a player
2018-05-16 20:44:58 -04:00
Aikar
72743537f4 WitchConsumePotionEvent
Fires when a witch consumes the potion in their hand
2018-05-16 20:35:16 -04:00
Aikar
40e2712d61 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:18:54 -04:00
0x22
952a6d631c Fix exploit that allowed colored signs to be created 2018-04-26 04:41:11 -04:00
Aikar
634b639098 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.
Adds an option to control the force mode of the particle.

This adds a new Builder API which is much friendlier to use.
2017-08-15 22:29:12 -04:00
Aikar
b4ece1619f 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.
2018-04-30 13:15:55 -04:00
Brokkonaut
5a528af05e Configurable sprint interruption on attack
If the sprint interruption is disabled players continue sprinting when they attack entities.
2018-04-14 20:20:46 +02:00
Minecrell
0511551203 Call PaperServerListPingEvent for legacy pings 2017-10-11 19:30:51 +02:00
Minecrell
361fc3ab43 Make 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
2017-10-11 18:22:50 +02:00
Aikar
d0d0b1a21e Player.setPlayerProfile API
This can be useful for changing name or skins after a player has logged in.

== AT ==
public-f net.minecraft.world.entity.player.Player gameProfile
2018-03-18 12:29:48 -04:00
Aikar
5fb78725e4 Add more fields to AsyncPreLoginEvent
Co-authored-by: Connor Linfoot <connorlinfoot@me.com>
Co-authored-by: MCMDEV <john-m.1@gmx.de>
2018-03-18 11:45:57 -04:00
Minecrell
ac0c06a72f Implement extended PaperServerListPingEvent 2017-10-11 15:56:26 +02:00
Aikar
a7bc7ca33a Disable Explicit Network Manager Flushing
This seems completely pointless, as packet dispatch uses .writeAndFlush.

Things seem to work fine without explicit flushing, but incase issues arise,
provide a System property to re-enable it using improved logic of doing the
flushing on the netty event loop, so it won't do the flush on the main thread.

Renable flushing by passing -Dpaper.explicit-flush=true
2018-03-11 14:13:33 -04:00
MiniDigger | Martin
b9319698ce Toggleable player crits 2018-03-10 00:50:24 +01:00
Shane Freeder
794fc9799b Extend Player Interact cancellation
GUIs are opened on the client, meaning that the server cannot block them from opening,
However, it is possible to close these GUIs from the server.

Flower pots are also not updated on the client when interaction is cancelled, this patch
also resolves this.
2018-02-11 10:43:46 +00:00
BillyGalbreath
ec3ae43c82 Add PlayerAdvancementCriterionGrantEvent 2018-01-19 08:15:29 -06:00
Aikar
4f248b1b5b Fill Profile Property Events
Allows plugins to populate profile properties from local sources to avoid calls out to Mojang API
to fill in textures for example.

If Mojang API does need to be hit, event fire so you can get the results.

This is useful for implementing a ProfileCache for Player Skulls
2018-01-02 00:31:26 -05:00
Aikar
cad0c129c8 PreCreatureSpawnEvent
Adds an event to fire before an Entity is created, so that plugins that need to cancel
CreatureSpawnEvent can do so from this event instead.

Cancelling CreatureSpawnEvent rapidly causes a lot of garbage collection and CPU waste
as it's done after the Entity object has been fully created.

Mob Limiting plugins and blanket "ban this type of monster" plugins should use this event
instead and save a lot of server resources.

See: https://github.com/PaperMC/Paper/issues/917
2018-01-14 17:01:31 -05:00
Aikar
f249b1f39a PlayerNaturallySpawnCreaturesEvent
This event can be used for when you want to exclude a certain player
from triggering monster spawns on a server.

Also a highly more effecient way to blanket block spawns in a world
2018-01-14 17:36:02 -05:00
Aikar
533b86c3fc PlayerPickupExperienceEvent
Allows plugins to cancel a player picking up an experience orb
2017-12-19 22:02:53 -05:00
Jason Penilla
ed76af5637 AsyncTabCompleteEvent
Let plugins be able to control tab completion of commands and chat async.

This will be useful for frameworks like ACF so we can define async safe completion handlers,
and avoid going to main for tab completions.

Especially useful if you need to query a database in order to obtain the results for tab
completion, such as offline players.

Also adds isCommand and getLocation to the sync TabCompleteEvent

Co-authored-by: Aikar <aikar@aikar.co>
2017-11-26 13:19:58 -05:00
Aikar
eb20b0b160 API to get a BlockState without a snapshot
This allows you to get a BlockState without creating a snapshot, operating
on the real tile entity.

This is useful for where performance is needed

also Avoid NPE during CraftBlockEntityState load if could not get TE

If Tile Entity was null, correct Sign to return empty lines instead of null
2017-11-06 21:08:22 -05:00
Shane Freeder
1d1c5a4493 use CB BlockState implementations for captured blocks
When modifying the world, CB will store a copy of the affected
blocks in order to restore their state in the case that the event
is cancelled. This change only modifies the collection of blocks
in the world by normal means, e.g. not during tree population,
as the potentially marginal overheads would serve no advantage.

CB was using a CraftBlockState for all blocks, which causes issues
should any block that uses information beyond a data ID would suffer
from missing information, e.g. Skulls.

By using CBs CraftBlock#getState(), we will maintain a proper copy of
the blockstate that will be valid for restoration, as opposed to dropping
information on restoration when the event is cancelled.
2017-11-16 12:12:41 +00:00
mezz
f1fd83ac7a Fix MC-117075: Block entity unload lag spike 2017-08-09 17:51:22 -05:00
killme
3ce6b37e05 Prevent logins from being processed when the player has disconnected 2017-11-12 19:40:01 +01:00
pkt77
540274bcf2 Add PlayerArmorChangeEvent 2017-11-10 23:46:34 -05:00