mirror of
https://github.com/PaperMC/Paper.git
synced 2026-11-04 17:00:09 -05:00
Compare commits
350
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38629ec417 | ||
|
|
60a9219865 | ||
|
|
e7e1b7cb5f | ||
|
|
d37761f49e | ||
|
|
0632270abf | ||
|
|
fbd7278bdf | ||
|
|
6e16c8151b | ||
|
|
a4d07733b8 | ||
|
|
dad36a346f | ||
|
|
7dbd040210 | ||
|
|
7b644639cd | ||
|
|
98d6d87a16 | ||
|
|
ea5e5b5bd0 | ||
|
|
cc87ccebf7 | ||
|
|
f8416f2239 | ||
|
|
219b5bd3eb | ||
|
|
e16ebd9768 | ||
|
|
eef9f9e154 | ||
|
|
49a6b6ee0b | ||
|
|
12e436e573 | ||
|
|
10c3643761 | ||
|
|
9c2cd19913 | ||
|
|
7042f13970 | ||
|
|
406b868e5d | ||
|
|
3d3dcf6444 | ||
|
|
785c0c648f | ||
|
|
c3d089fc38 | ||
|
|
ed9942f6d6 | ||
|
|
e4adac7336 | ||
|
|
0649158c70 | ||
|
|
2eee472f72 | ||
|
|
53aab5e3c4 | ||
|
|
e7c3732ea5 | ||
|
|
8274d6f563 | ||
|
|
faf117a93e | ||
|
|
516877f477 | ||
|
|
180a25d1d0 | ||
|
|
8ac694005a | ||
|
|
f548f4a1b0 | ||
|
|
9315b6d156 | ||
|
|
bc8858c361 | ||
|
|
1c8cc4a916 | ||
|
|
e9d5ddc150 | ||
|
|
1ea8e08ebc | ||
|
|
f4a6a3b885 | ||
|
|
5929ed63cf | ||
|
|
d34638c755 | ||
|
|
e1a0397dc4 | ||
|
|
8d197ba4b0 | ||
|
|
9280bf27fc | ||
|
|
8b9e4c7d11 | ||
|
|
6979dced5c | ||
|
|
9f893d1e66 | ||
|
|
4bbe75753c | ||
|
|
2716922383 | ||
|
|
7f785a3516 | ||
|
|
3a0407500e | ||
|
|
6b56630859 | ||
|
|
589ad52e5a | ||
|
|
c2f1b0a55f | ||
|
|
f8f320e70a | ||
|
|
aa37ad776e | ||
|
|
f839cf8d84 | ||
|
|
4d489d4a8a | ||
|
|
dd4cb61c69 | ||
|
|
f9e2023bfe | ||
|
|
af984540ba | ||
|
|
d7129a5013 | ||
|
|
b70c43c16f | ||
|
|
c1d911c16c | ||
|
|
bab72db6b1 | ||
|
|
a3ba87b29f | ||
|
|
5e10df70d3 | ||
|
|
a5efe6f6f2 | ||
|
|
0612615a18 | ||
|
|
e57fcce61c | ||
|
|
13550ba3ae | ||
|
|
0db5f0903e | ||
|
|
25629f4de5 | ||
|
|
0928b20314 | ||
|
|
aa96be2bc1 | ||
|
|
384a710167 | ||
|
|
e2cf03e706 | ||
|
|
b3830b76c1 | ||
|
|
079cf7d9a7 | ||
|
|
22a19181cf | ||
|
|
23fd92d0c0 | ||
|
|
b7a1169d30 | ||
|
|
dceff8335f | ||
|
|
7dc84166a9 | ||
|
|
43c85ccd53 | ||
|
|
c1ede62295 | ||
|
|
91dd0214f1 | ||
|
|
2a212eae42 | ||
|
|
216a4161be | ||
|
|
9e1b9fbcea | ||
|
|
be05c0e24f | ||
|
|
656dc56043 | ||
|
|
1f8591a410 | ||
|
|
d68dc0715f | ||
|
|
752c303be1 | ||
|
|
51e1e63319 | ||
|
|
7c446e0139 | ||
|
|
e68c701528 | ||
|
|
34cfa23fc0 | ||
|
|
33d7d349f5 | ||
|
|
4aeb33a5f4 | ||
|
|
4fa9499a24 | ||
|
|
646a873602 | ||
|
|
14979ac517 | ||
|
|
6b29c52a33 | ||
|
|
8c1e7b4a57 | ||
|
|
115d5e64e7 | ||
|
|
2b3b6f3b66 | ||
|
|
b99b095b61 | ||
|
|
2260daa8b3 | ||
|
|
b54f99c244 | ||
|
|
cdbe56ff29 | ||
|
|
beee07f89a | ||
|
|
d0d617a535 | ||
|
|
18f1aa712b | ||
|
|
255179b4b2 | ||
|
|
70ad50b387 | ||
|
|
bf5aba7260 | ||
|
|
cabe9db92e | ||
|
|
cedb1ffa64 | ||
|
|
4204a93ca6 | ||
|
|
a4c450a160 | ||
|
|
90a79f22e1 | ||
|
|
7e5a257553 | ||
|
|
6c79add3e3 | ||
|
|
32f8feb7e4 | ||
|
|
20d64c1f42 | ||
|
|
9be6bb009a | ||
|
|
c056b0a07e | ||
|
|
668dcda9de | ||
|
|
ce579b4e2c | ||
|
|
876b4d7a1a | ||
|
|
250178eaf0 | ||
|
|
8192c9f575 | ||
|
|
97823725ce | ||
|
|
0c0257254e | ||
|
|
740bb04269 | ||
|
|
9bcddac82d | ||
|
|
0dd5fad8a6 | ||
|
|
e8d93523e2 | ||
|
|
5ddb6833ff | ||
|
|
3132f2929e | ||
|
|
01d37292a2 | ||
|
|
871c14c6be | ||
|
|
6ef75d43cc | ||
|
|
e0fc7eb9bd | ||
|
|
9511306ca9 | ||
|
|
585df25333 | ||
|
|
b067ecf46e | ||
|
|
459f0860a1 | ||
|
|
367148200f | ||
|
|
fbf971617c | ||
|
|
7ec5986da1 | ||
|
|
c7d1b23b93 | ||
|
|
4b0e3109d7 | ||
|
|
aca9668964 | ||
|
|
6bb6a909a7 | ||
|
|
3264ac58e3 | ||
|
|
b49a41efb7 | ||
|
|
df04cb69ba | ||
|
|
ebfe21e2ca | ||
|
|
db422ee9af | ||
|
|
18e2c24e05 | ||
|
|
7187fdf465 | ||
|
|
c8bd70a838 | ||
|
|
d873174c2a | ||
|
|
8936ac3735 | ||
|
|
155f855959 | ||
|
|
8bfe75dc01 | ||
|
|
70c7b5dee5 | ||
|
|
508e4166f3 | ||
|
|
1e91d1224a | ||
|
|
cdb4f991f6 | ||
|
|
9808091bcf | ||
|
|
1e3d010778 | ||
|
|
f1fed860c5 | ||
|
|
fabbf136a9 | ||
|
|
a741d5a060 | ||
|
|
db56b19f86 | ||
|
|
f616414eb7 | ||
|
|
8314f898e6 | ||
|
|
af57d9efae | ||
|
|
df49621e76 | ||
|
|
cd1d929399 | ||
|
|
24194f2704 | ||
|
|
05be2f2430 | ||
|
|
68dc428d44 | ||
|
|
28c8b952ee | ||
|
|
59dbce1176 | ||
|
|
463a9a0348 | ||
|
|
9cbb166ef7 | ||
|
|
b68aeef916 | ||
|
|
1765f064a7 | ||
|
|
abf24dfac1 | ||
|
|
a234ecc775 | ||
|
|
35b21193e0 | ||
|
|
f562d238d2 | ||
|
|
1e161152b9 | ||
|
|
6e54f73d74 | ||
|
|
95ef9c22fb | ||
|
|
dcad5fa99e | ||
|
|
e6c0ba7646 | ||
|
|
1cda896417 | ||
|
|
5c99a97dac | ||
|
|
ad0d113da0 | ||
|
|
ff4a2ca564 | ||
|
|
be5b215be2 | ||
|
|
655ea8288a | ||
|
|
6d1bd949aa | ||
|
|
5093290edf | ||
|
|
b4d418c073 | ||
|
|
1a74b81716 | ||
|
|
a3d9ae13f3 | ||
|
|
1dbf8f9f46 | ||
|
|
fa4d547a35 | ||
|
|
bb7122b480 | ||
|
|
4dc7c308b0 | ||
|
|
7a1dbc123f | ||
|
|
e8df304884 | ||
|
|
03f3ece1b9 | ||
|
|
5c92b1a8d7 | ||
|
|
495fae1784 | ||
|
|
e94e49b5a7 | ||
|
|
dc9c3ce64d | ||
|
|
fc940f8f37 | ||
|
|
7b3f232e79 | ||
|
|
32aa346546 | ||
|
|
cfa232a0a7 | ||
|
|
65ae2ca9b0 | ||
|
|
46da35f1ab | ||
|
|
9c8387b5bd | ||
|
|
eeec638538 | ||
|
|
366a375afe | ||
|
|
a71878ebe5 | ||
|
|
21bb7dff80 | ||
|
|
55f8938768 | ||
|
|
c5093c5d12 | ||
|
|
368f22e290 | ||
|
|
65806e018a | ||
|
|
625a963b4d | ||
|
|
81cc5be9a0 | ||
|
|
dc245be340 | ||
|
|
a38201bc4b | ||
|
|
e2b0e61aa6 | ||
|
|
05201926f0 | ||
|
|
b5b202a09a | ||
|
|
7d27d0363e | ||
|
|
ef47cbcb48 | ||
|
|
0d46683855 | ||
|
|
cca983b5fe | ||
|
|
5e3602a300 | ||
|
|
e65954bdfd | ||
|
|
296afa8d33 | ||
|
|
d4a834c37b | ||
|
|
d64d779359 | ||
|
|
08d65a7618 | ||
|
|
5f48209795 | ||
|
|
e18d894a1b | ||
|
|
c32bbc64a7 | ||
|
|
2417fcf770 | ||
|
|
f69babca92 | ||
|
|
e329288e71 | ||
|
|
f6e5d12043 | ||
|
|
349954c88b | ||
|
|
590797a8b8 | ||
|
|
396665c697 | ||
|
|
f968ceb56f | ||
|
|
100bb1a330 | ||
|
|
35d737d013 | ||
|
|
b203c309ee | ||
|
|
ffc30dfe41 | ||
|
|
fb208e8c1f | ||
|
|
7ae1e99865 | ||
|
|
7ce8db084a | ||
|
|
ae74a09461 | ||
|
|
51ed87cf57 | ||
|
|
cc5518feeb | ||
|
|
c905812e71 | ||
|
|
a8166bcff5 | ||
|
|
0895fec3d6 | ||
|
|
4e9ce25dcd | ||
|
|
6e9c581a7a | ||
|
|
77a605370d | ||
|
|
4f7d947fa9 | ||
|
|
504dbab8a3 | ||
|
|
bd3f8c5099 | ||
|
|
8732f8d6ee | ||
|
|
6e64b30d0b | ||
|
|
2523a86612 | ||
|
|
ec6b7510ca | ||
|
|
3a97aae601 | ||
|
|
1161288346 | ||
|
|
665db9d5d4 | ||
|
|
bdfdb298b4 | ||
|
|
3a2aa6fa9b | ||
|
|
f0c9d7c46a | ||
|
|
2cb6460c5d | ||
|
|
7964a7dd34 | ||
|
|
f708170b5d | ||
|
|
cd57a8ce55 | ||
|
|
ea7bc08754 | ||
|
|
759c949dfc | ||
|
|
89bf3b791c | ||
|
|
8f2362d544 | ||
|
|
a741a0f8bd | ||
|
|
6630607358 | ||
|
|
1b1d891f1e | ||
|
|
7fbde83842 | ||
|
|
900a47f4e8 | ||
|
|
ce5255d6a4 | ||
|
|
b388f0dc0a | ||
|
|
3dc7a8ae4c | ||
|
|
cf6bf97b43 | ||
|
|
85f4d46701 | ||
|
|
6cb9e3318f | ||
|
|
7107732cb6 | ||
|
|
f6f8f4ff77 | ||
|
|
024b97d466 | ||
|
|
0a39f88496 | ||
|
|
858b72c074 | ||
|
|
7e9f5647f3 | ||
|
|
8ac44842d5 | ||
|
|
aec560ee7b | ||
|
|
6062382779 | ||
|
|
d04a432231 | ||
|
|
c647a6318a | ||
|
|
ea2b4c2b7d | ||
|
|
18b128ae31 | ||
|
|
76154a0188 | ||
|
|
a7d3dc626e | ||
|
|
e6540faed8 | ||
|
|
2150f1193e | ||
|
|
ca5529b139 | ||
|
|
3a3021b52a | ||
|
|
660f5ea092 | ||
|
|
e2f9e92286 | ||
|
|
eca438aed3 | ||
|
|
0dbcc07d4d | ||
|
|
b86e74cd5b | ||
|
|
196dae383f | ||
|
|
ae640407cf | ||
|
|
8b16616b81 | ||
|
|
fe5da06d79 | ||
|
|
2c83fb4cbc |
No files matched your search
+12
-53
@@ -6,96 +6,55 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.inventory.InventoryEvent;
|
||||
import org.bukkit.inventory.AnvilInventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when an anvil is damaged from being used
|
||||
*/
|
||||
@NullMarked
|
||||
public class AnvilDamagedEvent extends InventoryEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private DamageState damageState;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AnvilDamagedEvent(final InventoryView inventory, final @Nullable BlockData blockData) {
|
||||
super(inventory);
|
||||
this.damageState = DamageState.getState(blockData);
|
||||
}
|
||||
public interface AnvilDamagedEvent extends InventoryEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public AnvilInventory getInventory() {
|
||||
return (AnvilInventory) super.getInventory();
|
||||
}
|
||||
AnvilInventory getInventory();
|
||||
|
||||
/**
|
||||
* Gets the new state of damage on the anvil
|
||||
*
|
||||
* @return Damage state
|
||||
*/
|
||||
public DamageState getDamageState() {
|
||||
return this.damageState;
|
||||
}
|
||||
DamageState getDamageState();
|
||||
|
||||
/**
|
||||
* Sets the new state of damage on the anvil
|
||||
*
|
||||
* @param damageState Damage state
|
||||
*/
|
||||
public void setDamageState(final DamageState damageState) {
|
||||
this.damageState = damageState;
|
||||
}
|
||||
void setDamageState(DamageState damageState);
|
||||
|
||||
/**
|
||||
* Gets if anvil is breaking on this use
|
||||
*
|
||||
* @return {@code true} if breaking
|
||||
*/
|
||||
public boolean isBreaking() {
|
||||
return this.damageState == DamageState.BROKEN;
|
||||
}
|
||||
boolean isBreaking();
|
||||
|
||||
/**
|
||||
* Sets if anvil is breaking on this use
|
||||
*
|
||||
* @param breaking {@code true} if breaking
|
||||
*/
|
||||
public void setBreaking(final boolean breaking) {
|
||||
if (breaking) {
|
||||
this.damageState = DamageState.BROKEN;
|
||||
} else if (this.damageState == DamageState.BROKEN) {
|
||||
this.damageState = DamageState.DAMAGED;
|
||||
void setBreaking(boolean breaking);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the amount of damage on an anvil block
|
||||
*/
|
||||
public enum DamageState {
|
||||
enum DamageState {
|
||||
FULL(Material.ANVIL),
|
||||
CHIPPED(Material.CHIPPED_ANVIL),
|
||||
DAMAGED(Material.DAMAGED_ANVIL),
|
||||
|
||||
+12
-50
@@ -1,88 +1,50 @@
|
||||
package com.destroystokyo.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a beacon effect is being applied to a player.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BeaconEffectEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final boolean primary;
|
||||
private PotionEffect effect;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BeaconEffectEvent(final Block beacon, final PotionEffect effect, final Player player, final boolean primary) {
|
||||
super(beacon);
|
||||
this.effect = effect;
|
||||
this.player = player;
|
||||
this.primary = primary;
|
||||
}
|
||||
public interface BeaconEffectEvent extends BlockEvent, PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the potion effect being applied.
|
||||
*
|
||||
* @return Potion effect
|
||||
*/
|
||||
public PotionEffect getEffect() {
|
||||
return this.effect;
|
||||
}
|
||||
PotionEffect getEffect();
|
||||
|
||||
/**
|
||||
* Sets the potion effect that will be applied.
|
||||
*
|
||||
* @param effect Potion effect
|
||||
*/
|
||||
public void setEffect(final PotionEffect effect) {
|
||||
this.effect = effect;
|
||||
}
|
||||
void setEffect(PotionEffect effect);
|
||||
|
||||
/**
|
||||
* Gets the player who the potion effect is being applied to.
|
||||
*
|
||||
* @return Affected player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
@Override
|
||||
Player getPlayer();
|
||||
|
||||
/**
|
||||
* Gets whether the effect is a primary beacon effect.
|
||||
*
|
||||
* @return {@code true} if this event represents a primary effect
|
||||
*/
|
||||
public boolean isPrimary() {
|
||||
return this.primary;
|
||||
}
|
||||
boolean isPrimary();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+16
-57
@@ -1,12 +1,9 @@
|
||||
package com.destroystokyo.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockExpEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired anytime the server intends to 'destroy' a block through some triggering reason.
|
||||
@@ -18,103 +15,65 @@ import org.jspecify.annotations.NullMarked;
|
||||
* <p>
|
||||
* Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BlockDestroyEvent extends BlockExpEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final BlockData newState;
|
||||
private boolean willDrop;
|
||||
private boolean playEffect = true;
|
||||
private BlockData effectBlock;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BlockDestroyEvent(final Block block, final BlockData newState, final BlockData effectBlock, final int xp, final boolean willDrop) {
|
||||
super(block, xp);
|
||||
this.newState = newState;
|
||||
this.effectBlock = effectBlock;
|
||||
this.willDrop = willDrop;
|
||||
}
|
||||
public interface BlockDestroyEvent extends BlockExpEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the effect that will be played when the block is broken.
|
||||
*
|
||||
* @return block break effect
|
||||
*/
|
||||
public BlockData getEffectBlock() {
|
||||
return this.effectBlock;
|
||||
}
|
||||
BlockData getEffectBlock();
|
||||
|
||||
/**
|
||||
* Sets the effect that will be played when the block is broken.
|
||||
* Note: {@link BlockDestroyEvent#playEffect()} must be {@code true} in order for this effect to be
|
||||
* Note: {@link #playEffect()} must be {@code true} in order for this effect to be
|
||||
* played.
|
||||
*
|
||||
* @param effectBlock block effect
|
||||
*/
|
||||
public void setEffectBlock(final BlockData effectBlock) {
|
||||
this.effectBlock = effectBlock.clone();
|
||||
}
|
||||
void setEffectBlock(BlockData effectBlock);
|
||||
|
||||
/**
|
||||
* @return The new state of this block (Air, or a Fluid type)
|
||||
*/
|
||||
public BlockData getNewState() {
|
||||
return this.newState.clone();
|
||||
}
|
||||
BlockData getNewState();
|
||||
|
||||
/**
|
||||
* @return If the server is going to drop the block in question with this destroy event
|
||||
*/
|
||||
public boolean willDrop() {
|
||||
return this.willDrop;
|
||||
}
|
||||
boolean willDrop();
|
||||
|
||||
/**
|
||||
* @param willDrop If the server is going to drop the block in question with this destroy event
|
||||
*/
|
||||
public void setWillDrop(final boolean willDrop) {
|
||||
this.willDrop = willDrop;
|
||||
}
|
||||
void setWillDrop(boolean willDrop);
|
||||
|
||||
/**
|
||||
* @return If the server is going to play the sound effect for this destruction
|
||||
*/
|
||||
public boolean playEffect() {
|
||||
return this.playEffect;
|
||||
}
|
||||
boolean playEffect();
|
||||
|
||||
/**
|
||||
* @param playEffect If the server should play the sound effect for this destruction
|
||||
*/
|
||||
public void setPlayEffect(final boolean playEffect) {
|
||||
this.playEffect = playEffect;
|
||||
}
|
||||
void setPlayEffect(boolean playEffect);
|
||||
|
||||
/**
|
||||
* @return If the event is cancelled, meaning the block will not be destroyed
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* If the event is cancelled, the block will remain in its previous state.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.destroystokyo.paper.event.block;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -9,9 +8,7 @@ import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when TNT block is about to turn into {@link TNTPrimed}
|
||||
@@ -23,31 +20,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @deprecated use {@link org.bukkit.event.block.TNTPrimeEvent}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.19.4")
|
||||
public class TNTPrimeEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@NotNull private final PrimeReason reason;
|
||||
@Nullable private final Entity primerEntity;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public TNTPrimeEvent(@NotNull Block block, @NotNull PrimeReason reason, @Nullable Entity primerEntity) {
|
||||
super(block);
|
||||
this.reason = reason;
|
||||
this.primerEntity = primerEntity;
|
||||
}
|
||||
public interface TNTPrimeEvent extends BlockEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the TNT prime reason
|
||||
*
|
||||
* @return Prime reason
|
||||
*/
|
||||
@NotNull
|
||||
public PrimeReason getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
PrimeReason getReason();
|
||||
|
||||
/**
|
||||
* Gets the TNT primer {@link Entity}.
|
||||
@@ -58,10 +38,7 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable {
|
||||
*
|
||||
* @return The {@link Entity} who primed the TNT
|
||||
*/
|
||||
@Nullable
|
||||
public Entity getPrimerEntity() {
|
||||
return this.primerEntity;
|
||||
}
|
||||
@Nullable Entity getPrimerEntity();
|
||||
|
||||
/**
|
||||
* Gets whether spawning {@link TNTPrimed} should be cancelled or not
|
||||
@@ -69,9 +46,7 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable {
|
||||
* @return Whether spawning {@link TNTPrimed} should be cancelled or not
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Sets whether to cancel spawning {@link TNTPrimed} or not
|
||||
@@ -79,22 +54,16 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable {
|
||||
* @param cancel whether spawning {@link TNTPrimed} should be cancelled or not
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public enum PrimeReason {
|
||||
enum PrimeReason {
|
||||
/**
|
||||
* When TNT prime was caused by other explosion (chain reaction)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package com.destroystokyo.paper.event.block;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+8
-30
@@ -2,12 +2,9 @@ package com.destroystokyo.paper.event.brigadier;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired any time a Brigadier RootCommandNode is generated for a player to inform the client of commands.
|
||||
@@ -30,45 +27,26 @@ import org.jspecify.annotations.NullMarked;
|
||||
* <p>This is a draft/experimental API and is subject to change.</p>
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@NullMarked
|
||||
public class AsyncPlayerSendCommandsEvent<S extends CommandSourceStack> extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final RootCommandNode<S> node;
|
||||
private final boolean hasFiredAsync;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AsyncPlayerSendCommandsEvent(final Player player, final RootCommandNode<S> node, final boolean hasFiredAsync) {
|
||||
super(player, !Bukkit.isPrimaryThread());
|
||||
this.node = node;
|
||||
this.hasFiredAsync = hasFiredAsync;
|
||||
}
|
||||
public interface AsyncPlayerSendCommandsEvent<S extends CommandSourceStack> extends PlayerEvent {
|
||||
|
||||
/**
|
||||
* Gets the full Root Command Node being sent to the client, which is mutable.
|
||||
*
|
||||
* @return the root command node
|
||||
*/
|
||||
public RootCommandNode<S> getCommandNode() {
|
||||
return this.node;
|
||||
}
|
||||
RootCommandNode<S> getCommandNode();
|
||||
|
||||
/**
|
||||
* Gets if this event has already fired asynchronously.
|
||||
*
|
||||
* @return whether this event has already fired asynchronously
|
||||
*/
|
||||
public boolean hasFiredAsync() {
|
||||
return this.hasFiredAsync;
|
||||
}
|
||||
boolean hasFiredAsync();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-44
@@ -1,67 +1,37 @@
|
||||
package com.destroystokyo.paper.event.brigadier;
|
||||
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when sending {@link Suggestions} to the client. Will be called asynchronously if a plugin
|
||||
* marks the {@link com.destroystokyo.paper.event.server.AsyncTabCompleteEvent} event handled asynchronously,
|
||||
* otherwise called synchronously.
|
||||
*/
|
||||
@NullMarked
|
||||
public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private Suggestions suggestions;
|
||||
private final String buffer;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AsyncPlayerSendSuggestionsEvent(final Player player, final Suggestions suggestions, final String buffer) {
|
||||
super(player, !Bukkit.isPrimaryThread());
|
||||
this.suggestions = suggestions;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
public interface AsyncPlayerSendSuggestionsEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the input buffer sent to request these suggestions.
|
||||
*
|
||||
* @return the input buffer
|
||||
*/
|
||||
public String getBuffer() {
|
||||
return this.buffer;
|
||||
}
|
||||
String getBuffer();
|
||||
|
||||
/**
|
||||
* Gets the suggestions to be sent to client.
|
||||
*
|
||||
* @return the suggestions
|
||||
*/
|
||||
public Suggestions getSuggestions() {
|
||||
return this.suggestions;
|
||||
}
|
||||
Suggestions getSuggestions();
|
||||
|
||||
/**
|
||||
* Sets the suggestions to be sent to client.
|
||||
*
|
||||
* @param suggestions suggestions
|
||||
*/
|
||||
public void setSuggestions(final Suggestions suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
void setSuggestions(Suggestions suggestions);
|
||||
|
||||
/**
|
||||
* Cancels sending suggestions to the client.
|
||||
@@ -69,16 +39,12 @@ public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Canc
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+24
-73
@@ -1,6 +1,7 @@
|
||||
package com.destroystokyo.paper.event.brigadier;
|
||||
|
||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommand;
|
||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||
import com.mojang.brigadier.tree.ArgumentCommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
@@ -9,7 +10,6 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.server.ServerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Fired anytime the server synchronizes Bukkit commands to Brigadier.
|
||||
@@ -22,37 +22,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
@Deprecated(since = "1.20.6")
|
||||
@Warning(reason = "This event has been superseded by the Commands API and will be removed in a future release. Listen to LifecycleEvents.COMMANDS instead.", value = true)
|
||||
public class CommandRegisteredEvent<S extends com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource> extends ServerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final String commandLabel;
|
||||
private final Command command;
|
||||
private final com.destroystokyo.paper.brigadier.BukkitBrigadierCommand<S> brigadierCommand;
|
||||
private final RootCommandNode<S> root;
|
||||
private final ArgumentCommandNode<S, String> defaultArgs;
|
||||
private LiteralCommandNode<S> literal;
|
||||
private boolean rawCommand = false;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public CommandRegisteredEvent(String commandLabel, com.destroystokyo.paper.brigadier.BukkitBrigadierCommand<S> brigadierCommand, Command command, RootCommandNode<S> root, LiteralCommandNode<S> literal, ArgumentCommandNode<S, String> defaultArgs) {
|
||||
this.commandLabel = commandLabel;
|
||||
this.brigadierCommand = brigadierCommand;
|
||||
this.command = command;
|
||||
this.root = root;
|
||||
this.literal = literal;
|
||||
this.defaultArgs = defaultArgs;
|
||||
}
|
||||
public interface CommandRegisteredEvent<S extends BukkitBrigadierCommandSource> extends ServerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the command label of the {@link Command} being registered.
|
||||
*
|
||||
* @return the command label
|
||||
*/
|
||||
public String getCommandLabel() {
|
||||
return this.commandLabel;
|
||||
}
|
||||
String getCommandLabel();
|
||||
|
||||
/**
|
||||
* Gets the {@link BukkitBrigadierCommand} for the {@link Command} being registered. This can be used
|
||||
@@ -62,46 +39,28 @@ public class CommandRegisteredEvent<S extends com.destroystokyo.paper.brigadier.
|
||||
*
|
||||
* @return the {@link BukkitBrigadierCommand}
|
||||
*/
|
||||
public BukkitBrigadierCommand<S> getBrigadierCommand() {
|
||||
return this.brigadierCommand;
|
||||
}
|
||||
BukkitBrigadierCommand<S> getBrigadierCommand();
|
||||
|
||||
/**
|
||||
* Gets the {@link Command} being registered.
|
||||
*
|
||||
* @return the {@link Command}
|
||||
*/
|
||||
public Command getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
Command getCommand();
|
||||
|
||||
/**
|
||||
* Gets the {@link RootCommandNode} which is being registered to.
|
||||
*
|
||||
* @return the {@link RootCommandNode}
|
||||
*/
|
||||
public RootCommandNode<S> getRoot() {
|
||||
return this.root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Bukkit APIs default arguments node (greedy string), for if
|
||||
* you wish to reuse it.
|
||||
*
|
||||
* @return default arguments node
|
||||
*/
|
||||
public ArgumentCommandNode<S, String> getDefaultArgs() {
|
||||
return this.defaultArgs;
|
||||
}
|
||||
RootCommandNode<S> getRoot();
|
||||
|
||||
/**
|
||||
* Gets the {@link LiteralCommandNode} to be registered for the {@link Command}.
|
||||
*
|
||||
* @return the {@link LiteralCommandNode}
|
||||
*/
|
||||
public LiteralCommandNode<S> getLiteral() {
|
||||
return this.literal;
|
||||
}
|
||||
LiteralCommandNode<S> getLiteral();
|
||||
|
||||
/**
|
||||
* Sets the {@link LiteralCommandNode} used to register this command. The default literal is mutable, so
|
||||
@@ -109,9 +68,15 @@ public class CommandRegisteredEvent<S extends com.destroystokyo.paper.brigadier.
|
||||
*
|
||||
* @param literal new node
|
||||
*/
|
||||
public void setLiteral(LiteralCommandNode<S> literal) {
|
||||
this.literal = literal;
|
||||
}
|
||||
void setLiteral(LiteralCommandNode<S> literal);
|
||||
|
||||
/**
|
||||
* Gets the Bukkit APIs default arguments node (greedy string), for if
|
||||
* you wish to reuse it.
|
||||
*
|
||||
* @return default arguments node
|
||||
*/
|
||||
ArgumentCommandNode<S, String> getDefaultArgs();
|
||||
|
||||
/**
|
||||
* Gets whether this command should is treated as "raw".
|
||||
@@ -119,9 +84,7 @@ public class CommandRegisteredEvent<S extends com.destroystokyo.paper.brigadier.
|
||||
* @see #setRawCommand(boolean)
|
||||
* @return whether this command is treated as "raw"
|
||||
*/
|
||||
public boolean isRawCommand() {
|
||||
return this.rawCommand;
|
||||
}
|
||||
boolean isRawCommand();
|
||||
|
||||
/**
|
||||
* Sets whether this command should be treated as "raw".
|
||||
@@ -135,14 +98,7 @@ public class CommandRegisteredEvent<S extends com.destroystokyo.paper.brigadier.
|
||||
*
|
||||
* @param rawCommand whether this command should be treated as "raw"
|
||||
*/
|
||||
public void setRawCommand(final boolean rawCommand) {
|
||||
this.rawCommand = rawCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
void setRawCommand(boolean rawCommand);
|
||||
|
||||
/**
|
||||
* Cancels registering this command to Brigadier, but will remain in Bukkit Command Map. Can be used to hide a
|
||||
@@ -151,17 +107,12 @@ public class CommandRegisteredEvent<S extends com.destroystokyo.paper.brigadier.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@NotNull
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package com.destroystokyo.paper.event.brigadier;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+4
-45
@@ -2,59 +2,18 @@ package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import io.papermc.paper.event.entity.EntityIgniteEvent;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.checkerframework.checker.index.qual.Positive;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a Creeper is ignited either by a
|
||||
* flint and steel, {@link Creeper#ignite()} or
|
||||
* {@link Creeper#setIgnited(boolean)}.
|
||||
*/
|
||||
@NullMarked
|
||||
public class CreeperIgniteEvent extends EntityIgniteEvent {
|
||||
|
||||
private boolean ignited;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public CreeperIgniteEvent(final Creeper creeper, final boolean ignited) {
|
||||
super(creeper, creeper.getMaxFuseTicks());
|
||||
this.ignited = ignited;
|
||||
}
|
||||
public interface CreeperIgniteEvent extends EntityIgniteEvent {
|
||||
|
||||
@Override
|
||||
public Creeper getEntity() {
|
||||
return (Creeper) super.getEntity();
|
||||
}
|
||||
Creeper getEntity();
|
||||
|
||||
public boolean isIgnited() {
|
||||
return this.ignited;
|
||||
}
|
||||
boolean isIgnited();
|
||||
|
||||
public void setIgnited(final boolean ignited) {
|
||||
this.ignited = ignited;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Positive int getFuseTime() {
|
||||
return this.getEntity().getMaxFuseTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuseTime(final @Positive int ticks) {
|
||||
this.getEntity().setMaxFuseTicks(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return super.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
super.setCancelled(cancel);
|
||||
}
|
||||
void setIgnited(boolean ignited);
|
||||
}
|
||||
+10
-43
@@ -7,68 +7,35 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
/**
|
||||
* Fired when a DragonFireball collides with a block/entity and spawns an AreaEffectCloud
|
||||
*/
|
||||
@NullMarked
|
||||
public class EnderDragonFireballHitEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Collection<LivingEntity> targets;
|
||||
private final AreaEffectCloud areaEffectCloud;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EnderDragonFireballHitEvent(final DragonFireball fireball, final Collection<LivingEntity> targets, final AreaEffectCloud areaEffectCloud) {
|
||||
super(fireball);
|
||||
this.targets = targets;
|
||||
this.areaEffectCloud = areaEffectCloud;
|
||||
}
|
||||
public interface EnderDragonFireballHitEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The fireball involved in this event
|
||||
*/
|
||||
@Override
|
||||
public DragonFireball getEntity() {
|
||||
return (DragonFireball) super.getEntity();
|
||||
}
|
||||
DragonFireball getEntity();
|
||||
|
||||
/**
|
||||
* The living entities hit by fireball
|
||||
*
|
||||
* @return the targets
|
||||
*/
|
||||
public Collection<LivingEntity> getTargets() {
|
||||
return this.targets;
|
||||
}
|
||||
@Unmodifiable Collection<LivingEntity> getTargets();
|
||||
|
||||
/**
|
||||
* @return The area effect cloud spawned in this collision
|
||||
*/
|
||||
public AreaEffectCloud getAreaEffectCloud() {
|
||||
return this.areaEffectCloud;
|
||||
}
|
||||
AreaEffectCloud getAreaEffectCloud();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-38
@@ -5,57 +5,27 @@ import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when an EnderDragon spawns an AreaEffectCloud by shooting flames
|
||||
*/
|
||||
@NullMarked
|
||||
public class EnderDragonFlameEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final AreaEffectCloud areaEffectCloud;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EnderDragonFlameEvent(final EnderDragon enderDragon, final AreaEffectCloud areaEffectCloud) {
|
||||
super(enderDragon);
|
||||
this.areaEffectCloud = areaEffectCloud;
|
||||
}
|
||||
public interface EnderDragonFlameEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The enderdragon involved in this event
|
||||
*/
|
||||
@Override
|
||||
public EnderDragon getEntity() {
|
||||
return (EnderDragon) super.getEntity();
|
||||
}
|
||||
EnderDragon getEntity();
|
||||
|
||||
/**
|
||||
* @return The area effect cloud spawned in this collision
|
||||
*/
|
||||
public AreaEffectCloud getAreaEffectCloud() {
|
||||
return this.areaEffectCloud;
|
||||
}
|
||||
AreaEffectCloud getAreaEffectCloud();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-38
@@ -5,57 +5,27 @@ import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when an EnderDragon shoots a fireball
|
||||
*/
|
||||
@NullMarked
|
||||
public class EnderDragonShootFireballEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final DragonFireball fireball;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EnderDragonShootFireballEvent(final EnderDragon entity, final DragonFireball fireball) {
|
||||
super(entity);
|
||||
this.fireball = fireball;
|
||||
}
|
||||
public interface EnderDragonShootFireballEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The enderdragon shooting the fireball
|
||||
*/
|
||||
@Override
|
||||
public EnderDragon getEntity() {
|
||||
return (EnderDragon) super.getEntity();
|
||||
}
|
||||
EnderDragon getEntity();
|
||||
|
||||
/**
|
||||
* @return The fireball being shot
|
||||
*/
|
||||
public DragonFireball getFireball() {
|
||||
return this.fireball;
|
||||
}
|
||||
DragonFireball getFireball();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-34
@@ -28,8 +28,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when an Enderman determines if it should attack a player or not.
|
||||
@@ -37,19 +35,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
* Starts off cancelled if the player is wearing a pumpkin head or is not looking
|
||||
* at the Enderman, according to Vanilla rules.
|
||||
*/
|
||||
@NullMarked
|
||||
public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EndermanAttackPlayerEvent(final Enderman entity, final Player player) {
|
||||
super(entity);
|
||||
this.player = player;
|
||||
}
|
||||
public interface EndermanAttackPlayerEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The enderman considering attacking
|
||||
@@ -57,26 +43,20 @@ public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellabl
|
||||
* @return The enderman considering attacking
|
||||
*/
|
||||
@Override
|
||||
public Enderman getEntity() {
|
||||
return (Enderman) super.getEntity();
|
||||
}
|
||||
Enderman getEntity();
|
||||
|
||||
/**
|
||||
* The player the Enderman is considering attacking
|
||||
*
|
||||
* @return The player the Enderman is considering attacking
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
Player getPlayer();
|
||||
|
||||
/**
|
||||
* @return If cancelled, the enderman will not attack
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -84,16 +64,12 @@ public class EndermanAttackPlayerEvent extends EntityEvent implements Cancellabl
|
||||
* Cancels if the Enderman will attack this player
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-38
@@ -4,41 +4,18 @@ import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class EndermanEscapeEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Reason reason;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EndermanEscapeEvent(final Enderman entity, final Reason reason) {
|
||||
super(entity);
|
||||
this.reason = reason;
|
||||
}
|
||||
public interface EndermanEscapeEvent extends EntityEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public Enderman getEntity() {
|
||||
return (Enderman) super.getEntity();
|
||||
}
|
||||
Enderman getEntity();
|
||||
|
||||
/**
|
||||
* Gets the reason the enderman is trying to escape.
|
||||
*
|
||||
* @return The reason
|
||||
*/
|
||||
public Reason getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
Reason getReason();
|
||||
|
||||
/**
|
||||
* Cancels the escape.
|
||||
@@ -48,20 +25,16 @@ public class EndermanEscapeEvent extends EntityEvent implements Cancellable {
|
||||
* innate immunities or damage behavior like arrows where the damage never happens.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public enum Reason {
|
||||
enum Reason {
|
||||
/**
|
||||
* The enderman has stopped attacking and ran away
|
||||
*/
|
||||
|
||||
+8
-24
@@ -1,44 +1,28 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.world.WorldEvent;
|
||||
|
||||
/**
|
||||
* Fired any time an entity is being added to the world for any reason (including a chunk loading).
|
||||
* <p>
|
||||
* Not to be confused with {@link CreatureSpawnEvent}
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityAddToWorldEvent extends EntityEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final World world;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityAddToWorldEvent(final Entity entity, final World world) {
|
||||
super(entity);
|
||||
this.world = world;
|
||||
}
|
||||
public interface EntityAddToWorldEvent extends EntityEvent, WorldEvent {
|
||||
|
||||
/**
|
||||
* @return The world that the entity is being added to
|
||||
*/
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
World getWorld();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -4,47 +4,21 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when an entity jumps
|
||||
* <p>
|
||||
* Cancelling the event will stop the entity from jumping
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityJumpEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityJumpEvent(final LivingEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
public interface EntityJumpEvent extends EntityEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) super.getEntity();
|
||||
}
|
||||
LivingEntity getEntity();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+4
-23
@@ -1,52 +1,33 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import io.papermc.paper.event.entity.EntityKnockbackEvent;
|
||||
import io.papermc.paper.event.entity.EntityPushedByEntityAttackEvent;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when an Entity is knocked back by the hit of another Entity. The acceleration
|
||||
* vector can be modified. If this event is cancelled, the entity is not knocked back.
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent {
|
||||
|
||||
private final float knockbackStrength;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityKnockbackByEntityEvent(final LivingEntity entity, final Entity hitBy, final EntityKnockbackEvent.Cause cause, final float knockbackStrength, final Vector knockback) {
|
||||
super(entity, cause, hitBy, knockback);
|
||||
this.knockbackStrength = knockbackStrength;
|
||||
}
|
||||
public interface EntityKnockbackByEntityEvent extends EntityPushedByEntityAttackEvent {
|
||||
|
||||
/**
|
||||
* @return the entity which was knocked back
|
||||
*/
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) super.getEntity();
|
||||
}
|
||||
LivingEntity getEntity();
|
||||
|
||||
/**
|
||||
* @return the original knockback strength.
|
||||
* @apiNote this value doesn't necessarily relate to {@link #getKnockback()}.
|
||||
*/
|
||||
@ApiStatus.Obsolete(since = "1.20.6")
|
||||
public float getKnockbackStrength() {
|
||||
return this.knockbackStrength;
|
||||
}
|
||||
float getKnockbackStrength();
|
||||
|
||||
/**
|
||||
* Gets the causing entity. Same as {@link #getPushedBy()}.
|
||||
*
|
||||
* @return the Entity which hit
|
||||
*/
|
||||
public Entity getHitBy() {
|
||||
return super.getPushedBy();
|
||||
}
|
||||
|
||||
Entity getHitBy();
|
||||
}
|
||||
+21
-42
@@ -5,8 +5,6 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -15,21 +13,7 @@ import org.jspecify.annotations.Nullable;
|
||||
* This event does not fire for the entities actual movement. Only when it
|
||||
* is choosing to start moving to a location.
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityPathfindEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final @Nullable Entity targetEntity;
|
||||
private final Location location;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityPathfindEvent(final Entity entity, final Location location, final @Nullable Entity targetEntity) {
|
||||
super(entity);
|
||||
this.targetEntity = targetEntity;
|
||||
this.location = location;
|
||||
}
|
||||
public interface EntityPathfindEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The Entity that is pathfinding.
|
||||
@@ -37,9 +21,7 @@ public class EntityPathfindEvent extends EntityEvent implements Cancellable {
|
||||
* @return The Entity that is pathfinding.
|
||||
*/
|
||||
@Override
|
||||
public Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
Entity getEntity();
|
||||
|
||||
/**
|
||||
* If the Entity is trying to pathfind to an entity, this is the entity in relation.
|
||||
@@ -48,9 +30,7 @@ public class EntityPathfindEvent extends EntityEvent implements Cancellable {
|
||||
*
|
||||
* @return The entity target or {@code null}
|
||||
*/
|
||||
public @Nullable Entity getTargetEntity() {
|
||||
return this.targetEntity;
|
||||
}
|
||||
@Nullable Entity getTargetEntity();
|
||||
|
||||
/**
|
||||
* The Location of where the entity is about to move to.
|
||||
@@ -59,26 +39,25 @@ public class EntityPathfindEvent extends EntityEvent implements Cancellable {
|
||||
*
|
||||
* @return Location of where the entity is trying to pathfind to.
|
||||
*/
|
||||
public Location getLoc() {
|
||||
return this.location.clone();
|
||||
Location getTargetLocation();
|
||||
|
||||
/**
|
||||
* The Location of where the entity is about to move to.
|
||||
* <br>
|
||||
* Note that if the target happened to of been an entity
|
||||
*
|
||||
* @return Location of where the entity is trying to pathfind to.
|
||||
* @deprecated use {@link #getTargetLocation()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default Location getLoc() {
|
||||
return this.getTargetLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-24
@@ -1,42 +1,26 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.world.WorldEvent;
|
||||
|
||||
/**
|
||||
* Fired any time an entity is being removed from a world for any reason (including a chunk unloading).
|
||||
* Note: The entity is updated prior to this event being called, as such, the entity's world may not be equal to {@link #getWorld()}.
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityRemoveFromWorldEvent extends EntityEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final World world;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityRemoveFromWorldEvent(final Entity entity, final World world) {
|
||||
super(entity);
|
||||
this.world = world;
|
||||
}
|
||||
public interface EntityRemoveFromWorldEvent extends EntityEvent, WorldEvent {
|
||||
|
||||
/**
|
||||
* @return The world that the entity is being removed from
|
||||
*/
|
||||
public World getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
World getWorld();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+2
-18
@@ -1,33 +1,17 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.EndGateway;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired any time an entity attempts to teleport in an end gateway
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityTeleportEndGatewayEvent extends EntityTeleportEvent {
|
||||
|
||||
private final EndGateway gateway;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityTeleportEndGatewayEvent(final Entity entity, final Location from, final Location to, final EndGateway gateway) {
|
||||
super(entity, from, to);
|
||||
this.gateway = gateway;
|
||||
}
|
||||
public interface EntityTeleportEndGatewayEvent extends EntityTeleportEvent {
|
||||
|
||||
/**
|
||||
* The gateway triggering the teleport
|
||||
*
|
||||
* @return EndGateway used
|
||||
*/
|
||||
public EndGateway getGateway() {
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
EndGateway getGateway();
|
||||
}
|
||||
@@ -1,65 +1,35 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import java.util.Collections;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityTransformEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when lightning strikes an entity
|
||||
*/
|
||||
@NullMarked
|
||||
public class EntityZapEvent extends EntityTransformEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final LightningStrike bolt;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public EntityZapEvent(final Entity entity, final LightningStrike bolt, final Entity replacementEntity) {
|
||||
super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING);
|
||||
this.bolt = bolt;
|
||||
}
|
||||
public interface EntityZapEvent extends EntityTransformEvent {
|
||||
|
||||
/**
|
||||
* Gets the lightning bolt that is striking the entity.
|
||||
*
|
||||
* @return The lightning bolt responsible for this event
|
||||
*/
|
||||
public LightningStrike getBolt() {
|
||||
return this.bolt;
|
||||
}
|
||||
LightningStrike getBolt();
|
||||
|
||||
/**
|
||||
* Gets the entity that will replace the struck entity.
|
||||
*
|
||||
* @return The entity that will replace the struck entity
|
||||
*/
|
||||
public Entity getReplacementEntity() {
|
||||
return super.getTransformedEntity();
|
||||
default Entity getReplacementEntity() {
|
||||
return this.getTransformedEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-41
@@ -27,62 +27,32 @@ import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired anytime the server is about to merge 2 experience orbs into one
|
||||
*/
|
||||
@NullMarked
|
||||
public class ExperienceOrbMergeEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ExperienceOrb mergeTarget;
|
||||
private final ExperienceOrb mergeSource;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ExperienceOrbMergeEvent(final ExperienceOrb mergeTarget, final ExperienceOrb mergeSource) {
|
||||
super(mergeTarget);
|
||||
this.mergeTarget = mergeTarget;
|
||||
this.mergeSource = mergeSource;
|
||||
}
|
||||
public interface ExperienceOrbMergeEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* @return The orb that will absorb the other experience orb
|
||||
* {@return the orb that will absorb the other experience orb}
|
||||
*/
|
||||
public ExperienceOrb getMergeTarget() {
|
||||
return this.mergeTarget;
|
||||
}
|
||||
ExperienceOrb getMergeTarget();
|
||||
|
||||
/**
|
||||
* @return The orb that is subject to being removed and merged into the target orb
|
||||
* {@return the orb that is subject to being removed and merged into the target orb}
|
||||
*/
|
||||
public ExperienceOrb getMergeSource() {
|
||||
return this.mergeSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
ExperienceOrb getMergeSource();
|
||||
|
||||
/**
|
||||
* @param cancel {@code true} if you wish to cancel this event, and prevent the orbs from merging
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+2
-18
@@ -1,32 +1,16 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a phantom is spawned for an exhausted player
|
||||
*/
|
||||
@NullMarked
|
||||
public class PhantomPreSpawnEvent extends PreCreatureSpawnEvent {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PhantomPreSpawnEvent(final Location location, final Entity entity, final CreatureSpawnEvent.SpawnReason reason) {
|
||||
super(location, EntityType.PHANTOM, reason);
|
||||
this.entity = entity;
|
||||
}
|
||||
public interface PhantomPreSpawnEvent extends PreCreatureSpawnEvent {
|
||||
|
||||
/**
|
||||
* Get the entity this phantom is spawning for
|
||||
*
|
||||
* @return the Entity
|
||||
*/
|
||||
public Entity getSpawningEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
Entity getSpawningEntity();
|
||||
}
|
||||
+10
-35
@@ -1,65 +1,40 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when the server is calculating what chunks to try to spawn monsters in every Monster Spawn Tick event
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerNaturallySpawnCreaturesEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private byte radius;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerNaturallySpawnCreaturesEvent(final Player player, final byte radius) {
|
||||
super(player);
|
||||
this.radius = radius;
|
||||
}
|
||||
public interface PlayerNaturallySpawnCreaturesEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* @return The radius of chunks around this player to be included in natural spawn selection
|
||||
*/
|
||||
public byte getSpawnRadius() {
|
||||
return this.radius;
|
||||
}
|
||||
byte getSpawnRadius();
|
||||
|
||||
/**
|
||||
* @param radius The radius of chunks around this player to be included in natural spawn selection
|
||||
*/
|
||||
public void setSpawnRadius(final byte radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
void setSpawnRadius(byte radius);
|
||||
|
||||
/**
|
||||
* @return If this player's chunks will be excluded from natural spawns
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* @param cancel {@code true} if you wish to cancel this event, and not include this player's chunks for natural spawning
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+13
-48
@@ -6,8 +6,6 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* WARNING: This event only fires for a limited number of cases, and not for every case that {@link CreatureSpawnEvent} does.
|
||||
@@ -19,52 +17,27 @@ import org.jspecify.annotations.NullMarked;
|
||||
* Currently: NATURAL and SPAWNER based reasons. <!-- Please submit a Pull Request for future additions. -->
|
||||
* Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PreCreatureSpawnEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Location location;
|
||||
private final EntityType type;
|
||||
private final CreatureSpawnEvent.SpawnReason reason;
|
||||
private boolean shouldAbortSpawn;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PreCreatureSpawnEvent(final Location location, final EntityType type, final CreatureSpawnEvent.SpawnReason reason) {
|
||||
this.location = location;
|
||||
this.type = type;
|
||||
this.reason = reason;
|
||||
}
|
||||
public interface PreCreatureSpawnEvent extends Event, Cancellable {
|
||||
|
||||
/**
|
||||
* @return The location this creature is being spawned at
|
||||
*/
|
||||
public Location getSpawnLocation() {
|
||||
return this.location.clone();
|
||||
}
|
||||
Location getSpawnLocation();
|
||||
|
||||
/**
|
||||
* @return The type of creature being spawned
|
||||
*/
|
||||
public EntityType getType() {
|
||||
return this.type;
|
||||
}
|
||||
EntityType getType();
|
||||
|
||||
/**
|
||||
* @return Reason this creature is spawning (ie, NATURAL vs SPAWNER)
|
||||
*/
|
||||
public CreatureSpawnEvent.SpawnReason getReason() {
|
||||
return this.reason;
|
||||
}
|
||||
CreatureSpawnEvent.SpawnReason getReason();
|
||||
|
||||
/**
|
||||
* @return If the spawn process should be aborted vs trying more attempts
|
||||
*/
|
||||
public boolean shouldAbortSpawn() {
|
||||
return this.shouldAbortSpawn;
|
||||
}
|
||||
boolean shouldAbortSpawn();
|
||||
|
||||
/**
|
||||
* Set this if you are more blanket blocking all types of these spawns, and wish to abort the spawn process from
|
||||
@@ -72,17 +45,13 @@ public class PreCreatureSpawnEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param shouldAbortSpawn Set if the spawn process should be aborted vs trying more attempts
|
||||
*/
|
||||
public void setShouldAbortSpawn(final boolean shouldAbortSpawn) {
|
||||
this.shouldAbortSpawn = shouldAbortSpawn;
|
||||
}
|
||||
void setShouldAbortSpawn(boolean shouldAbortSpawn);
|
||||
|
||||
/**
|
||||
* @return If the spawn of this creature is cancelled or not
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Cancelling this event is more efficient than cancelling {@link CreatureSpawnEvent}
|
||||
@@ -90,16 +59,12 @@ public class PreCreatureSpawnEvent extends Event implements Cancellable {
|
||||
* @param cancel {@code true} if you wish to cancel this event, and abort the spawn of this creature
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+2
-17
@@ -1,10 +1,6 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called before an entity is spawned into a world by a spawner.
|
||||
@@ -12,18 +8,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
* This only includes the spawner's location and not the full BlockState snapshot for performance reasons.
|
||||
* If you really need it you have to get the spawner yourself.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PreSpawnerSpawnEvent extends PreCreatureSpawnEvent {
|
||||
public interface PreSpawnerSpawnEvent extends PreCreatureSpawnEvent {
|
||||
|
||||
private final Location spawnerLocation;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PreSpawnerSpawnEvent(final Location location, final EntityType type, final Location spawnerLocation) {
|
||||
super(location, type, CreatureSpawnEvent.SpawnReason.SPAWNER);
|
||||
this.spawnerLocation = spawnerLocation;
|
||||
}
|
||||
|
||||
public Location getSpawnerLocation() {
|
||||
return this.spawnerLocation.clone();
|
||||
}
|
||||
Location getSpawnerLocation();
|
||||
}
|
||||
+10
-43
@@ -6,69 +6,36 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a projectile collides with an entity
|
||||
* <p>
|
||||
* This event is called <b>before</b> {@link EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying
|
||||
*
|
||||
* @deprecated Deprecated, use {@link org.bukkit.event.entity.ProjectileHitEvent} and check if there is a hit entity
|
||||
* @deprecated use {@link org.bukkit.event.entity.ProjectileHitEvent} and check if there is a hit entity
|
||||
*/
|
||||
@Deprecated(since = "1.19.3")
|
||||
public class ProjectileCollideEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@NotNull private final Entity collidedWith;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ProjectileCollideEvent(@NotNull Projectile projectile, @NotNull Entity collidedWith) {
|
||||
super(projectile);
|
||||
this.collidedWith = collidedWith;
|
||||
}
|
||||
public interface ProjectileCollideEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Get the projectile that collided
|
||||
*
|
||||
* @return the projectile that collided
|
||||
*/
|
||||
@NotNull
|
||||
public Projectile getEntity() {
|
||||
return (Projectile) super.getEntity();
|
||||
}
|
||||
@Override
|
||||
Projectile getEntity();
|
||||
|
||||
/**
|
||||
* Get the entity the projectile collided with
|
||||
*
|
||||
* @return the entity collided with
|
||||
*/
|
||||
@NotNull
|
||||
public Entity getCollidedWith() {
|
||||
return this.collidedWith;
|
||||
}
|
||||
Entity getCollidedWith();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-38
@@ -6,52 +6,22 @@ import org.bukkit.entity.SkeletonHorse;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Event called when a player gets close to a skeleton horse and triggers the lightning trap
|
||||
*/
|
||||
@NullMarked
|
||||
public class SkeletonHorseTrapEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final List<HumanEntity> eligibleHumans;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SkeletonHorseTrapEvent(final SkeletonHorse horse, final List<HumanEntity> eligibleHumans) {
|
||||
super(horse);
|
||||
this.eligibleHumans = eligibleHumans;
|
||||
}
|
||||
public interface SkeletonHorseTrapEvent extends EntityEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public SkeletonHorse getEntity() {
|
||||
return (SkeletonHorse) super.getEntity();
|
||||
}
|
||||
SkeletonHorse getEntity();
|
||||
|
||||
public List<HumanEntity> getEligibleHumans() {
|
||||
return this.eligibleHumans;
|
||||
}
|
||||
List<HumanEntity> getEligibleHumans();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-20
@@ -1,41 +1,24 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.AbstractCubeMob;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to change its facing direction.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to change direction.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeChangeDirectionEvent extends SlimePathfindEvent {
|
||||
|
||||
private float yaw;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeChangeDirectionEvent(final AbstractCubeMob cubeMob, final float yaw) {
|
||||
super(cubeMob);
|
||||
this.yaw = yaw;
|
||||
}
|
||||
public interface SlimeChangeDirectionEvent extends SlimePathfindEvent {
|
||||
|
||||
/**
|
||||
* Get the new chosen yaw
|
||||
*
|
||||
* @return Chosen yaw
|
||||
*/
|
||||
public float getNewYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
float getNewYaw();
|
||||
|
||||
/**
|
||||
* Set the new chosen yaw
|
||||
*
|
||||
* @param yaw Chosen yaw
|
||||
*/
|
||||
public void setNewYaw(final float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
void setNewYaw(float yaw);
|
||||
}
|
||||
+7
-33
@@ -4,8 +4,6 @@ import org.bukkit.entity.AbstractCubeMob;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to start pathfinding.
|
||||
@@ -13,17 +11,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start moving.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimePathfindEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimePathfindEvent(final AbstractCubeMob cubeMob) {
|
||||
super(cubeMob);
|
||||
}
|
||||
public interface SlimePathfindEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The Slime that is pathfinding.
|
||||
@@ -31,26 +19,12 @@ public class SlimePathfindEvent extends EntityEvent implements Cancellable {
|
||||
* @return The Slime that is pathfinding.
|
||||
*/
|
||||
@Override
|
||||
public AbstractCubeMob getEntity() {
|
||||
return (AbstractCubeMob) super.getEntity();
|
||||
}
|
||||
AbstractCubeMob getEntity();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,10 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.AbstractCubeMob;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to start jumping while swimming in water/lava.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start jumping.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeSwimEvent extends SlimeWanderEvent {
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeSwimEvent(final AbstractCubeMob cubeMob) {
|
||||
super(cubeMob);
|
||||
}
|
||||
public interface SlimeSwimEvent extends SlimeWanderEvent {
|
||||
}
|
||||
+2
-16
@@ -1,9 +1,6 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.AbstractCubeMob;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to change direction to target a LivingEntity.
|
||||
@@ -11,23 +8,12 @@ import org.jspecify.annotations.NullMarked;
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start moving.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
|
||||
|
||||
private final LivingEntity target;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeTargetLivingEntityEvent(final AbstractCubeMob cubeMob, final LivingEntity target) {
|
||||
super(cubeMob);
|
||||
this.target = target;
|
||||
}
|
||||
public interface SlimeTargetLivingEntityEvent extends SlimePathfindEvent {
|
||||
|
||||
/**
|
||||
* Get the targeted entity
|
||||
*
|
||||
* @return Targeted entity
|
||||
*/
|
||||
public LivingEntity getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
LivingEntity getTarget();
|
||||
}
|
||||
@@ -1,20 +1,10 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.bukkit.entity.AbstractCubeMob;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Slime decides to start wandering.
|
||||
* <p>
|
||||
* This event does not fire for the entity's actual movement. Only when it
|
||||
* is choosing to start moving.
|
||||
*/
|
||||
@NullMarked
|
||||
public class SlimeWanderEvent extends SlimePathfindEvent {
|
||||
|
||||
@ApiStatus.Internal
|
||||
public SlimeWanderEvent(final AbstractCubeMob cubeMob) {
|
||||
super(cubeMob);
|
||||
}
|
||||
public interface SlimeWanderEvent extends SlimePathfindEvent {
|
||||
}
|
||||
+32
-60
@@ -1,54 +1,39 @@
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.checkerframework.checker.index.qual.NonNegative;
|
||||
|
||||
/**
|
||||
* Called when a thrown egg might hatch.
|
||||
* <p>
|
||||
* This event fires for all thrown eggs that may hatch, players, dispensers, etc.
|
||||
*/
|
||||
@NullMarked
|
||||
public class ThrownEggHatchEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Egg egg;
|
||||
private boolean hatching;
|
||||
private byte numHatches;
|
||||
private EntityType hatchType;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ThrownEggHatchEvent(final Egg egg, final boolean hatching, final byte numHatches, final EntityType hatchingType) {
|
||||
this.egg = egg;
|
||||
this.hatching = hatching;
|
||||
this.numHatches = numHatches;
|
||||
this.hatchType = hatchingType;
|
||||
}
|
||||
public interface ThrownEggHatchEvent extends EntityEvent {
|
||||
|
||||
/**
|
||||
* Gets the egg involved in this event.
|
||||
*
|
||||
* @return the egg involved in this event
|
||||
* @deprecated use {@link #getEntity()}
|
||||
*/
|
||||
public Egg getEgg() {
|
||||
return this.egg;
|
||||
@Deprecated(forRemoval = true)
|
||||
default Egg getEgg() {
|
||||
return this.getEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
Egg getEntity();
|
||||
|
||||
/**
|
||||
* Gets whether the egg is hatching or not. Will be what the server
|
||||
* would've done without interaction.
|
||||
*
|
||||
* @return boolean Whether the egg is going to hatch or not
|
||||
*/
|
||||
public boolean isHatching() {
|
||||
return this.hatching;
|
||||
}
|
||||
boolean isHatching();
|
||||
|
||||
/**
|
||||
* Sets whether the egg will hatch or not.
|
||||
@@ -56,28 +41,7 @@ public class ThrownEggHatchEvent extends Event {
|
||||
* @param hatching {@code true} if you want the egg to hatch, {@code false} if you want it
|
||||
* not to
|
||||
*/
|
||||
public void setHatching(final boolean hatching) {
|
||||
this.hatching = hatching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type of the mob being hatched ({@link EntityType#CHICKEN} by default)
|
||||
*
|
||||
* @return The type of the mob being hatched by the egg
|
||||
*/
|
||||
public EntityType getHatchingType() {
|
||||
return this.hatchType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the type of mob being hatched by the egg
|
||||
*
|
||||
* @param hatchType The type of the mob being hatched by the egg
|
||||
*/
|
||||
public void setHatchingType(final EntityType hatchType) {
|
||||
Preconditions.checkArgument(hatchType.isSpawnable(), "Can't spawn that entity type from an egg!");
|
||||
this.hatchType = hatchType;
|
||||
}
|
||||
void setHatching(boolean hatching);
|
||||
|
||||
/**
|
||||
* Get the number of mob hatches from the egg. By default, the number will
|
||||
@@ -90,9 +54,7 @@ public class ThrownEggHatchEvent extends Event {
|
||||
*
|
||||
* @return The number of mobs going to be hatched by the egg
|
||||
*/
|
||||
public byte getNumHatches() {
|
||||
return this.numHatches;
|
||||
}
|
||||
@NonNegative byte getNumHatches();
|
||||
|
||||
/**
|
||||
* Change the number of mobs coming out of the hatched egg
|
||||
@@ -102,16 +64,26 @@ public class ThrownEggHatchEvent extends Event {
|
||||
*
|
||||
* @param numHatches The number of mobs coming out of the egg
|
||||
*/
|
||||
public void setNumHatches(final byte numHatches) {
|
||||
this.numHatches = numHatches;
|
||||
}
|
||||
void setNumHatches(@NonNegative byte numHatches);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
/**
|
||||
* Get the type of the mob being hatched ({@link EntityType#CHICKEN} by default)
|
||||
*
|
||||
* @return The type of the mob being hatched by the egg
|
||||
*/
|
||||
EntityType getHatchingType();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
/**
|
||||
* Change the type of mob being hatched by the egg
|
||||
*
|
||||
* @param hatchType The type of the mob being hatched by the egg
|
||||
*/
|
||||
void setHatchingType(EntityType hatchType);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+7
-33
@@ -4,23 +4,11 @@ import org.bukkit.entity.Turtle;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Turtle decides to go home
|
||||
*/
|
||||
@NullMarked
|
||||
public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public TurtleGoHomeEvent(final Turtle turtle) {
|
||||
super(turtle);
|
||||
}
|
||||
public interface TurtleGoHomeEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The turtle going home
|
||||
@@ -28,26 +16,12 @@ public class TurtleGoHomeEvent extends EntityEvent implements Cancellable {
|
||||
* @return The turtle
|
||||
*/
|
||||
@Override
|
||||
public Turtle getEntity() {
|
||||
return (Turtle) super.getEntity();
|
||||
}
|
||||
Turtle getEntity();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-51
@@ -5,28 +5,12 @@ import org.bukkit.entity.Turtle;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.common.value.qual.IntRange;
|
||||
|
||||
/**
|
||||
* Fired when a Turtle lays eggs
|
||||
*/
|
||||
@NullMarked
|
||||
public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Location location;
|
||||
private int eggCount;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public TurtleLayEggEvent(final Turtle turtle, final Location location, final int eggCount) {
|
||||
super(turtle);
|
||||
this.location = location;
|
||||
this.eggCount = eggCount;
|
||||
}
|
||||
public interface TurtleLayEggEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The turtle laying the eggs
|
||||
@@ -34,57 +18,33 @@ public class TurtleLayEggEvent extends EntityEvent implements Cancellable {
|
||||
* @return The turtle
|
||||
*/
|
||||
@Override
|
||||
public Turtle getEntity() {
|
||||
return (Turtle) super.getEntity();
|
||||
}
|
||||
Turtle getEntity();
|
||||
|
||||
/**
|
||||
* Get the location where the eggs are being laid
|
||||
*
|
||||
* @return Location of eggs
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return this.location.clone();
|
||||
}
|
||||
Location getLocation();
|
||||
|
||||
/**
|
||||
* Get the number of eggs being laid
|
||||
*
|
||||
* @return Number of eggs
|
||||
*/
|
||||
public int getEggCount() {
|
||||
return this.eggCount;
|
||||
}
|
||||
@IntRange(from = 1, to = 4) int getEggCount();
|
||||
|
||||
/**
|
||||
* Set the number of eggs being laid
|
||||
*
|
||||
* @param eggCount Number of eggs
|
||||
*/
|
||||
public void setEggCount(final int eggCount) {
|
||||
if (eggCount < 1) {
|
||||
this.cancelled = true;
|
||||
return;
|
||||
void setEggCount(@IntRange(from = 0, to = 4) int eggCount);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
this.eggCount = Math.min(eggCount, 4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-38
@@ -5,25 +5,11 @@ import org.bukkit.entity.Turtle;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a Turtle starts digging to lay eggs
|
||||
*/
|
||||
@NullMarked
|
||||
public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Location location;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public TurtleStartDiggingEvent(final Turtle turtle, final Location location) {
|
||||
super(turtle);
|
||||
this.location = location;
|
||||
}
|
||||
public interface TurtleStartDiggingEvent extends EntityEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* The turtle digging
|
||||
@@ -31,35 +17,19 @@ public class TurtleStartDiggingEvent extends EntityEvent implements Cancellable
|
||||
* @return The turtle
|
||||
*/
|
||||
@Override
|
||||
public Turtle getEntity() {
|
||||
return (Turtle) super.getEntity();
|
||||
}
|
||||
Turtle getEntity();
|
||||
|
||||
/**
|
||||
* Get the location where the turtle is digging
|
||||
*
|
||||
* @return Location where digging
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return this.location.clone();
|
||||
}
|
||||
Location getLocation();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-39
@@ -5,67 +5,38 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Fired when a witch consumes the potion in their hand to buff themselves.
|
||||
*/
|
||||
@NullMarked
|
||||
public class WitchConsumePotionEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private @Nullable ItemStack potion;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public WitchConsumePotionEvent(final Witch witch, final @Nullable ItemStack potion) {
|
||||
super(witch);
|
||||
this.potion = potion;
|
||||
}
|
||||
public interface WitchConsumePotionEvent extends EntityEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public Witch getEntity() {
|
||||
return (Witch) super.getEntity();
|
||||
}
|
||||
Witch getEntity();
|
||||
|
||||
/**
|
||||
* @return the potion the witch will consume and have the effects applied.
|
||||
*/
|
||||
public @Nullable ItemStack getPotion() {
|
||||
return this.potion;
|
||||
}
|
||||
@Nullable ItemStack getPotion();
|
||||
|
||||
/**
|
||||
* Sets the potion to be consumed and applied to the witch.
|
||||
*
|
||||
* @param potion The potion
|
||||
*/
|
||||
public void setPotion(final @Nullable ItemStack potion) {
|
||||
this.potion = potion != null ? potion.clone() : null;
|
||||
}
|
||||
void setPotion(@Nullable ItemStack potion);
|
||||
|
||||
/**
|
||||
* @return Event was cancelled or potion was {@code null}
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled || this.potion == null;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+9
-41
@@ -5,61 +5,29 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@NullMarked
|
||||
public class WitchReadyPotionEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private @Nullable ItemStack potion;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public WitchReadyPotionEvent(final Witch witch, final @Nullable ItemStack potion) {
|
||||
super(witch);
|
||||
this.potion = potion;
|
||||
}
|
||||
public interface WitchReadyPotionEvent extends EntityEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public Witch getEntity() {
|
||||
return (Witch) super.getEntity();
|
||||
}
|
||||
Witch getEntity();
|
||||
|
||||
/**
|
||||
* @return the potion the witch is readying to use
|
||||
*/
|
||||
public @Nullable ItemStack getPotion() {
|
||||
return this.potion;
|
||||
}
|
||||
@Nullable ItemStack getPotion();
|
||||
|
||||
/**
|
||||
* Sets the potion the which is going to hold and use
|
||||
*
|
||||
* @param potion The potion
|
||||
*/
|
||||
public void setPotion(final @Nullable ItemStack potion) {
|
||||
this.potion = potion != null ? potion.clone() : null;
|
||||
}
|
||||
void setPotion(@Nullable ItemStack potion);
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-44
@@ -6,76 +6,43 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Fired when a witch throws a potion at a player
|
||||
*/
|
||||
@NullMarked
|
||||
public class WitchThrowPotionEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final LivingEntity target;
|
||||
private @Nullable ItemStack potion;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public WitchThrowPotionEvent(final Witch witch, final LivingEntity target, final @Nullable ItemStack potion) {
|
||||
super(witch);
|
||||
this.target = target;
|
||||
this.potion = potion;
|
||||
}
|
||||
public interface WitchThrowPotionEvent extends EntityEvent, Cancellable {
|
||||
|
||||
@Override
|
||||
public Witch getEntity() {
|
||||
return (Witch) super.getEntity();
|
||||
}
|
||||
Witch getEntity();
|
||||
|
||||
/**
|
||||
* @return The target of the potion
|
||||
*/
|
||||
public LivingEntity getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
LivingEntity getTarget();
|
||||
|
||||
/**
|
||||
* @return The potion the witch will throw at a player
|
||||
*/
|
||||
public @Nullable ItemStack getPotion() {
|
||||
return this.potion;
|
||||
}
|
||||
@Nullable ItemStack getPotion();
|
||||
|
||||
/**
|
||||
* Sets the potion to be thrown at a player
|
||||
*
|
||||
* @param potion The potion
|
||||
*/
|
||||
public void setPotion(final @Nullable ItemStack potion) {
|
||||
this.potion = potion != null ? potion.clone() : null;
|
||||
}
|
||||
void setPotion(@Nullable ItemStack potion);
|
||||
|
||||
/**
|
||||
* @return Event was cancelled or potion was {@code null}
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled || this.potion == null;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package com.destroystokyo.paper.event.entity;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+4
-16
@@ -2,11 +2,7 @@ package com.destroystokyo.paper.event.inventory;
|
||||
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.inventory.GrindstoneInventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when an item is put in a slot for grinding in a Grindstone
|
||||
@@ -15,17 +11,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
@Deprecated(since = "1.16.1")
|
||||
@Warning
|
||||
public class PrepareGrindstoneEvent extends PrepareResultEvent {
|
||||
@NullMarked
|
||||
public interface PrepareGrindstoneEvent extends PrepareResultEvent {
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) {
|
||||
super(inventory, result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GrindstoneInventory getInventory() {
|
||||
return (GrindstoneInventory) super.getInventory();
|
||||
}
|
||||
|
||||
GrindstoneInventory getInventory();
|
||||
}
|
||||
+1
-34
@@ -1,42 +1,9 @@
|
||||
package com.destroystokyo.paper.event.inventory;
|
||||
|
||||
import org.bukkit.event.inventory.PrepareInventoryResultEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when an item is put in an inventory containing a result slot
|
||||
*/
|
||||
@NullMarked
|
||||
public class PrepareResultEvent extends PrepareInventoryResultEvent {
|
||||
|
||||
// HandlerList on PrepareInventoryResultEvent to ensure api compat
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PrepareResultEvent(final InventoryView inventory, final @Nullable ItemStack result) {
|
||||
super(inventory, result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get result item, may be {@code null}.
|
||||
*
|
||||
* @return result item
|
||||
*/
|
||||
@Override
|
||||
public @Nullable ItemStack getResult() {
|
||||
return super.getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set result item, may be {@code null}.
|
||||
*
|
||||
* @param result result item
|
||||
*/
|
||||
@Override
|
||||
public void setResult(final @Nullable ItemStack result) {
|
||||
super.setResult(result);
|
||||
}
|
||||
public interface PrepareResultEvent extends PrepareInventoryResultEvent {
|
||||
}
|
||||
+14
-50
@@ -1,67 +1,31 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @deprecated Not used
|
||||
* @deprecated not called anymore
|
||||
*/
|
||||
@Deprecated(since = "1.16.4", forRemoval = true)
|
||||
public class IllegalPacketEvent extends PlayerEvent {
|
||||
public interface IllegalPacketEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
boolean isShouldKick();
|
||||
|
||||
@Nullable private final String type;
|
||||
@Nullable private final String exceptionMessage;
|
||||
@Nullable private String kickMessage;
|
||||
private boolean shouldKick = true;
|
||||
void setShouldKick(boolean shouldKick);
|
||||
|
||||
@ApiStatus.Internal
|
||||
public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) {
|
||||
super(player);
|
||||
this.type = type;
|
||||
this.kickMessage = kickMessage;
|
||||
this.exceptionMessage = e.getMessage();
|
||||
}
|
||||
@Nullable String getKickMessage();
|
||||
|
||||
public boolean isShouldKick() {
|
||||
return this.shouldKick;
|
||||
}
|
||||
void setKickMessage(@Nullable String kickMessage);
|
||||
|
||||
public void setShouldKick(boolean shouldKick) {
|
||||
this.shouldKick = shouldKick;
|
||||
}
|
||||
@Nullable String getType();
|
||||
|
||||
@Nullable
|
||||
public String getKickMessage() {
|
||||
return this.kickMessage;
|
||||
}
|
||||
@Nullable String getExceptionMessage();
|
||||
|
||||
public void setKickMessage(@Nullable String kickMessage) {
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getExceptionMessage() {
|
||||
return this.exceptionMessage;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-48
@@ -2,79 +2,41 @@ package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.advancement.AdvancementProgress;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called after a player is granted a criteria in an advancement.
|
||||
* If cancelled the criteria will be revoked.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerAdvancementCriterionGrantEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Advancement advancement;
|
||||
private final String criterion;
|
||||
private final AdvancementProgress advancementProgress;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerAdvancementCriterionGrantEvent(final Player player, final Advancement advancement, final String criterion) {
|
||||
super(player);
|
||||
this.advancement = advancement;
|
||||
this.criterion = criterion;
|
||||
this.advancementProgress = player.getAdvancementProgress(advancement);
|
||||
}
|
||||
public interface PlayerAdvancementCriterionGrantEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Get the advancement which has been affected.
|
||||
*
|
||||
* @return affected advancement
|
||||
*/
|
||||
public Advancement getAdvancement() {
|
||||
return this.advancement;
|
||||
}
|
||||
Advancement getAdvancement();
|
||||
|
||||
/**
|
||||
* Get the criterion which has been granted.
|
||||
*
|
||||
* @return granted criterion
|
||||
*/
|
||||
public String getCriterion() {
|
||||
return this.criterion;
|
||||
}
|
||||
String getCriterion();
|
||||
|
||||
/**
|
||||
* Gets the current AdvancementProgress.
|
||||
* Gets the current {@link AdvancementProgress}.
|
||||
*
|
||||
* @return advancement progress
|
||||
*/
|
||||
public AdvancementProgress getAdvancementProgress() {
|
||||
return this.advancementProgress;
|
||||
}
|
||||
AdvancementProgress getAdvancementProgress();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-43
@@ -2,13 +2,11 @@ package com.destroystokyo.paper.event.player;
|
||||
|
||||
import java.util.Set;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
@@ -19,23 +17,8 @@ import static org.bukkit.Material.*;
|
||||
* Not currently called for environmental factors though it <strong>MAY BE IN THE FUTURE</strong>
|
||||
* @apiNote Use {@link io.papermc.paper.event.entity.EntityEquipmentChangedEvent} for all entity equipment changes
|
||||
*/
|
||||
@NullMarked
|
||||
@ApiStatus.Obsolete(since = "1.21.4")
|
||||
public class PlayerArmorChangeEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final SlotType slotType;
|
||||
private final ItemStack oldItem;
|
||||
private final ItemStack newItem;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerArmorChangeEvent(final Player player, final SlotType slotType, final ItemStack oldItem, final ItemStack newItem) {
|
||||
super(player);
|
||||
this.slotType = slotType;
|
||||
this.oldItem = oldItem;
|
||||
this.newItem = newItem;
|
||||
}
|
||||
public interface PlayerArmorChangeEvent extends PlayerEvent {
|
||||
|
||||
/**
|
||||
* Gets the type of slot being altered.
|
||||
@@ -44,56 +27,41 @@ public class PlayerArmorChangeEvent extends PlayerEvent {
|
||||
* @deprecated {@link SlotType} does not accurately represent what item types are valid in each slot. Use {@link #getSlot()} instead.
|
||||
*/
|
||||
@Deprecated(since = "1.21.4")
|
||||
public SlotType getSlotType() {
|
||||
return this.slotType;
|
||||
}
|
||||
SlotType getSlotType();
|
||||
|
||||
/**
|
||||
* Gets the slot being altered.
|
||||
*
|
||||
* @return slot being altered
|
||||
*/
|
||||
public EquipmentSlot getSlot() {
|
||||
return switch (this.slotType) {
|
||||
case HEAD -> EquipmentSlot.HEAD;
|
||||
case CHEST -> EquipmentSlot.CHEST;
|
||||
case LEGS -> EquipmentSlot.LEGS;
|
||||
case FEET -> EquipmentSlot.FEET;
|
||||
};
|
||||
}
|
||||
EquipmentSlot getSlot();
|
||||
|
||||
/**
|
||||
* Gets the existing item that's being replaced
|
||||
*
|
||||
* @return old item
|
||||
*/
|
||||
public ItemStack getOldItem() {
|
||||
return this.oldItem;
|
||||
}
|
||||
ItemStack getOldItem();
|
||||
|
||||
/**
|
||||
* Gets the new item that's replacing the old
|
||||
*
|
||||
* @return new item
|
||||
*/
|
||||
public ItemStack getNewItem() {
|
||||
return this.newItem;
|
||||
}
|
||||
ItemStack getNewItem();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated {@link SlotType} does not accurately represent what item types are valid in each slot.
|
||||
*/
|
||||
@Deprecated(since = "1.21.4")
|
||||
public enum SlotType {
|
||||
enum SlotType {
|
||||
HEAD(COPPER_HELMET, NETHERITE_HELMET, DIAMOND_HELMET, GOLDEN_HELMET, IRON_HELMET, CHAINMAIL_HELMET, LEATHER_HELMET, CARVED_PUMPKIN, PLAYER_HEAD, SKELETON_SKULL, ZOMBIE_HEAD, CREEPER_HEAD, WITHER_SKELETON_SKULL, TURTLE_HELMET, DRAGON_HEAD, PIGLIN_HEAD),
|
||||
CHEST(COPPER_CHESTPLATE, NETHERITE_CHESTPLATE, DIAMOND_CHESTPLATE, GOLDEN_CHESTPLATE, IRON_CHESTPLATE, CHAINMAIL_CHESTPLATE, LEATHER_CHESTPLATE, ELYTRA),
|
||||
LEGS(COPPER_LEGGINGS, NETHERITE_LEGGINGS, DIAMOND_LEGGINGS, GOLDEN_LEGGINGS, IRON_LEGGINGS, CHAINMAIL_LEGGINGS, LEATHER_LEGGINGS),
|
||||
|
||||
+16
-44
@@ -1,12 +1,9 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when processing a player's attack on an entity when the player's attack strength cooldown is reset.
|
||||
@@ -17,41 +14,22 @@ import org.jspecify.annotations.NullMarked;
|
||||
* Additionally, the cancellation of event is misleading as the client will reset the cooldown manually.
|
||||
* So there is no way for the server to control this.
|
||||
*/
|
||||
@NullMarked
|
||||
@Deprecated(since = "26.1", forRemoval = true)
|
||||
public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Entity attackedEntity;
|
||||
private final float cooledAttackStrength;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerAttackEntityCooldownResetEvent(final Player player, final Entity attackedEntity, final float cooledAttackStrength) {
|
||||
super(player);
|
||||
this.attackedEntity = attackedEntity;
|
||||
this.cooledAttackStrength = cooledAttackStrength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the players cooldown attack strength when they initiated the attack
|
||||
*
|
||||
* @return returns the original player cooldown value
|
||||
*/
|
||||
public float getCooledAttackStrength() {
|
||||
return this.cooledAttackStrength;
|
||||
}
|
||||
public interface PlayerAttackEntityCooldownResetEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Returns the entity attacked by the player
|
||||
*
|
||||
* @return the entity attacked by the player
|
||||
*/
|
||||
public Entity getAttackedEntity() {
|
||||
return this.attackedEntity;
|
||||
}
|
||||
Entity getAttackedEntity();
|
||||
|
||||
/**
|
||||
* Get the value of the players cooldown attack strength when they initiated the attack
|
||||
*
|
||||
* @return returns the original player cooldown value
|
||||
*/
|
||||
float getCooledAttackStrength();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -59,9 +37,7 @@ public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements
|
||||
* If an attack cooldown event is cancelled, the players attack strength will remain at the same value instead of being reset.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -69,16 +45,12 @@ public class PlayerAttackEntityCooldownResetEvent extends PlayerEvent implements
|
||||
* Cancelling this event will prevent the target player from having their cooldown reset from attacking this entity
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+24
-95
@@ -1,128 +1,57 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import com.destroystokyo.paper.ClientOption;
|
||||
import com.destroystokyo.paper.ClientOption.ChatVisibility;
|
||||
import com.destroystokyo.paper.ClientOption.ParticleVisibility;
|
||||
import com.destroystokyo.paper.SkinParts;
|
||||
import java.util.Map;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.MainHand;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when the player changes their client settings
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerClientOptionsChangeEvent extends PlayerEvent {
|
||||
public interface PlayerClientOptionsChangeEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
String getLocale();
|
||||
|
||||
private final String locale;
|
||||
private final int viewDistance;
|
||||
private final ChatVisibility chatVisibility;
|
||||
private final boolean chatColors;
|
||||
private final SkinParts skinparts;
|
||||
private final MainHand mainHand;
|
||||
private final boolean allowsServerListings;
|
||||
private final boolean textFilteringEnabled;
|
||||
private final ParticleVisibility particleVisibility;
|
||||
boolean hasLocaleChanged();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerClientOptionsChangeEvent(final Player player, final Map<ClientOption<?>, ?> options) {
|
||||
super(player);
|
||||
int getViewDistance();
|
||||
|
||||
this.locale = (String) options.get(ClientOption.LOCALE);
|
||||
this.viewDistance = (int) options.get(ClientOption.VIEW_DISTANCE);
|
||||
this.chatVisibility = (ChatVisibility) options.get(ClientOption.CHAT_VISIBILITY);
|
||||
this.chatColors = (boolean) options.get(ClientOption.CHAT_COLORS_ENABLED);
|
||||
this.skinparts = (SkinParts) options.get(ClientOption.SKIN_PARTS);
|
||||
this.mainHand = (MainHand) options.get(ClientOption.MAIN_HAND);
|
||||
this.allowsServerListings = (boolean) options.get(ClientOption.ALLOW_SERVER_LISTINGS);
|
||||
this.textFilteringEnabled = (boolean) options.get(ClientOption.TEXT_FILTERING_ENABLED);
|
||||
this.particleVisibility = (ParticleVisibility) options.get(ClientOption.PARTICLE_VISIBILITY);
|
||||
}
|
||||
boolean hasViewDistanceChanged();
|
||||
|
||||
public String getLocale() {
|
||||
return this.locale;
|
||||
}
|
||||
ChatVisibility getChatVisibility();
|
||||
|
||||
public boolean hasLocaleChanged() {
|
||||
return !this.locale.equals(this.player.getClientOption(ClientOption.LOCALE));
|
||||
}
|
||||
boolean hasChatVisibilityChanged();
|
||||
|
||||
public int getViewDistance() {
|
||||
return this.viewDistance;
|
||||
}
|
||||
boolean hasChatColorsEnabled();
|
||||
|
||||
public boolean hasViewDistanceChanged() {
|
||||
return this.viewDistance != this.player.getClientOption(ClientOption.VIEW_DISTANCE);
|
||||
}
|
||||
boolean hasChatColorsEnabledChanged();
|
||||
|
||||
public ChatVisibility getChatVisibility() {
|
||||
return this.chatVisibility;
|
||||
}
|
||||
SkinParts getSkinParts();
|
||||
|
||||
public boolean hasChatVisibilityChanged() {
|
||||
return this.chatVisibility != this.player.getClientOption(ClientOption.CHAT_VISIBILITY);
|
||||
}
|
||||
boolean hasSkinPartsChanged();
|
||||
|
||||
public boolean hasChatColorsEnabled() {
|
||||
return this.chatColors;
|
||||
}
|
||||
MainHand getMainHand();
|
||||
|
||||
public boolean hasChatColorsEnabledChanged() {
|
||||
return this.chatColors != this.player.getClientOption(ClientOption.CHAT_COLORS_ENABLED);
|
||||
}
|
||||
boolean hasMainHandChanged();
|
||||
|
||||
public SkinParts getSkinParts() {
|
||||
return this.skinparts;
|
||||
}
|
||||
boolean hasTextFilteringEnabled();
|
||||
|
||||
public boolean hasSkinPartsChanged() {
|
||||
return this.skinparts.getRaw() != this.player.getClientOption(ClientOption.SKIN_PARTS).getRaw();
|
||||
}
|
||||
boolean hasTextFilteringChanged();
|
||||
|
||||
public MainHand getMainHand() {
|
||||
return this.mainHand;
|
||||
}
|
||||
boolean allowsServerListings();
|
||||
|
||||
public boolean hasMainHandChanged() {
|
||||
return this.mainHand != this.player.getClientOption(ClientOption.MAIN_HAND);
|
||||
}
|
||||
boolean hasAllowServerListingsChanged();
|
||||
|
||||
public boolean hasTextFilteringEnabled() {
|
||||
return this.textFilteringEnabled;
|
||||
}
|
||||
ParticleVisibility getParticleVisibility();
|
||||
|
||||
public boolean hasTextFilteringChanged() {
|
||||
return this.textFilteringEnabled != this.player.getClientOption(ClientOption.TEXT_FILTERING_ENABLED);
|
||||
}
|
||||
boolean hasParticleVisibilityChanged();
|
||||
|
||||
public boolean allowsServerListings() {
|
||||
return this.allowsServerListings;
|
||||
}
|
||||
|
||||
public boolean hasAllowServerListingsChanged() {
|
||||
return this.allowsServerListings != this.player.getClientOption(ClientOption.ALLOW_SERVER_LISTINGS);
|
||||
}
|
||||
|
||||
public ParticleVisibility getParticleVisibility() {
|
||||
return this.particleVisibility;
|
||||
}
|
||||
|
||||
public boolean hasParticleVisibilityChanged() {
|
||||
return this.particleVisibility != this.player.getClientOption(ClientOption.PARTICLE_VISIBILITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-36
@@ -1,16 +1,14 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import io.papermc.paper.event.connection.ConnectionEvent;
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This event is invoked when a player has disconnected. It is guaranteed that,
|
||||
* if the server is in online-mode, that the provided uuid and username have been
|
||||
* validated.
|
||||
@@ -34,50 +32,27 @@ import org.jspecify.annotations.NullMarked;
|
||||
* The event may be invoked asynchronously or synchronously. Plugins should check
|
||||
* {@link Event#isAsynchronous()} and handle accordingly.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerConnectionCloseEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final UUID playerUniqueId;
|
||||
private final String playerName;
|
||||
private final InetAddress ipAddress;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerConnectionCloseEvent(final UUID playerUniqueId, final String playerName, final InetAddress ipAddress, final boolean async) {
|
||||
super(async);
|
||||
this.playerUniqueId = playerUniqueId;
|
||||
this.playerName = playerName;
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
public interface PlayerConnectionCloseEvent extends ConnectionEvent {
|
||||
|
||||
/**
|
||||
* Returns the {@code UUID} of the player disconnecting.
|
||||
* Returns the {@link UUID} of the player disconnecting.
|
||||
*/
|
||||
public UUID getPlayerUniqueId() {
|
||||
return this.playerUniqueId;
|
||||
}
|
||||
UUID getPlayerUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the name of the player disconnecting.
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return this.playerName;
|
||||
}
|
||||
String getPlayerName();
|
||||
|
||||
/**
|
||||
* Returns the player's IP address.
|
||||
*/
|
||||
public InetAddress getIpAddress() {
|
||||
return this.ipAddress;
|
||||
}
|
||||
InetAddress getIpAddress();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-54
@@ -1,99 +1,56 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a player boosts elytra flight with a firework
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerElytraBoostEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final Firework firework;
|
||||
private boolean consume = true;
|
||||
private final EquipmentSlot hand;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerElytraBoostEvent(final Player player, final ItemStack itemStack, final Firework firework, final EquipmentSlot hand) {
|
||||
super(player);
|
||||
this.itemStack = itemStack;
|
||||
this.firework = firework;
|
||||
this.hand = hand;
|
||||
}
|
||||
public interface PlayerElytraBoostEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Get the firework itemstack used
|
||||
*
|
||||
* @return ItemStack of firework
|
||||
*/
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* Get the firework entity that was spawned
|
||||
*
|
||||
* @return Firework entity
|
||||
*/
|
||||
public Firework getFirework() {
|
||||
return this.firework;
|
||||
}
|
||||
Firework getFirework();
|
||||
|
||||
/**
|
||||
* Get whether to consume the firework or not
|
||||
*
|
||||
* @return {@code true} to consume
|
||||
*/
|
||||
public boolean shouldConsume() {
|
||||
return this.consume;
|
||||
}
|
||||
boolean shouldConsume();
|
||||
|
||||
/**
|
||||
* Set whether to consume the firework or not
|
||||
*
|
||||
* @param consume {@code true} to consume
|
||||
*/
|
||||
public void setShouldConsume(final boolean consume) {
|
||||
this.consume = consume;
|
||||
}
|
||||
void setShouldConsume(boolean consume);
|
||||
|
||||
/**
|
||||
* Gets the hand holding the firework used for boosting this player.
|
||||
*
|
||||
* @return interaction hand
|
||||
*/
|
||||
public EquipmentSlot getHand() {
|
||||
return this.hand;
|
||||
}
|
||||
EquipmentSlot getHand();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+24
-96
@@ -1,15 +1,10 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -20,44 +15,14 @@ import org.jspecify.annotations.Nullable;
|
||||
*
|
||||
* <p>WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS</p>
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final String originalHandshake;
|
||||
private final String originalSocketAddressHostname;
|
||||
private @Nullable String serverHostname;
|
||||
private @Nullable String socketAddressHostname;
|
||||
private @Nullable UUID uniqueId;
|
||||
private @Nullable String propertiesJson;
|
||||
private boolean failed;
|
||||
private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW);
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.Internal
|
||||
public PlayerHandshakeEvent(final String originalHandshake, final boolean cancelled) {
|
||||
this(originalHandshake, "127.0.0.1", cancelled);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerHandshakeEvent(final String originalHandshake, final String originalSocketAddressHostname, final boolean cancelled) {
|
||||
super(true);
|
||||
this.originalHandshake = originalHandshake;
|
||||
this.originalSocketAddressHostname = originalSocketAddressHostname;
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
public interface PlayerHandshakeEvent extends Event, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the original handshake string.
|
||||
*
|
||||
* @return the original handshake string
|
||||
*/
|
||||
public String getOriginalHandshake() {
|
||||
return this.originalHandshake;
|
||||
}
|
||||
String getOriginalHandshake();
|
||||
|
||||
/**
|
||||
* Gets the original socket address hostname.
|
||||
@@ -67,9 +32,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the original socket address hostname
|
||||
*/
|
||||
public String getOriginalSocketAddressHostname() {
|
||||
return this.originalSocketAddressHostname;
|
||||
}
|
||||
String getOriginalSocketAddressHostname();
|
||||
|
||||
/**
|
||||
* Gets the server hostname string.
|
||||
@@ -78,9 +41,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the server hostname string
|
||||
*/
|
||||
public @Nullable String getServerHostname() {
|
||||
return this.serverHostname;
|
||||
}
|
||||
@Nullable String getServerHostname();
|
||||
|
||||
/**
|
||||
* Sets the server hostname string.
|
||||
@@ -89,9 +50,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param serverHostname the server hostname string
|
||||
*/
|
||||
public void setServerHostname(final String serverHostname) {
|
||||
this.serverHostname = serverHostname;
|
||||
}
|
||||
void setServerHostname(String serverHostname);
|
||||
|
||||
/**
|
||||
* Gets the socket address hostname string.
|
||||
@@ -100,9 +59,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the socket address hostname string
|
||||
*/
|
||||
public @Nullable String getSocketAddressHostname() {
|
||||
return this.socketAddressHostname;
|
||||
}
|
||||
@Nullable String getSocketAddressHostname();
|
||||
|
||||
/**
|
||||
* Sets the socket address hostname string.
|
||||
@@ -111,27 +68,21 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param socketAddressHostname the socket address hostname string
|
||||
*/
|
||||
public void setSocketAddressHostname(final String socketAddressHostname) {
|
||||
this.socketAddressHostname = socketAddressHostname;
|
||||
}
|
||||
void setSocketAddressHostname(String socketAddressHostname);
|
||||
|
||||
/**
|
||||
* Gets the unique id.
|
||||
*
|
||||
* @return the unique id
|
||||
*/
|
||||
public @Nullable UUID getUniqueId() {
|
||||
return this.uniqueId;
|
||||
}
|
||||
@Nullable UUID getUniqueId();
|
||||
|
||||
/**
|
||||
* Sets the unique id.
|
||||
*
|
||||
* @param uniqueId the unique id
|
||||
*/
|
||||
public void setUniqueId(final UUID uniqueId) {
|
||||
this.uniqueId = uniqueId;
|
||||
}
|
||||
void setUniqueId(UUID uniqueId);
|
||||
|
||||
/**
|
||||
* Gets the profile properties.
|
||||
@@ -140,9 +91,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return the profile properties, as JSON
|
||||
*/
|
||||
public @Nullable String getPropertiesJson() {
|
||||
return this.propertiesJson;
|
||||
}
|
||||
@Nullable String getPropertiesJson();
|
||||
|
||||
/**
|
||||
* Determines if authentication failed.
|
||||
@@ -152,9 +101,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return {@code true} if authentication failed, {@code false} otherwise
|
||||
*/
|
||||
public boolean isFailed() {
|
||||
return this.failed;
|
||||
}
|
||||
boolean isFailed();
|
||||
|
||||
/**
|
||||
* Sets if authentication failed and the client should be disconnected.
|
||||
@@ -164,9 +111,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param failed {@code true} if authentication failed, {@code false} otherwise
|
||||
*/
|
||||
public void setFailed(final boolean failed) {
|
||||
this.failed = failed;
|
||||
}
|
||||
void setFailed(boolean failed);
|
||||
|
||||
/**
|
||||
* Sets the profile properties.
|
||||
@@ -175,27 +120,21 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param propertiesJson the profile properties, as JSON
|
||||
*/
|
||||
public void setPropertiesJson(final String propertiesJson) {
|
||||
this.propertiesJson = propertiesJson;
|
||||
}
|
||||
void setPropertiesJson(String propertiesJson);
|
||||
|
||||
/**
|
||||
* Gets the message to display to the client when authentication fails.
|
||||
*
|
||||
* @return the message to display to the client
|
||||
*/
|
||||
public Component failMessage() {
|
||||
return this.failMessage;
|
||||
}
|
||||
Component failMessage();
|
||||
|
||||
/**
|
||||
* Sets the message to display to the client when authentication fails.
|
||||
*
|
||||
* @param failMessage the message to display to the client
|
||||
*/
|
||||
public void failMessage(final Component failMessage) {
|
||||
this.failMessage = failMessage;
|
||||
}
|
||||
void failMessage(Component failMessage);
|
||||
|
||||
/**
|
||||
* Gets the message to display to the client when authentication fails.
|
||||
@@ -204,9 +143,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
* @deprecated use {@link #failMessage()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getFailMessage() {
|
||||
return LegacyComponentSerializer.legacySection().serialize(this.failMessage());
|
||||
}
|
||||
String getFailMessage();
|
||||
|
||||
/**
|
||||
* Sets the message to display to the client when authentication fails.
|
||||
@@ -215,10 +152,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
* @deprecated use {@link #failMessage(Component)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setFailMessage(final String failMessage) {
|
||||
Preconditions.checkArgument(failMessage != null && !failMessage.isEmpty(), "fail message cannot be null or empty");
|
||||
this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage));
|
||||
}
|
||||
void setFailMessage(String failMessage);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -227,9 +161,7 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
* be processed.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -238,16 +170,12 @@ public class PlayerHandshakeEvent extends Event implements Cancellable {
|
||||
* be processed.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when the server detects the player is jumping.
|
||||
@@ -17,66 +13,21 @@ import org.jspecify.annotations.NullMarked;
|
||||
* when checking for jumps via {@link PlayerMoveEvent}, this event is fired whenever
|
||||
* the server detects that the player is jumping.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Location to;
|
||||
private Location from;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerJumpEvent(final Player player, final Location from, final Location to) {
|
||||
super(player);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If this event is cancelled, the player will be moved or
|
||||
* teleported back to the Location as defined by {@link #getFrom()}. This will not
|
||||
* fire an event
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If this event is cancelled, the player will be moved or
|
||||
* teleported back to the Location as defined by {@link #getFrom()}. This will not
|
||||
* fire an event
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
public interface PlayerJumpEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the location this player jumped from
|
||||
*
|
||||
* @return Location the player jumped from
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
Location getFrom();
|
||||
|
||||
/**
|
||||
* Sets the location to mark as where the player jumped from
|
||||
*
|
||||
* @param from New location to mark as the players previous location
|
||||
*/
|
||||
public void setFrom(final Location from) {
|
||||
Preconditions.checkArgument(from != null, "Cannot use null from location!");
|
||||
Preconditions.checkArgument(from.getWorld() != null, "Cannot use from location with null world!");
|
||||
this.from = from.clone();
|
||||
}
|
||||
void setFrom(Location from);
|
||||
|
||||
/**
|
||||
* Gets the location this player jumped to
|
||||
@@ -86,16 +37,32 @@ public class PlayerJumpEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @return Location the player jumped to
|
||||
*/
|
||||
public Location getTo() {
|
||||
return this.to.clone();
|
||||
}
|
||||
Location getTo();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If this event is cancelled, the player will be moved or
|
||||
* teleported back to the Location as defined by {@link #getFrom()}. This will not
|
||||
* fire an event
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* If this event is cancelled, the player will be moved or
|
||||
* teleported back to the Location as defined by {@link #getFrom()}. This will not
|
||||
* fire an event
|
||||
*/
|
||||
@Override
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-49
@@ -1,14 +1,11 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a player shoots a projectile.
|
||||
@@ -17,76 +14,40 @@ import org.jspecify.annotations.NullMarked;
|
||||
* of a bow or crossbow. A plugin may listen to {@link EntityShootBowEvent}
|
||||
* for these actions instead.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerLaunchProjectileEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Projectile projectile;
|
||||
private final ItemStack itemStack;
|
||||
private boolean consumeItem = true;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerLaunchProjectileEvent(final Player shooter, final ItemStack itemStack, final Projectile projectile) {
|
||||
super(shooter);
|
||||
this.itemStack = itemStack;
|
||||
this.projectile = projectile;
|
||||
}
|
||||
public interface PlayerLaunchProjectileEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the projectile which will be launched by this event
|
||||
*
|
||||
* @return the launched projectile
|
||||
*/
|
||||
public Projectile getProjectile() {
|
||||
return this.projectile;
|
||||
}
|
||||
Projectile getProjectile();
|
||||
|
||||
/**
|
||||
* Get the ItemStack used to fire the projectile
|
||||
*
|
||||
* @return The ItemStack used
|
||||
*/
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* Get whether to consume the ItemStack or not
|
||||
*
|
||||
* @return {@code true} to consume
|
||||
*/
|
||||
public boolean shouldConsume() {
|
||||
return this.consumeItem;
|
||||
}
|
||||
boolean shouldConsume();
|
||||
|
||||
/**
|
||||
* Set whether to consume the ItemStack or not
|
||||
*
|
||||
* @param consumeItem {@code true} to consume
|
||||
*/
|
||||
public void setShouldConsume(final boolean consumeItem) {
|
||||
this.consumeItem = consumeItem;
|
||||
}
|
||||
void setShouldConsume(boolean consumeItem);
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+9
-35
@@ -24,41 +24,19 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a player is attempting to pick up an experience orb
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ExperienceOrb experienceOrb;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerPickupExperienceEvent(final Player player, final ExperienceOrb experienceOrb) {
|
||||
super(player);
|
||||
this.experienceOrb = experienceOrb;
|
||||
}
|
||||
public interface PlayerPickupExperienceEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* @return Returns the Orb that the player is picking up
|
||||
* @return the experience orb that the player is picking up
|
||||
*/
|
||||
public ExperienceOrb getExperienceOrb() {
|
||||
return this.experienceOrb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
ExperienceOrb getExperienceOrb();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -66,16 +44,12 @@ public class PlayerPickupExperienceEvent extends PlayerEvent implements Cancella
|
||||
* If {@code true}, cancels picking up the experience orb, leaving it in the world
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+9
-29
@@ -2,31 +2,13 @@ package com.destroystokyo.paper.event.player;
|
||||
|
||||
import io.papermc.paper.event.player.AbstractRespawnEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired after a player has respawned
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerPostRespawnEvent extends AbstractRespawnEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerPostRespawnEvent(
|
||||
final Player respawnPlayer,
|
||||
final Location respawnLocation,
|
||||
final boolean isBedSpawn,
|
||||
final boolean isAnchorSpawn,
|
||||
final boolean missingRespawnBlock,
|
||||
final PlayerRespawnEvent.RespawnReason respawnReason
|
||||
) {
|
||||
super(respawnPlayer, respawnLocation, isBedSpawn, isAnchorSpawn, missingRespawnBlock, respawnReason);
|
||||
}
|
||||
public interface PlayerPostRespawnEvent extends AbstractRespawnEvent {
|
||||
|
||||
/**
|
||||
* Returns the location of the respawned player.
|
||||
@@ -34,17 +16,15 @@ public class PlayerPostRespawnEvent extends AbstractRespawnEvent {
|
||||
* @return location of the respawned player
|
||||
* @see #getRespawnLocation()
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public Location getRespawnedLocation() {
|
||||
return super.getRespawnLocation();
|
||||
@ApiStatus.Obsolete(since = "1.21.5")
|
||||
default Location getRespawnedLocation() {
|
||||
return this.getRespawnLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-36
@@ -23,45 +23,25 @@
|
||||
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a player is firing a bow and the server is choosing an arrow to use.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ItemStack bow;
|
||||
private final ItemStack arrow;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerReadyArrowEvent(final Player player, final ItemStack bow, final ItemStack arrow) {
|
||||
super(player);
|
||||
this.bow = bow;
|
||||
this.arrow = arrow;
|
||||
}
|
||||
public interface PlayerReadyArrowEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* @return the player is using to fire the arrow
|
||||
*/
|
||||
public ItemStack getBow() {
|
||||
return this.bow;
|
||||
}
|
||||
ItemStack getBow();
|
||||
|
||||
/**
|
||||
* @return the arrow that is attempting to be used
|
||||
*/
|
||||
public ItemStack getArrow() {
|
||||
return this.arrow;
|
||||
}
|
||||
ItemStack getArrow();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -69,24 +49,18 @@ public class PlayerReadyArrowEvent extends PlayerEvent implements Cancellable {
|
||||
* Whether use of this arrow is cancelled. On cancel, the server will try the next arrow available and fire another event.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Cancel use of this arrow. On cancel, the server will try the next arrow available and fire another event.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-48
@@ -1,50 +1,28 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a player clicks a recipe in the recipe book
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private NamespacedKey recipe;
|
||||
private boolean makeAll;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerRecipeBookClickEvent(final Player player, final NamespacedKey recipe, final boolean makeAll) {
|
||||
super(player);
|
||||
this.recipe = recipe;
|
||||
this.makeAll = makeAll;
|
||||
}
|
||||
public interface PlayerRecipeBookClickEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the namespaced key of the recipe that was clicked by the player
|
||||
*
|
||||
* @return The namespaced key of the recipe
|
||||
*/
|
||||
public NamespacedKey getRecipe() {
|
||||
return this.recipe;
|
||||
}
|
||||
NamespacedKey getRecipe();
|
||||
|
||||
/**
|
||||
* Changes what recipe is requested. This sets the requested recipe to the recipe with the given key
|
||||
*
|
||||
* @param recipe The key of the recipe that should be requested
|
||||
*/
|
||||
public void setRecipe(final NamespacedKey recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
void setRecipe(NamespacedKey recipe);
|
||||
|
||||
/**
|
||||
* Gets a boolean which indicates whether the player requested to make the maximum amount of results. This is
|
||||
@@ -52,9 +30,7 @@ public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellab
|
||||
*
|
||||
* @return {@code true} if shift is pressed while the recipe is clicked
|
||||
*/
|
||||
public boolean isMakeAll() {
|
||||
return this.makeAll;
|
||||
}
|
||||
boolean isMakeAll();
|
||||
|
||||
/**
|
||||
* Sets whether the maximum amount of results should be made. If this is {@code true}, the request is handled as if
|
||||
@@ -62,26 +38,12 @@ public class PlayerRecipeBookClickEvent extends PlayerEvent implements Cancellab
|
||||
*
|
||||
* @param makeAll {@code true} if the request should attempt to make the maximum amount of results
|
||||
*/
|
||||
public void setMakeAll(final boolean makeAll) {
|
||||
this.makeAll = makeAll;
|
||||
}
|
||||
void setMakeAll(boolean makeAll);
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+17
-70
@@ -6,8 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -15,37 +13,14 @@ import org.jspecify.annotations.Nullable;
|
||||
* <br>
|
||||
* Cancelling this event will prevent the spawn from being set.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Cause cause;
|
||||
private @Nullable Location location;
|
||||
private boolean forced;
|
||||
private boolean notifyPlayer;
|
||||
private @Nullable Component notification;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerSetSpawnEvent(final Player player, final Cause cause, final @Nullable Location location, final boolean forced, final boolean notifyPlayer, final @Nullable Component notification) {
|
||||
super(player);
|
||||
this.cause = cause;
|
||||
this.location = location;
|
||||
this.forced = forced;
|
||||
this.notifyPlayer = notifyPlayer;
|
||||
this.notification = notification;
|
||||
}
|
||||
public interface PlayerSetSpawnEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the cause of this event.
|
||||
*
|
||||
* @return the cause
|
||||
*/
|
||||
public Cause getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
Cause getCause();
|
||||
|
||||
/**
|
||||
* Gets the location that the spawn is set to. The yaw
|
||||
@@ -55,9 +30,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @return the spawn location, or {@code null} if removing the location
|
||||
*/
|
||||
public @Nullable Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
@Nullable Location getLocation();
|
||||
|
||||
/**
|
||||
* Sets the location to be set as the spawn location. The yaw
|
||||
@@ -65,27 +38,21 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @param location the spawn location, or {@code null} to remove the spawn location
|
||||
*/
|
||||
public void setLocation(final @Nullable Location location) {
|
||||
this.location = location != null ? location.clone() : null;
|
||||
}
|
||||
void setLocation(@Nullable Location location);
|
||||
|
||||
/**
|
||||
* Gets if this is a force spawn location
|
||||
*
|
||||
* @return {@code true} if forced
|
||||
*/
|
||||
public boolean isForced() {
|
||||
return this.forced;
|
||||
}
|
||||
boolean isForced();
|
||||
|
||||
/**
|
||||
* Sets if this is a forced spawn location
|
||||
*
|
||||
* @param forced {@code true} to force
|
||||
*/
|
||||
public void setForced(final boolean forced) {
|
||||
this.forced = forced;
|
||||
}
|
||||
void setForced(boolean forced);
|
||||
|
||||
/**
|
||||
* Gets if this action will notify the player their spawn
|
||||
@@ -93,9 +60,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @return {@code true} to notify
|
||||
*/
|
||||
public boolean willNotifyPlayer() {
|
||||
return this.notifyPlayer;
|
||||
}
|
||||
boolean willNotifyPlayer();
|
||||
|
||||
/**
|
||||
* Sets if this action will notify the player that their spawn
|
||||
@@ -103,9 +68,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @param notifyPlayer {@code true} to notify
|
||||
*/
|
||||
public void setNotifyPlayer(final boolean notifyPlayer) {
|
||||
this.notifyPlayer = notifyPlayer;
|
||||
}
|
||||
void setNotifyPlayer(boolean notifyPlayer);
|
||||
|
||||
/**
|
||||
* Gets the notification message that will be sent to the player
|
||||
@@ -113,39 +76,23 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable {
|
||||
*
|
||||
* @return {@code null} if no notification
|
||||
*/
|
||||
public @Nullable Component getNotification() {
|
||||
return this.notification;
|
||||
}
|
||||
@Nullable Component getNotification();
|
||||
|
||||
/**
|
||||
* Sets the notification message that will be sent to the player.
|
||||
*
|
||||
* @param notification {@code null} to send no message
|
||||
*/
|
||||
public void setNotification(final @Nullable Component notification) {
|
||||
this.notification = notification;
|
||||
void setNotification(@Nullable Component notification);
|
||||
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public enum Cause {
|
||||
enum Cause {
|
||||
/**
|
||||
* When a player interacts successfully with a bed.
|
||||
*/
|
||||
|
||||
+8
-42
@@ -1,68 +1,34 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Triggered when a player starts spectating an entity in spectator mode.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerStartSpectatingEntityEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Entity currentSpectatorTarget;
|
||||
private final Entity newSpectatorTarget;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerStartSpectatingEntityEvent(final Player player, final Entity currentSpectatorTarget, final Entity newSpectatorTarget) {
|
||||
super(player);
|
||||
this.currentSpectatorTarget = currentSpectatorTarget;
|
||||
this.newSpectatorTarget = newSpectatorTarget;
|
||||
}
|
||||
public interface PlayerStartSpectatingEntityEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the entity that the player is currently spectating or themselves if they weren't spectating anything
|
||||
*
|
||||
* @return The entity the player is currently spectating (before they start spectating the new target).
|
||||
*/
|
||||
public Entity getCurrentSpectatorTarget() {
|
||||
return this.currentSpectatorTarget;
|
||||
}
|
||||
Entity getCurrentSpectatorTarget();
|
||||
|
||||
/**
|
||||
* Gets the new entity that the player will now be spectating
|
||||
*
|
||||
* @return The entity the player is now going to be spectating.
|
||||
*/
|
||||
public Entity getNewSpectatorTarget() {
|
||||
return this.newSpectatorTarget;
|
||||
}
|
||||
Entity getNewSpectatorTarget();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-36
@@ -1,55 +1,26 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Triggered when a player stops spectating an entity in spectator mode.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerStopSpectatingEntityEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Entity spectatorTarget;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerStopSpectatingEntityEvent(final Player player, final Entity spectatorTarget) {
|
||||
super(player);
|
||||
this.spectatorTarget = spectatorTarget;
|
||||
}
|
||||
public interface PlayerStopSpectatingEntityEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the entity that the player is spectating
|
||||
*
|
||||
* @return The entity the player is currently spectating (before they will stop).
|
||||
*/
|
||||
public Entity getSpectatorTarget() {
|
||||
return this.spectatorTarget;
|
||||
}
|
||||
Entity getSpectatorTarget();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+2
-17
@@ -1,32 +1,17 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.EndGateway;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when a teleport is triggered for an End Gateway
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent {
|
||||
|
||||
private final EndGateway gateway;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerTeleportEndGatewayEvent(final Player player, final Location from, final Location to, final EndGateway gateway) {
|
||||
super(player, from, to, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
|
||||
this.gateway = gateway;
|
||||
}
|
||||
public interface PlayerTeleportEndGatewayEvent extends PlayerTeleportEvent {
|
||||
|
||||
/**
|
||||
* The gateway triggering the teleport
|
||||
*
|
||||
* @return EndGateway used
|
||||
*/
|
||||
public EndGateway getGateway() {
|
||||
return this.gateway;
|
||||
}
|
||||
EndGateway getGateway();
|
||||
}
|
||||
+10
-40
@@ -1,13 +1,10 @@
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -17,51 +14,28 @@ import org.jspecify.annotations.Nullable;
|
||||
* This event may be called multiple times per interaction with different interaction hands
|
||||
* and with or without the clicked position.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerUseUnknownEntityEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final int entityId;
|
||||
private final boolean attack;
|
||||
private final EquipmentSlot hand;
|
||||
private final @Nullable Vector clickedPosition;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerUseUnknownEntityEvent(final Player player, final int entityId, final boolean attack, final EquipmentSlot hand, final @Nullable Vector clickedPosition) {
|
||||
super(player);
|
||||
this.entityId = entityId;
|
||||
this.attack = attack;
|
||||
this.hand = hand;
|
||||
this.clickedPosition = clickedPosition;
|
||||
}
|
||||
public interface PlayerUseUnknownEntityEvent extends PlayerEvent {
|
||||
|
||||
/**
|
||||
* Returns the entity id of the unknown entity that was interacted with.
|
||||
*
|
||||
* @return the entity id of the entity that was interacted with
|
||||
*/
|
||||
public int getEntityId() {
|
||||
return this.entityId;
|
||||
}
|
||||
int getEntityId();
|
||||
|
||||
/**
|
||||
* Returns whether the interaction was an attack.
|
||||
*
|
||||
* @return {@code true} if the player is attacking the entity, {@code false} if the player is interacting with the entity
|
||||
*/
|
||||
public boolean isAttack() {
|
||||
return this.attack;
|
||||
}
|
||||
boolean isAttack();
|
||||
|
||||
/**
|
||||
* Returns the hand used to perform this interaction.
|
||||
*
|
||||
* @return the hand used to interact
|
||||
*/
|
||||
public EquipmentSlot getHand() {
|
||||
return this.hand;
|
||||
}
|
||||
EquipmentSlot getHand();
|
||||
|
||||
/**
|
||||
* Returns the position relative to the entity that was clicked, or {@code null} if not available.
|
||||
@@ -70,16 +44,12 @@ public class PlayerUseUnknownEntityEvent extends PlayerEvent {
|
||||
* @return the position relative to the entity that was clicked, or {@code null} if not available
|
||||
* @see PlayerInteractAtEntityEvent
|
||||
*/
|
||||
public @Nullable Vector getClickedRelativePosition() {
|
||||
return this.clickedPosition != null ? this.clickedPosition.clone() : null;
|
||||
}
|
||||
@Nullable Vector getClickedRelativePosition();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package com.destroystokyo.paper.event.player;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+8
-27
@@ -28,31 +28,16 @@ import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import java.util.Set;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired once a profiles additional properties (such as textures) has been filled
|
||||
*/
|
||||
@NullMarked
|
||||
public class FillProfileEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final PlayerProfile profile;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public FillProfileEvent(final PlayerProfile profile) {
|
||||
super(!org.bukkit.Bukkit.isPrimaryThread());
|
||||
this.profile = profile;
|
||||
}
|
||||
public interface FillProfileEvent extends Event {
|
||||
|
||||
/**
|
||||
* @return The Profile that had properties filled
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
PlayerProfile getPlayerProfile();
|
||||
|
||||
/**
|
||||
* Same as .getPlayerProfile().getProperties()
|
||||
@@ -60,16 +45,12 @@ public class FillProfileEvent extends Event {
|
||||
* @return The new properties on the profile.
|
||||
* @see PlayerProfile#getProperties()
|
||||
*/
|
||||
public Set<ProfileProperty> getProperties() {
|
||||
return this.profile.getProperties();
|
||||
}
|
||||
Set<ProfileProperty> getProperties();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+10
-33
@@ -1,13 +1,9 @@
|
||||
package com.destroystokyo.paper.event.profile;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Allows a plugin to be notified anytime AFTER a Profile has been looked up from the Mojang API
|
||||
@@ -16,52 +12,33 @@ import java.util.UUID;
|
||||
* No guarantees are made about thread execution context for this event. If you need to know, check
|
||||
* {@link Event#isAsynchronous()}
|
||||
*/
|
||||
@NullMarked
|
||||
public class LookupProfileEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final PlayerProfile profile;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public LookupProfileEvent(final PlayerProfile profile) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.profile = profile;
|
||||
}
|
||||
public interface LookupProfileEvent extends Event {
|
||||
|
||||
/**
|
||||
* Gets the name of the profile that was looked up.
|
||||
*
|
||||
* @return the name of the profile
|
||||
*/
|
||||
public String getName() {
|
||||
return Objects.requireNonNull(this.profile.getName(), "profile name");
|
||||
}
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the UUID of the profile that was looked up.
|
||||
*
|
||||
* @return the UUID of the profile
|
||||
*/
|
||||
public UUID getId() {
|
||||
return Objects.requireNonNull(this.profile.getId(), "profile id");
|
||||
}
|
||||
UUID getId();
|
||||
|
||||
/**
|
||||
* @return The profile that was recently looked up. This profile can be mutated
|
||||
* @deprecated This event is only called after UUID lookups, properties set here will be ignored. Use {@link FillProfileEvent} for setting properties.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.9")
|
||||
public PlayerProfile getPlayerProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
PlayerProfile getPlayerProfile();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-27
@@ -28,33 +28,18 @@ import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Fired when the server is requesting to fill in properties of an incomplete profile, such as textures.
|
||||
* <p>
|
||||
* Allows plugins to pre-populate cached properties and avoid a call to the Mojang API
|
||||
*/
|
||||
@NullMarked
|
||||
public class PreFillProfileEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final PlayerProfile profile;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PreFillProfileEvent(final PlayerProfile profile) {
|
||||
super(!org.bukkit.Bukkit.isPrimaryThread());
|
||||
this.profile = profile;
|
||||
}
|
||||
public interface PreFillProfileEvent extends Event {
|
||||
|
||||
/**
|
||||
* @return The profile that needs its properties filled
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
PlayerProfile getPlayerProfile();
|
||||
|
||||
/**
|
||||
* Sets the properties on the profile, avoiding the call to the Mojang API
|
||||
@@ -63,16 +48,12 @@ public class PreFillProfileEvent extends Event {
|
||||
* @param properties The properties to set/append
|
||||
* @see PlayerProfile#setProperties(Collection)
|
||||
*/
|
||||
public void setProperties(final Collection<ProfileProperty> properties) {
|
||||
this.profile.setProperties(properties);
|
||||
}
|
||||
void setProperties(Collection<ProfileProperty> properties);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+12
-46
@@ -1,14 +1,10 @@
|
||||
package com.destroystokyo.paper.event.profile;
|
||||
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -21,28 +17,12 @@ import org.jspecify.annotations.Nullable;
|
||||
* No guarantees are made about thread execution context for this event. If you need to know, check
|
||||
* {@link Event#isAsynchronous()}
|
||||
*/
|
||||
@NullMarked
|
||||
public class PreLookupProfileEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final String name;
|
||||
|
||||
private @Nullable UUID uuid;
|
||||
private Set<ProfileProperty> properties = new HashSet<>();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PreLookupProfileEvent(final String name) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.name = name;
|
||||
}
|
||||
public interface PreLookupProfileEvent extends Event {
|
||||
|
||||
/**
|
||||
* @return Name of the profile
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* If this value is left {@code null} by the completion of the event call, then the server will
|
||||
@@ -51,9 +31,7 @@ public class PreLookupProfileEvent extends Event {
|
||||
*
|
||||
* @return The UUID of the profile if it has already been provided by a plugin
|
||||
*/
|
||||
public @Nullable UUID getUUID() {
|
||||
return this.uuid;
|
||||
}
|
||||
@Nullable UUID getUUID();
|
||||
|
||||
/**
|
||||
* Sets the UUID for this player name. This will skip the initial API call to find the players UUID.
|
||||
@@ -62,9 +40,7 @@ public class PreLookupProfileEvent extends Event {
|
||||
*
|
||||
* @param uuid the UUID to set for the profile or {@code null} to reset
|
||||
*/
|
||||
public void setUUID(final @Nullable UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
void setUUID(@Nullable UUID uuid);
|
||||
|
||||
/**
|
||||
* @return The currently pending pre-populated properties.
|
||||
@@ -72,9 +48,7 @@ public class PreLookupProfileEvent extends Event {
|
||||
* @deprecated This event is only called for UUID lookups, properties set here will be ignored. Use {@link PreFillProfileEvent} for setting properties.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.9")
|
||||
public Set<ProfileProperty> getProfileProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
Set<ProfileProperty> getProfileProperties();
|
||||
|
||||
/**
|
||||
* Clears any existing pre-populated properties and uses the supplied properties
|
||||
@@ -84,10 +58,7 @@ public class PreLookupProfileEvent extends Event {
|
||||
* @deprecated This event is only called for UUID lookups, properties set here will be ignored. Use {@link PreFillProfileEvent} for setting properties.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.9")
|
||||
public void setProfileProperties(final Set<ProfileProperty> properties) {
|
||||
this.properties = new HashSet<>();
|
||||
this.properties.addAll(properties);
|
||||
}
|
||||
void setProfileProperties(Set<ProfileProperty> properties);
|
||||
|
||||
/**
|
||||
* Adds any properties currently missing to the pre-populated properties set, replacing any that already were set. Use {@link PreFillProfileEvent} for setting properties.
|
||||
@@ -97,17 +68,12 @@ public class PreLookupProfileEvent extends Event {
|
||||
* @deprecated This event is only called for UUID lookups, properties set here will be ignored.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.21.9")
|
||||
public void addProfileProperties(final Set<ProfileProperty> properties) {
|
||||
this.properties.addAll(properties);
|
||||
}
|
||||
void addProfileProperties(Set<ProfileProperty> properties);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
+15
-56
@@ -25,12 +25,9 @@ package com.destroystokyo.paper.event.profile;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -39,102 +36,64 @@ import org.jspecify.annotations.Nullable;
|
||||
* Plugins may override/control the servers whitelist with this event,
|
||||
* and dynamically change the kick message.
|
||||
*/
|
||||
@NullMarked
|
||||
public class ProfileWhitelistVerifyEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final PlayerProfile profile;
|
||||
private final boolean whitelistEnabled;
|
||||
private final boolean isOp;
|
||||
private boolean whitelisted;
|
||||
private @Nullable Component kickMessage;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ProfileWhitelistVerifyEvent(final PlayerProfile profile, final boolean whitelistEnabled, final boolean whitelisted, final boolean isOp, final @Nullable Component kickMessage) {
|
||||
this.profile = profile;
|
||||
this.whitelistEnabled = whitelistEnabled;
|
||||
this.whitelisted = whitelisted;
|
||||
this.isOp = isOp;
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
public interface ProfileWhitelistVerifyEvent extends Event {
|
||||
|
||||
/**
|
||||
* @return the currently planned message to send to the user if they are not whitelisted
|
||||
* @deprecated use {@link #kickMessage()}
|
||||
*/
|
||||
@Deprecated
|
||||
public @Nullable String getKickMessage() {
|
||||
return this.kickMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.kickMessage);
|
||||
}
|
||||
@Nullable String getKickMessage();
|
||||
|
||||
/**
|
||||
* @param kickMessage The message to send to the player on kick if not whitelisted. May set to {@code null} to use the server configured default
|
||||
* @deprecated Use {@link #kickMessage(Component)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKickMessage(final @Nullable String kickMessage) {
|
||||
this.kickMessage(kickMessage == null ? null : LegacyComponentSerializer.legacySection().deserialize(kickMessage));
|
||||
}
|
||||
void setKickMessage(@Nullable String kickMessage);
|
||||
|
||||
/**
|
||||
* @return the currently planned message to send to the user if they are not whitelisted
|
||||
*/
|
||||
@Contract(pure = true)
|
||||
public @Nullable Component kickMessage() {
|
||||
return this.kickMessage;
|
||||
}
|
||||
@Nullable Component kickMessage();
|
||||
|
||||
/**
|
||||
* @param kickMessage The message to send to the player on kick if not whitelisted. May set to {@code null} to use the server configured default
|
||||
*/
|
||||
public void kickMessage(final @Nullable Component kickMessage) {
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
void kickMessage(@Nullable Component kickMessage);
|
||||
|
||||
/**
|
||||
* @return The profile of the player trying to connect
|
||||
*/
|
||||
public PlayerProfile getPlayerProfile() {
|
||||
return this.profile;
|
||||
}
|
||||
PlayerProfile getPlayerProfile();
|
||||
|
||||
/**
|
||||
* @return Whether the player is whitelisted to play on this server (whitelist may be off is why it's true)
|
||||
*/
|
||||
public boolean isWhitelisted() {
|
||||
return this.whitelisted;
|
||||
}
|
||||
boolean isWhitelisted();
|
||||
|
||||
/**
|
||||
* Changes the players whitelisted state. {@code false} will deny the login
|
||||
*
|
||||
* @param whitelisted The new whitelisted state
|
||||
*/
|
||||
public void setWhitelisted(final boolean whitelisted) {
|
||||
this.whitelisted = whitelisted;
|
||||
}
|
||||
void setWhitelisted(boolean whitelisted);
|
||||
|
||||
/**
|
||||
* @return if the player obtained whitelist status by having op
|
||||
*/
|
||||
public boolean isOp() {
|
||||
return this.isOp;
|
||||
}
|
||||
boolean isOp();
|
||||
|
||||
/**
|
||||
* @return if the server even has whitelist on
|
||||
*/
|
||||
public boolean isWhitelistEnabled() {
|
||||
return this.whitelistEnabled;
|
||||
}
|
||||
boolean isWhitelistEnabled();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package com.destroystokyo.paper.event.profile;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
+22
-110
@@ -24,10 +24,7 @@
|
||||
package com.destroystokyo.paper.event.server;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.papermc.paper.util.TransformingRandomAccessList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -35,8 +32,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -48,52 +43,14 @@ import org.jspecify.annotations.Nullable;
|
||||
* <p>
|
||||
* Only 1 process will be allowed to provide completions, the Async Event, or the standard process.
|
||||
*/
|
||||
@NullMarked
|
||||
public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final CommandSender sender;
|
||||
private final String buffer;
|
||||
private final boolean isCommand;
|
||||
private final @Nullable Location location;
|
||||
private final List<Completion> completions = new ArrayList<>();
|
||||
private final List<String> stringCompletions = new TransformingRandomAccessList<>(
|
||||
this.completions,
|
||||
Completion::suggestion,
|
||||
Completion::completion
|
||||
);
|
||||
private boolean handled;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public AsyncTabCompleteEvent(final CommandSender sender, final String buffer, final boolean isCommand, final @Nullable Location loc) {
|
||||
super(true);
|
||||
this.sender = sender;
|
||||
this.buffer = buffer;
|
||||
this.isCommand = isCommand;
|
||||
this.location = loc;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ApiStatus.Internal
|
||||
public AsyncTabCompleteEvent(final CommandSender sender, final List<String> completions, final String buffer, final boolean isCommand, final @Nullable Location loc) {
|
||||
super(true);
|
||||
this.sender = sender;
|
||||
this.completions.addAll(fromStrings(completions));
|
||||
this.buffer = buffer;
|
||||
this.isCommand = isCommand;
|
||||
this.location = loc;
|
||||
}
|
||||
public interface AsyncTabCompleteEvent extends Event, Cancellable {
|
||||
|
||||
/**
|
||||
* Get the sender completing this command.
|
||||
*
|
||||
* @return the {@link CommandSender} instance
|
||||
*/
|
||||
public CommandSender getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
CommandSender getSender();
|
||||
|
||||
/**
|
||||
* The list of completions which will be offered to the sender, in order.
|
||||
@@ -105,9 +62,7 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return a list of offered completions
|
||||
*/
|
||||
public List<String> getCompletions() {
|
||||
return this.stringCompletions;
|
||||
}
|
||||
List<String> getCompletions();
|
||||
|
||||
/**
|
||||
* Set the completions offered, overriding any already set.
|
||||
@@ -119,14 +74,7 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param completions the new completions
|
||||
*/
|
||||
public void setCompletions(final List<String> completions) {
|
||||
Preconditions.checkArgument(completions != null, "Completions list cannot be null");
|
||||
if (completions == this.stringCompletions) {
|
||||
return;
|
||||
}
|
||||
this.completions.clear();
|
||||
this.completions.addAll(fromStrings(completions));
|
||||
}
|
||||
void setCompletions(List<String> completions);
|
||||
|
||||
/**
|
||||
* The list of {@link Completion completions} which will be offered to the sender, in order.
|
||||
@@ -138,9 +86,7 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return a list of offered completions
|
||||
*/
|
||||
public List<Completion> completions() {
|
||||
return this.completions;
|
||||
}
|
||||
List<Completion> completions();
|
||||
|
||||
/**
|
||||
* Set the {@link Completion completions} offered, overriding any already set.
|
||||
@@ -152,34 +98,24 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param newCompletions the new completions
|
||||
*/
|
||||
public void completions(final List<Completion> newCompletions) {
|
||||
Preconditions.checkArgument(newCompletions != null, "new completions cannot be null");
|
||||
this.completions.clear();
|
||||
this.completions.addAll(newCompletions);
|
||||
}
|
||||
void completions(List<Completion> newCompletions);
|
||||
|
||||
/**
|
||||
* Return the entire buffer which formed the basis of this completion.
|
||||
*
|
||||
* @return command buffer, as entered
|
||||
*/
|
||||
public String getBuffer() {
|
||||
return this.buffer;
|
||||
}
|
||||
String getBuffer();
|
||||
|
||||
/**
|
||||
* @return {@code true} if it is a command being tab completed, {@code false} if it is a chat message.
|
||||
*/
|
||||
public boolean isCommand() {
|
||||
return this.isCommand;
|
||||
}
|
||||
boolean isCommand();
|
||||
|
||||
/**
|
||||
* @return The position looked at by the sender, or {@code null} if none
|
||||
*/
|
||||
public @Nullable Location getLocation() {
|
||||
return this.location != null ? this.location.clone() : null;
|
||||
}
|
||||
@Nullable Location getLocation();
|
||||
|
||||
/**
|
||||
* If {@code true}, the standard process of calling {@link Command#tabComplete(CommandSender, String, String[])}
|
||||
@@ -187,9 +123,7 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @return Is completions considered handled. Always {@code true} if completions is not empty.
|
||||
*/
|
||||
public boolean isHandled() {
|
||||
return !this.completions.isEmpty() || this.handled;
|
||||
}
|
||||
boolean isHandled();
|
||||
|
||||
/**
|
||||
* Sets whether to consider the completion request handled.
|
||||
@@ -198,14 +132,7 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
*
|
||||
* @param handled if this completion should be marked as being handled
|
||||
*/
|
||||
public void setHandled(final boolean handled) {
|
||||
this.handled = handled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
void setHandled(boolean handled);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -213,31 +140,19 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
* Will provide no completions, and will not fire the synchronous process
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
private static List<Completion> fromStrings(final List<String> suggestions) {
|
||||
final List<Completion> list = new ArrayList<>(suggestions.size());
|
||||
for (final String suggestion : suggestions) {
|
||||
list.add(new CompletionImpl(suggestion, null));
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return list;
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* A rich tab completion, consisting of a string suggestion, and a nullable {@link Component} tooltip.
|
||||
*/
|
||||
public interface Completion {
|
||||
interface Completion {
|
||||
|
||||
/**
|
||||
* Get the suggestion string for this {@link Completion}.
|
||||
@@ -260,7 +175,7 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
* @return new completion instance
|
||||
*/
|
||||
static Completion completion(final String suggestion) {
|
||||
return new CompletionImpl(suggestion, null);
|
||||
return completion(suggestion, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,14 +188,11 @@ public class AsyncTabCompleteEvent extends Event implements Cancellable {
|
||||
* @return new completion instance
|
||||
*/
|
||||
static Completion completion(final String suggestion, final @Nullable Component tooltip) {
|
||||
Preconditions.checkArgument(suggestion != null, "suggestion cannot be null");
|
||||
record CompletionImpl(String suggestion, @Nullable Component tooltip) implements Completion {
|
||||
}
|
||||
|
||||
return new CompletionImpl(suggestion, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
record CompletionImpl(String suggestion, @Nullable Component tooltip) implements Completion {
|
||||
CompletionImpl {
|
||||
Objects.requireNonNull(suggestion, "suggestion");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,7 @@ import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This event is fired if server is getting queried over GS4 Query protocol.
|
||||
@@ -21,72 +19,47 @@ import org.jspecify.annotations.NullMarked;
|
||||
*
|
||||
* @author Mark Vainomaa
|
||||
*/
|
||||
@NullMarked
|
||||
public final class GS4QueryEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final QueryType queryType;
|
||||
private final InetAddress querierAddress;
|
||||
private QueryResponse response;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public GS4QueryEvent(final QueryType queryType, final InetAddress querierAddress, final QueryResponse response) {
|
||||
super(true); // should always be called async
|
||||
this.queryType = queryType;
|
||||
this.querierAddress = querierAddress;
|
||||
this.response = response;
|
||||
}
|
||||
public interface GS4QueryEvent extends Event {
|
||||
|
||||
/**
|
||||
* Get query type
|
||||
*
|
||||
* @return query type
|
||||
*/
|
||||
public QueryType getQueryType() {
|
||||
return this.queryType;
|
||||
}
|
||||
QueryType getQueryType();
|
||||
|
||||
/**
|
||||
* Get querier address
|
||||
*
|
||||
* @return querier address
|
||||
*/
|
||||
public InetAddress getQuerierAddress() {
|
||||
return this.querierAddress;
|
||||
}
|
||||
InetAddress getQuerierAddress();
|
||||
|
||||
/**
|
||||
* Get query response
|
||||
*
|
||||
* @return query response
|
||||
*/
|
||||
public QueryResponse getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
QueryResponse getResponse();
|
||||
|
||||
/**
|
||||
* Set query response
|
||||
*
|
||||
* @param response query response
|
||||
*/
|
||||
public void setResponse(final QueryResponse response) {
|
||||
this.response = Preconditions.checkNotNull(response, "response");
|
||||
}
|
||||
void setResponse(QueryResponse response);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of query
|
||||
*/
|
||||
public enum QueryType {
|
||||
enum QueryType {
|
||||
/**
|
||||
* Basic query asks only a subset of information, such as motd, game type (hardcoded to <pre>MINECRAFT</pre>), map,
|
||||
* current players, max players, server port and server motd
|
||||
@@ -99,7 +72,7 @@ public final class GS4QueryEvent extends Event {
|
||||
FULL
|
||||
}
|
||||
|
||||
public static final class QueryResponse {
|
||||
final class QueryResponse {
|
||||
|
||||
private final String motd;
|
||||
private final String gameVersion;
|
||||
@@ -112,7 +85,18 @@ public final class GS4QueryEvent extends Event {
|
||||
private final String serverVersion;
|
||||
private final Collection<PluginInformation> plugins;
|
||||
|
||||
private QueryResponse(final String motd, final String gameVersion, final String map, final int currentPlayers, final int maxPlayers, final String hostname, final int port, final Collection<String> players, final String serverVersion, final Collection<PluginInformation> plugins) {
|
||||
private QueryResponse(
|
||||
final String motd,
|
||||
final String gameVersion,
|
||||
final String map,
|
||||
final int currentPlayers,
|
||||
final int maxPlayers,
|
||||
final String hostname,
|
||||
final int port,
|
||||
final Collection<String> players,
|
||||
final String serverVersion,
|
||||
final Collection<PluginInformation> plugins
|
||||
) {
|
||||
this.motd = motd;
|
||||
this.gameVersion = gameVersion;
|
||||
this.map = map;
|
||||
@@ -248,11 +232,11 @@ public final class GS4QueryEvent extends Event {
|
||||
*/
|
||||
public static final class Builder {
|
||||
|
||||
private @MonotonicNonNull String motd;
|
||||
private @MonotonicNonNull String gameVersion;
|
||||
private @MonotonicNonNull String map;
|
||||
private @MonotonicNonNull String hostname;
|
||||
private @MonotonicNonNull String serverVersion;
|
||||
private @Nullable String motd;
|
||||
private @Nullable String gameVersion;
|
||||
private @Nullable String map;
|
||||
private @Nullable String hostname;
|
||||
private @Nullable String serverVersion;
|
||||
|
||||
private int currentPlayers;
|
||||
private int maxPlayers;
|
||||
@@ -265,17 +249,20 @@ public final class GS4QueryEvent extends Event {
|
||||
}
|
||||
|
||||
public Builder motd(final String motd) {
|
||||
this.motd = Preconditions.checkNotNull(motd, "motd");
|
||||
Preconditions.checkArgument(motd != null, "motd cannot be null");
|
||||
this.motd = motd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder gameVersion(final String gameVersion) {
|
||||
this.gameVersion = Preconditions.checkNotNull(gameVersion, "gameVersion");
|
||||
Preconditions.checkArgument(gameVersion != null, "gameVersion cannot be null");
|
||||
this.gameVersion = gameVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder map(final String map) {
|
||||
this.map = Preconditions.checkNotNull(map, "map");
|
||||
Preconditions.checkArgument(map != null, "map cannot be null");
|
||||
this.map = map;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -292,7 +279,8 @@ public final class GS4QueryEvent extends Event {
|
||||
}
|
||||
|
||||
public Builder hostname(final String hostname) {
|
||||
this.hostname = Preconditions.checkNotNull(hostname, "hostname");
|
||||
Preconditions.checkArgument(hostname != null, "hostname cannot be null");
|
||||
this.hostname = hostname;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -303,12 +291,14 @@ public final class GS4QueryEvent extends Event {
|
||||
}
|
||||
|
||||
public Builder players(final Collection<String> players) {
|
||||
this.players.addAll(Preconditions.checkNotNull(players, "players"));
|
||||
Preconditions.checkArgument(players != null, "players cannot be null");
|
||||
this.players.addAll(players);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder players(final String... players) {
|
||||
this.players.addAll(Arrays.asList(Preconditions.checkNotNull(players, "players")));
|
||||
Preconditions.checkArgument(players != null, "players cannot be null");
|
||||
this.players.addAll(Arrays.asList(players));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -318,17 +308,20 @@ public final class GS4QueryEvent extends Event {
|
||||
}
|
||||
|
||||
public Builder serverVersion(final String serverVersion) {
|
||||
this.serverVersion = Preconditions.checkNotNull(serverVersion, "serverVersion");
|
||||
Preconditions.checkArgument(serverVersion != null, "serverVersion cannot be null");
|
||||
this.serverVersion = serverVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder plugins(final Collection<PluginInformation> plugins) {
|
||||
this.plugins.addAll(Preconditions.checkNotNull(plugins, "plugins"));
|
||||
Preconditions.checkArgument(plugins != null, "plugins cannot be null");
|
||||
this.plugins.addAll(plugins);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder plugins(final PluginInformation... plugins) {
|
||||
this.plugins.addAll(Arrays.asList(Preconditions.checkNotNull(plugins, "plugins")));
|
||||
Preconditions.checkArgument(plugins != null, "plugins cannot be null");
|
||||
this.plugins.addAll(Arrays.asList(plugins));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -343,16 +336,21 @@ public final class GS4QueryEvent extends Event {
|
||||
* @return response
|
||||
*/
|
||||
public QueryResponse build() {
|
||||
Preconditions.checkState(this.motd != null, "motd is required");
|
||||
Preconditions.checkState(this.gameVersion != null, "gameVersion is required");
|
||||
Preconditions.checkState(this.map != null, "map is required");
|
||||
Preconditions.checkState(this.hostname != null, "hostname is required");
|
||||
Preconditions.checkState(this.serverVersion != null, "serverVersion is required");
|
||||
return new QueryResponse(
|
||||
Preconditions.checkNotNull(this.motd, "motd"),
|
||||
Preconditions.checkNotNull(this.gameVersion, "gameVersion"),
|
||||
Preconditions.checkNotNull(this.map, "map"),
|
||||
this.motd,
|
||||
this.gameVersion,
|
||||
this.map,
|
||||
this.currentPlayers,
|
||||
this.maxPlayers,
|
||||
Preconditions.checkNotNull(this.hostname, "hostname"),
|
||||
this.hostname,
|
||||
this.port,
|
||||
ImmutableList.copyOf(this.players),
|
||||
Preconditions.checkNotNull(this.serverVersion, "serverVersion"),
|
||||
this.serverVersion,
|
||||
ImmutableList.copyOf(this.plugins)
|
||||
);
|
||||
}
|
||||
@@ -361,34 +359,66 @@ public final class GS4QueryEvent extends Event {
|
||||
/**
|
||||
* Plugin information
|
||||
*/
|
||||
public static class PluginInformation {
|
||||
public interface PluginInformation {
|
||||
|
||||
private String name;
|
||||
private String version;
|
||||
String name();
|
||||
|
||||
public PluginInformation(final String name, final String version) {
|
||||
this.name = Preconditions.checkNotNull(name, "name");
|
||||
this.version = Preconditions.checkNotNull(version, "version");
|
||||
String version();
|
||||
|
||||
PluginInformation withName(String name);
|
||||
|
||||
PluginInformation withVersion(String version);
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #name()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default String getName() {
|
||||
return this.name();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
/**
|
||||
* @deprecated use {@link #withName(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default void setName(String name) {
|
||||
this.withName(name); // no op
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
/**
|
||||
* @deprecated use {@link #version()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default String getVersion() {
|
||||
return this.version();
|
||||
}
|
||||
|
||||
public void setVersion(final String version) {
|
||||
this.version = version;
|
||||
/**
|
||||
* @deprecated use {@link #withVersion(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
default void setVersion(String version) {
|
||||
this.withVersion(version); // no op
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
static PluginInformation of(final String name, final String version) {
|
||||
record PluginInformationImpl(String name, String version) implements PluginInformation {
|
||||
PluginInformationImpl {
|
||||
Preconditions.checkArgument(name != null, "name cannot be null");
|
||||
Preconditions.checkArgument(version != null, "version cannot be null");
|
||||
}
|
||||
|
||||
public static PluginInformation of(final String name, final String version) {
|
||||
return new PluginInformation(name, version);
|
||||
@Override
|
||||
public PluginInformation withName(final String name) {
|
||||
return new PluginInformationImpl(name, this.version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginInformation withVersion(final String version) {
|
||||
return new PluginInformationImpl(this.name, version);
|
||||
}
|
||||
}
|
||||
return new PluginInformationImpl(name, version);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-318
@@ -1,80 +1,28 @@
|
||||
package com.destroystokyo.paper.event.server;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.destroystokyo.paper.network.StatusClient;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.papermc.paper.util.TransformingRandomAccessList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.profile.PlayerTextures;
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Extended version of {@link ServerListPingEvent} that allows full control
|
||||
* of the response sent to the client.
|
||||
*/
|
||||
public class PaperServerListPingEvent extends ServerListPingEvent implements Cancellable {
|
||||
|
||||
@NotNull private final StatusClient client;
|
||||
|
||||
private int numPlayers;
|
||||
private boolean hidePlayers;
|
||||
@NotNull private final List<ListedPlayerInfo> listedPlayers = new ArrayList<>();
|
||||
@NotNull private final TransformingRandomAccessList<ListedPlayerInfo, PlayerProfile> playerSample = new TransformingRandomAccessList<>(
|
||||
listedPlayers,
|
||||
info -> new UncheckedPlayerProfile(info.name(), info.id()),
|
||||
profile -> new ListedPlayerInfo(profile.getName(), profile.getId())
|
||||
);
|
||||
|
||||
@NotNull private String version;
|
||||
private int protocolVersion;
|
||||
|
||||
@Nullable private CachedServerIcon favicon;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
private boolean originalPlayerCount = true;
|
||||
private Object[] players;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PaperServerListPingEvent(@NotNull StatusClient client, @NotNull net.kyori.adventure.text.Component motd, int numPlayers, int maxPlayers,
|
||||
@NotNull String version, int protocolVersion, @Nullable CachedServerIcon favicon) {
|
||||
super("", client.getAddress().getAddress(), motd, numPlayers, maxPlayers);
|
||||
this.client = client;
|
||||
this.numPlayers = numPlayers;
|
||||
this.version = version;
|
||||
this.protocolVersion = protocolVersion;
|
||||
setServerIcon(favicon);
|
||||
}
|
||||
public interface PaperServerListPingEvent extends ServerListPingEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Returns the {@link StatusClient} pinging the server.
|
||||
*
|
||||
* @return The client
|
||||
*/
|
||||
@NotNull
|
||||
public StatusClient getClient() {
|
||||
return this.client;
|
||||
}
|
||||
StatusClient getClient();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -83,13 +31,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* {@link #shouldHidePlayers()}.</p>
|
||||
*/
|
||||
@Override
|
||||
public int getNumPlayers() {
|
||||
if (this.hidePlayers) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return this.numPlayers;
|
||||
}
|
||||
int getNumPlayers();
|
||||
|
||||
/**
|
||||
* Sets the number of players displayed in the server list.
|
||||
@@ -99,12 +41,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
*
|
||||
* @param numPlayers The number of online players
|
||||
*/
|
||||
public void setNumPlayers(int numPlayers) {
|
||||
if (this.numPlayers != numPlayers) {
|
||||
this.numPlayers = numPlayers;
|
||||
this.originalPlayerCount = false;
|
||||
}
|
||||
}
|
||||
void setNumPlayers(int numPlayers);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -113,13 +50,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* {@link #shouldHidePlayers()}.
|
||||
*/
|
||||
@Override
|
||||
public int getMaxPlayers() {
|
||||
if (this.hidePlayers) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return super.getMaxPlayers();
|
||||
}
|
||||
int getMaxPlayers();
|
||||
|
||||
/**
|
||||
* Returns whether all player related information is hidden in the server
|
||||
@@ -131,9 +62,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
*
|
||||
* @return {@code true} if the player count is hidden
|
||||
*/
|
||||
public boolean shouldHidePlayers() {
|
||||
return this.hidePlayers;
|
||||
}
|
||||
boolean shouldHidePlayers();
|
||||
|
||||
/**
|
||||
* Sets whether all player related information is hidden in the server
|
||||
@@ -145,9 +74,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
*
|
||||
* @param hidePlayers {@code true} if the player count should be hidden
|
||||
*/
|
||||
public void setHidePlayers(boolean hidePlayers) {
|
||||
this.hidePlayers = hidePlayers;
|
||||
}
|
||||
void setHidePlayers(boolean hidePlayers);
|
||||
|
||||
/**
|
||||
* Returns a mutable list of {@link ListedPlayerInfo} that will be displayed
|
||||
@@ -158,10 +85,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
*
|
||||
* @return The mutable player sample list
|
||||
*/
|
||||
@NotNull
|
||||
public List<ListedPlayerInfo> getListedPlayers() {
|
||||
return this.listedPlayers;
|
||||
}
|
||||
List<ListedPlayerInfo> getListedPlayers();
|
||||
|
||||
/**
|
||||
* Returns a mutable list of {@link PlayerProfile} that will be displayed
|
||||
@@ -173,30 +97,22 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* @return The mutable player sample list
|
||||
* @deprecated Use {@link #getListedPlayers()}, as this does not contain real player profiles
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated(forRemoval = true, since = "1.20.6")
|
||||
public List<PlayerProfile> getPlayerSample() {
|
||||
return this.playerSample;
|
||||
}
|
||||
List<PlayerProfile> getPlayerSample();
|
||||
|
||||
/**
|
||||
* Returns the version that will be sent as server version on the client.
|
||||
*
|
||||
* @return The server version
|
||||
*/
|
||||
@NotNull
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Sets the version that will be sent as server version to the client.
|
||||
*
|
||||
* @param version The server version
|
||||
*/
|
||||
public void setVersion(@NotNull String version) {
|
||||
this.version = requireNonNull(version, "version");
|
||||
}
|
||||
void setVersion(String version);
|
||||
|
||||
/**
|
||||
* Returns the protocol version that will be sent as the protocol version
|
||||
@@ -205,9 +121,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* @return The protocol version of the server, or {@code -1} if the server
|
||||
* has not finished initialization yet
|
||||
*/
|
||||
public int getProtocolVersion() {
|
||||
return this.protocolVersion;
|
||||
}
|
||||
int getProtocolVersion();
|
||||
|
||||
/**
|
||||
* Sets the protocol version that will be sent as the protocol version
|
||||
@@ -215,19 +129,14 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
*
|
||||
* @param protocolVersion The protocol version of the server
|
||||
*/
|
||||
public void setProtocolVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
void setProtocolVersion(int protocolVersion);
|
||||
|
||||
/**
|
||||
* Gets the server icon sent to the client.
|
||||
*
|
||||
* @return The icon to send to the client, or {@code null} for none
|
||||
*/
|
||||
@Nullable
|
||||
public CachedServerIcon getServerIcon() {
|
||||
return this.favicon;
|
||||
}
|
||||
@Nullable CachedServerIcon getServerIcon();
|
||||
|
||||
/**
|
||||
* Sets the server icon sent to the client.
|
||||
@@ -235,14 +144,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* @param icon The icon to send to the client, or {@code null} for none
|
||||
*/
|
||||
@Override
|
||||
public void setServerIcon(@Nullable CachedServerIcon icon) {
|
||||
if (icon != null && icon.isEmpty()) {
|
||||
// Represent empty icons as null
|
||||
icon = null;
|
||||
}
|
||||
|
||||
this.favicon = icon;
|
||||
}
|
||||
void setServerIcon(@Nullable CachedServerIcon icon);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -251,9 +153,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* without sending a response to the client.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -262,9 +162,7 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* without sending a response to the client.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -281,77 +179,9 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* </ul>
|
||||
* @deprecated the Iterable interface will be removed at some point
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
@Deprecated(forRemoval = true, since = "1.20.6")
|
||||
public Iterator<Player> iterator() {
|
||||
if (this.players == null) {
|
||||
this.players = getOnlinePlayers();
|
||||
}
|
||||
|
||||
return new PlayerIterator();
|
||||
}
|
||||
|
||||
protected @NotNull Object @NotNull [] getOnlinePlayers() {
|
||||
return Bukkit.getOnlinePlayers().toArray();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Player getBukkitPlayer(@NotNull Object player) {
|
||||
return (Player) player;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
private final class PlayerIterator implements Iterator<Player> {
|
||||
|
||||
private int next;
|
||||
private int current;
|
||||
@Nullable private Player player;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
for (; this.next < players.length; this.next++) {
|
||||
if (players[this.next] != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Player next() {
|
||||
if (!hasNext()) {
|
||||
this.player = null;
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
this.current = this.next++;
|
||||
return this.player = getBukkitPlayer(players[this.current]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (this.player == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
UUID uniqueId = this.player.getUniqueId();
|
||||
this.player = null;
|
||||
|
||||
// Remove player from iterator
|
||||
players[this.current] = null;
|
||||
|
||||
// Remove player from sample
|
||||
getPlayerSample().removeIf(p -> uniqueId.equals(p.getId()));
|
||||
|
||||
// Decrement player count
|
||||
if (originalPlayerCount) {
|
||||
numPlayers--;
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<Player> iterator();
|
||||
|
||||
/**
|
||||
* Represents a player that will be displayed in the player sample of the server list.
|
||||
@@ -359,131 +189,6 @@ public class PaperServerListPingEvent extends ServerListPingEvent implements Can
|
||||
* @param name name of the listed player
|
||||
* @param id UUID of the listed player
|
||||
*/
|
||||
public record ListedPlayerInfo(@NotNull String name, @NotNull UUID id) {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
private static final class UncheckedPlayerProfile implements PlayerProfile {
|
||||
private String name;
|
||||
private UUID uuid;
|
||||
|
||||
public UncheckedPlayerProfile(final @NotNull String name, final @NotNull UUID uuid) {
|
||||
Preconditions.checkNotNull(name, "name cannot be null");
|
||||
Preconditions.checkNotNull(uuid, "uuid cannot be null");
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID getUniqueId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String setName(@Nullable final String name) {
|
||||
Preconditions.checkNotNull(name, "name cannot be null");
|
||||
return this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID getId() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID setId(@Nullable final UUID uuid) {
|
||||
Preconditions.checkNotNull(uuid, "uuid cannot be null");
|
||||
return this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlayerTextures getTextures() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextures(@Nullable final PlayerTextures textures) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<ProfileProperty> getProperties() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProperty(@Nullable final String property) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(@NotNull final ProfileProperty property) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(@NotNull final Collection<ProfileProperty> properties) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeProperty(@Nullable final String property) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearProperties() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache(final boolean onlineMode) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache(final boolean lookupUUID, final boolean onlineMode) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complete(final boolean textures) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complete(final boolean textures, final boolean onlineMode) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<PlayerProfile> update() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlayerProfile clone() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<String, Object> serialize() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
record ListedPlayerInfo(String name, UUID id) {
|
||||
}
|
||||
}
|
||||
+8
-26
@@ -1,43 +1,25 @@
|
||||
package com.destroystokyo.paper.event.server;
|
||||
|
||||
import com.destroystokyo.paper.exception.ServerException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.server.ServerEvent;
|
||||
|
||||
/**
|
||||
* Called whenever an exception is thrown in a recoverable section of the server.
|
||||
*/
|
||||
@NullMarked
|
||||
public class ServerExceptionEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ServerException exception;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ServerExceptionEvent(final ServerException exception) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.exception = exception;
|
||||
}
|
||||
public interface ServerExceptionEvent extends ServerEvent {
|
||||
|
||||
/**
|
||||
* Gets the wrapped exception that was thrown.
|
||||
*
|
||||
* @return Exception thrown
|
||||
*/
|
||||
public ServerException getException() {
|
||||
return this.exception;
|
||||
}
|
||||
ServerException getException();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+11
-34
@@ -1,42 +1,23 @@
|
||||
package com.destroystokyo.paper.event.server;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.server.ServerEvent;
|
||||
import org.checkerframework.checker.index.qual.Positive;
|
||||
|
||||
/**
|
||||
* Called when the server has finished ticking the main loop
|
||||
*/
|
||||
@NullMarked
|
||||
public class ServerTickEndEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final int tickNumber;
|
||||
private final double tickDuration;
|
||||
private final long timeEnd;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ServerTickEndEvent(final int tickNumber, final double tickDuration, final long timeRemaining) {
|
||||
this.tickNumber = tickNumber;
|
||||
this.tickDuration = tickDuration;
|
||||
this.timeEnd = System.nanoTime() + timeRemaining;
|
||||
}
|
||||
public interface ServerTickEndEvent extends ServerEvent {
|
||||
|
||||
/**
|
||||
* @return What tick this was since start (first tick = 1)
|
||||
*/
|
||||
public int getTickNumber() {
|
||||
return this.tickNumber;
|
||||
}
|
||||
@Positive int getTickNumber();
|
||||
|
||||
/**
|
||||
* @return Time in milliseconds of how long this tick took
|
||||
*/
|
||||
public double getTickDuration() {
|
||||
return this.tickDuration;
|
||||
}
|
||||
double getTickDuration();
|
||||
|
||||
/**
|
||||
* Amount of nanoseconds remaining before the next tick should start.
|
||||
@@ -47,16 +28,12 @@ public class ServerTickEndEvent extends Event {
|
||||
*
|
||||
* @return Amount of nanoseconds remaining before the next tick should start
|
||||
*/
|
||||
public long getTimeRemaining() {
|
||||
return this.timeEnd - System.nanoTime();
|
||||
}
|
||||
long getTimeRemaining();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+12
-24
@@ -1,35 +1,23 @@
|
||||
package com.destroystokyo.paper.event.server;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.server.ServerEvent;
|
||||
import org.checkerframework.checker.index.qual.Positive;
|
||||
|
||||
@NullMarked
|
||||
public class ServerTickStartEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final int tickNumber;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ServerTickStartEvent(final int tickNumber) {
|
||||
this.tickNumber = tickNumber;
|
||||
}
|
||||
/**
|
||||
* Called when the server has started ticking the main loop
|
||||
*/
|
||||
public interface ServerTickStartEvent extends ServerEvent {
|
||||
|
||||
/**
|
||||
* @return What tick this is going be since start (first tick = 1)
|
||||
*/
|
||||
public int getTickNumber() {
|
||||
return this.tickNumber;
|
||||
}
|
||||
@Positive int getTickNumber();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+7
-23
@@ -2,41 +2,25 @@ package com.destroystokyo.paper.event.server;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* This event is fired when whitelist is toggled
|
||||
*
|
||||
* @author Mark Vainomaa
|
||||
*/
|
||||
@NullMarked
|
||||
public class WhitelistToggleEvent extends Event {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final boolean enabled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public WhitelistToggleEvent(final boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
public interface WhitelistToggleEvent extends Event {
|
||||
|
||||
/**
|
||||
* Gets whether whitelist is going to be enabled or not
|
||||
*
|
||||
* @return Whether whitelist is going to be enabled or not
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
boolean isEnabled();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package com.destroystokyo.paper.event.server;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
-13
@@ -1,9 +1,5 @@
|
||||
package com.destroystokyo.paper.exception;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
|
||||
/**
|
||||
* Thrown when the internal server throws a recoverable exception.
|
||||
*/
|
||||
@@ -24,13 +20,4 @@ public class ServerInternalException extends ServerException {
|
||||
protected ServerInternalException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public static void reportInternalException(Throwable cause) {
|
||||
try {
|
||||
Bukkit.getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(cause)));
|
||||
;
|
||||
} catch (Throwable t) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Exception posting ServerExceptionEvent", t); // Don't want to rethrow!
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-34
@@ -1,46 +1,19 @@
|
||||
package com.destroystokyo.paper.loottable;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable {
|
||||
public interface LootableInventoryReplenishEvent extends PlayerEvent, Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
LootableInventory getInventory();
|
||||
|
||||
private final LootableInventory inventory;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public LootableInventoryReplenishEvent(final Player player, final LootableInventory inventory) {
|
||||
super(player);
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
public LootableInventory getInventory() {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public interface NetworkClient {
|
||||
*
|
||||
* @return The client's socket address
|
||||
*/
|
||||
InetSocketAddress getAddress();
|
||||
InetSocketAddress address();
|
||||
|
||||
/**
|
||||
* Returns the protocol version of the client.
|
||||
@@ -24,7 +24,7 @@ public interface NetworkClient {
|
||||
* @see <a href="https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Protocol_version_numbers">List of protocol
|
||||
* version numbers</a>
|
||||
*/
|
||||
int getProtocolVersion();
|
||||
int protocolVersion();
|
||||
|
||||
/**
|
||||
* Returns the virtual host the client is connected to.
|
||||
@@ -34,6 +34,6 @@ public interface NetworkClient {
|
||||
*
|
||||
* @return The client's virtual host, or {@code null} if unknown
|
||||
*/
|
||||
@Nullable InetSocketAddress getVirtualHost();
|
||||
@Nullable InetSocketAddress virtualHost();
|
||||
|
||||
}
|
||||
@@ -3,7 +3,5 @@ package io.papermc.paper.block.bed;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ApiStatus.Internal
|
||||
record BedRuleResultImpl(
|
||||
boolean success
|
||||
) implements BedRuleResult {
|
||||
record BedRuleResultImpl(boolean success) implements BedRuleResult {
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.papermc.paper.connection;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import java.util.Map;
|
||||
|
||||
import com.destroystokyo.paper.ClientOption;
|
||||
@@ -12,6 +13,13 @@ import org.jspecify.annotations.Nullable;
|
||||
*/
|
||||
public interface PlayerCommonConnection extends WritablePlayerCookieConnection, ReadablePlayerCookieConnection, PluginMessageRecipient {
|
||||
|
||||
/**
|
||||
* Gets the profile for this connection.
|
||||
*
|
||||
* @return profile
|
||||
*/
|
||||
PlayerProfile getProfile();
|
||||
|
||||
/**
|
||||
* Sends data to appear in this connection's report logs.
|
||||
* This is useful for debugging server state that may be causing
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.papermc.paper.connection;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
|
||||
public interface PlayerConfigurationConnection extends PlayerCommonConnection {
|
||||
@@ -14,13 +13,6 @@ public interface PlayerConfigurationConnection extends PlayerCommonConnection {
|
||||
*/
|
||||
Audience getAudience();
|
||||
|
||||
/**
|
||||
* Gets the profile for this connection.
|
||||
*
|
||||
* @return profile
|
||||
*/
|
||||
PlayerProfile getProfile();
|
||||
|
||||
/**
|
||||
* Clears the players chat history and their local chat.
|
||||
*/
|
||||
|
||||
@@ -1,41 +1,26 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a beacon is activated.
|
||||
* Activation occurs when the beacon beam becomes visible.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BeaconActivatedEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BeaconActivatedEvent(final Block beacon) {
|
||||
super(beacon);
|
||||
}
|
||||
public interface BeaconActivatedEvent extends BlockEvent {
|
||||
|
||||
/**
|
||||
* Returns the beacon that was activated.
|
||||
*
|
||||
* @return the beacon that was activated.
|
||||
*/
|
||||
public Beacon getBeacon() {
|
||||
return (Beacon) this.block.getState();
|
||||
}
|
||||
Beacon getBeacon();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,14 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Beacon;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when a beacon is deactivated, either because its base block(s) or itself were destroyed.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BeaconDeactivatedEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BeaconDeactivatedEvent(final Block beacon) {
|
||||
super(beacon);
|
||||
}
|
||||
public interface BeaconDeactivatedEvent extends BlockEvent {
|
||||
|
||||
/**
|
||||
* Returns the beacon that was deactivated.
|
||||
@@ -29,16 +17,12 @@ public class BeaconDeactivatedEvent extends BlockEvent {
|
||||
*
|
||||
* @return The beacon that got deactivated, or {@code null} if it does not exist.
|
||||
*/
|
||||
public @Nullable Beacon getBeacon() {
|
||||
return this.block.getType() == Material.BEACON ? (Beacon) this.block.getState() : null;
|
||||
}
|
||||
@Nullable Beacon getBeacon();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Raider;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a {@link Raider} is revealed by a bell.
|
||||
@@ -14,33 +11,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @deprecated use {@link org.bukkit.event.block.BellResonateEvent}
|
||||
*/
|
||||
@Deprecated(since = "1.19.4")
|
||||
public class BellRevealRaiderEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Raider raider;
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BellRevealRaiderEvent(@NotNull Block bell, @NotNull Raider raider) {
|
||||
super(bell);
|
||||
this.raider = raider;
|
||||
}
|
||||
public interface BellRevealRaiderEvent extends BlockEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the raider that the bell revealed.
|
||||
*
|
||||
* @return The raider
|
||||
*/
|
||||
@NotNull
|
||||
public Raider getEntity() {
|
||||
return this.raider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
Raider getEntity();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -48,16 +26,12 @@ public class BellRevealRaiderEvent extends BlockEvent implements Cancellable {
|
||||
* This does not cancel the particle effects shown on the bell, only the entity.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static @NotNull HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,10 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when a bell is rung.
|
||||
*
|
||||
* @deprecated use {@link org.bukkit.event.block.BellRingEvent}
|
||||
*/
|
||||
@Deprecated(since = "1.19.4")
|
||||
public class BellRingEvent extends org.bukkit.event.block.BellRingEvent {
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) {
|
||||
super(block, direction, entity);
|
||||
}
|
||||
public interface BellRingEvent extends org.bukkit.event.block.BellRingEvent {
|
||||
}
|
||||
@@ -5,53 +5,32 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockExpEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a block forces another block to break and drop items.
|
||||
* <p>
|
||||
* Currently called for piston's and liquid flows.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BlockBreakBlockEvent extends BlockExpEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Block source;
|
||||
private final List<ItemStack> drops;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BlockBreakBlockEvent(final Block block, final Block source, final List<ItemStack> drops) {
|
||||
super(block, 0);
|
||||
this.source = source;
|
||||
this.drops = drops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a mutable list of drops for this event
|
||||
*
|
||||
* @return the drops
|
||||
*/
|
||||
public List<ItemStack> getDrops() {
|
||||
return this.drops;
|
||||
}
|
||||
public interface BlockBreakBlockEvent extends BlockExpEvent {
|
||||
|
||||
/**
|
||||
* Gets the block that cause this (e.g. a piston, or adjacent liquid)
|
||||
*
|
||||
* @return the source
|
||||
*/
|
||||
public Block getSource() {
|
||||
return this.source;
|
||||
}
|
||||
Block getSource();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
/**
|
||||
* Gets a mutable list of drops for this event
|
||||
*
|
||||
* @return the drops
|
||||
*/
|
||||
List<ItemStack> getDrops();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
+8
-37
@@ -1,29 +1,13 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.bukkit.event.entity.EntityEvent;
|
||||
|
||||
/**
|
||||
* Called when the progress of a block break is updated.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BlockBreakProgressUpdateEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final float progress;
|
||||
private final Entity entity;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BlockBreakProgressUpdateEvent(final Block block, final float progress, final Entity entity) {
|
||||
super(block);
|
||||
this.progress = progress;
|
||||
this.entity = entity;
|
||||
}
|
||||
public interface BlockBreakProgressUpdateEvent extends BlockEvent, EntityEvent {
|
||||
|
||||
/**
|
||||
* The progress of the block break
|
||||
@@ -33,25 +17,12 @@ public class BlockBreakProgressUpdateEvent extends BlockEvent {
|
||||
*
|
||||
* @return The progress of the block break
|
||||
*/
|
||||
public float getProgress() {
|
||||
return this.progress;
|
||||
}
|
||||
float getProgress();
|
||||
|
||||
/**
|
||||
* The entity breaking the block.
|
||||
*
|
||||
* @return The entity breaking the block
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +1,29 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a block tries to dispense an item, but its inventory is empty.
|
||||
*/
|
||||
@NullMarked
|
||||
public class BlockFailedDispenseEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private boolean shouldPlayEffect = true;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BlockFailedDispenseEvent(final Block block) {
|
||||
super(block);
|
||||
}
|
||||
public interface BlockFailedDispenseEvent extends BlockEvent {
|
||||
|
||||
/**
|
||||
* @return if the effect should be played
|
||||
*/
|
||||
public boolean shouldPlayEffect() {
|
||||
return this.shouldPlayEffect;
|
||||
}
|
||||
boolean shouldPlayEffect();
|
||||
|
||||
/**
|
||||
* Sets if the effect for empty dispensers should be played
|
||||
*
|
||||
* @param playEffect if the effect should be played
|
||||
*/
|
||||
public void shouldPlayEffect(final boolean playEffect) {
|
||||
this.shouldPlayEffect = playEffect;
|
||||
}
|
||||
void shouldPlayEffect(boolean playEffect);
|
||||
|
||||
/**
|
||||
* @return {@link #shouldPlayEffect()}
|
||||
*/
|
||||
@Override
|
||||
public boolean callEvent() {
|
||||
super.callEvent();
|
||||
return this.shouldPlayEffect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,12 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.papermc.paper.block.LockableTileState;
|
||||
import java.util.Objects;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -20,24 +14,7 @@ import org.jspecify.annotations.Nullable;
|
||||
* <br>
|
||||
* See {@link #setResult(Result)} to change behavior
|
||||
*/
|
||||
@NullMarked
|
||||
public class BlockLockCheckEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private @Nullable Component lockedMessage;
|
||||
private @Nullable Sound lockedSound;
|
||||
private @Nullable ItemStack itemStack;
|
||||
private Result result = Result.DEFAULT;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BlockLockCheckEvent(final Block block, final Player player, final Component lockedMessage, final Sound lockedSound) {
|
||||
super(block);
|
||||
this.player = player;
|
||||
this.lockedMessage = lockedMessage;
|
||||
this.lockedSound = lockedSound;
|
||||
}
|
||||
public interface BlockLockCheckEvent extends BlockEvent, PlayerEvent {
|
||||
|
||||
/**
|
||||
* Gets the snapshot {@link LockableTileState} of the block entity
|
||||
@@ -45,20 +22,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
*
|
||||
* @return the snapshot block state.
|
||||
*/
|
||||
public LockableTileState getBlockState() {
|
||||
final BlockState blockState = this.getBlock().getState();
|
||||
Preconditions.checkState(blockState instanceof LockableTileState, "Block state of lock-checked block is no longer a lockable tile state!");
|
||||
return (LockableTileState) blockState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player involved this lock check.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
LockableTileState getBlockState();
|
||||
|
||||
/**
|
||||
* Gets the itemstack that will be used as the key itemstack. Initially
|
||||
@@ -69,9 +33,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
* @return the item being used as the key item
|
||||
* @see #isUsingCustomKeyItemStack()
|
||||
*/
|
||||
public ItemStack getKeyItem() {
|
||||
return Objects.requireNonNullElseGet(this.itemStack, this.player.getInventory()::getItemInMainHand);
|
||||
}
|
||||
ItemStack getKeyItem();
|
||||
|
||||
/**
|
||||
* Sets the itemstack that will be used as the key item.
|
||||
@@ -79,26 +41,19 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
* @param stack the stack to use as a key
|
||||
* @see #resetKeyItem() to clear a custom key item
|
||||
*/
|
||||
public void setKeyItem(final ItemStack stack) {
|
||||
Preconditions.checkArgument(stack != null, "stack cannot be null");
|
||||
this.itemStack = stack;
|
||||
}
|
||||
void setKeyItem(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Reset the key stack to the default (the player's main hand).
|
||||
*/
|
||||
public void resetKeyItem() {
|
||||
this.itemStack = null;
|
||||
}
|
||||
void resetKeyItem();
|
||||
|
||||
/**
|
||||
* Checks if a custom key stack has been set.
|
||||
*
|
||||
* @return {@code true} if a custom key itemstack has been set
|
||||
*/
|
||||
public boolean isUsingCustomKeyItemStack() {
|
||||
return this.itemStack != null;
|
||||
}
|
||||
boolean isUsingCustomKeyItemStack();
|
||||
|
||||
/**
|
||||
* Gets the result of this event.
|
||||
@@ -106,9 +61,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
* @return the result
|
||||
* @see #setResult(Result)
|
||||
*/
|
||||
public Result getResult() {
|
||||
return this.result;
|
||||
}
|
||||
Result getResult();
|
||||
|
||||
/**
|
||||
* Gets the result of this event. {@link Result#DEFAULT} is the default
|
||||
@@ -119,9 +72,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
*
|
||||
* @param result the result of this event
|
||||
*/
|
||||
public void setResult(final Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
void setResult(Result result);
|
||||
|
||||
/**
|
||||
* Shorthand method to set the {@link #getResult()} to {@link Result#DENY},
|
||||
@@ -130,11 +81,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
* @param lockedMessage the message to show if locked (or {@code null} for none)
|
||||
* @param lockedSound the sound to play if locked (or {@code null} for none)
|
||||
*/
|
||||
public void denyWithMessageAndSound(final @Nullable Component lockedMessage, final @Nullable Sound lockedSound) {
|
||||
this.result = Result.DENY;
|
||||
this.lockedMessage = lockedMessage;
|
||||
this.lockedSound = lockedSound;
|
||||
}
|
||||
void denyWithMessageAndSound(@Nullable Component lockedMessage, @Nullable Sound lockedSound);
|
||||
|
||||
/**
|
||||
* Gets the locked message that will be sent if the
|
||||
@@ -142,9 +89,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
*
|
||||
* @return the locked message (or {@code null} if none)
|
||||
*/
|
||||
public @Nullable Component getLockedMessage() {
|
||||
return this.lockedMessage;
|
||||
}
|
||||
@Nullable Component getLockedMessage();
|
||||
|
||||
/**
|
||||
* Sets the locked message that will be sent if the
|
||||
@@ -152,9 +97,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
*
|
||||
* @param lockedMessage the locked message (or {@code null} for none)
|
||||
*/
|
||||
public void setLockedMessage(final @Nullable Component lockedMessage) {
|
||||
this.lockedMessage = lockedMessage;
|
||||
}
|
||||
void setLockedMessage(@Nullable Component lockedMessage);
|
||||
|
||||
/**
|
||||
* Gets the locked sound that will play if the
|
||||
@@ -162,9 +105,7 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
*
|
||||
* @return the locked sound (or {@code null} if none)
|
||||
*/
|
||||
public @Nullable Sound getLockedSound() {
|
||||
return this.lockedSound;
|
||||
}
|
||||
@Nullable Sound getLockedSound();
|
||||
|
||||
/**
|
||||
* Sets the locked sound that will play if the
|
||||
@@ -172,16 +113,12 @@ public class BlockLockCheckEvent extends BlockEvent {
|
||||
*
|
||||
* @param lockedSound the locked sound (or {@code null} for none)
|
||||
*/
|
||||
public void setLockedSound(final @Nullable Sound lockedSound) {
|
||||
this.lockedSound = lockedSound;
|
||||
}
|
||||
void setLockedSound(@Nullable Sound lockedSound);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,30 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
public class BlockPreDispenseEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final int slot;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public BlockPreDispenseEvent(final Block block, final ItemStack itemStack, final int slot) {
|
||||
super(block);
|
||||
this.itemStack = itemStack;
|
||||
this.slot = slot;
|
||||
}
|
||||
public interface BlockPreDispenseEvent extends BlockEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the {@link ItemStack} to be dispensed.
|
||||
*
|
||||
* @return The item to be dispensed
|
||||
*/
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* Gets the inventory slot of the dispenser to dispense from.
|
||||
*
|
||||
* @return The inventory slot
|
||||
*/
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
int getSlot();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +1,41 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when an item is about to be composted by a hopper.
|
||||
* To prevent hoppers from moving items into composters, cancel the {@link InventoryMoveItemEvent}.
|
||||
*/
|
||||
@NullMarked
|
||||
public class CompostItemEvent extends BlockEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final ItemStack item;
|
||||
private boolean willRaiseLevel;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public CompostItemEvent(final Block composter, final ItemStack item, final boolean willRaiseLevel) {
|
||||
super(composter);
|
||||
this.item = item;
|
||||
this.willRaiseLevel = willRaiseLevel;
|
||||
}
|
||||
public interface CompostItemEvent extends BlockEvent {
|
||||
|
||||
/**
|
||||
* Gets the item that was used on the composter.
|
||||
*
|
||||
* @return the item
|
||||
*/
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
ItemStack getItem();
|
||||
|
||||
/**
|
||||
* Gets whether the composter will rise a level.
|
||||
*
|
||||
* @return {@code true} if successful
|
||||
*/
|
||||
public boolean willRaiseLevel() {
|
||||
return this.willRaiseLevel;
|
||||
}
|
||||
boolean willRaiseLevel();
|
||||
|
||||
/**
|
||||
* Sets whether the composter will rise a level.
|
||||
*
|
||||
* @param willRaiseLevel {@code true} if the composter should rise a level
|
||||
*/
|
||||
public void setWillRaiseLevel(final boolean willRaiseLevel) {
|
||||
this.willRaiseLevel = willRaiseLevel;
|
||||
}
|
||||
void setWillRaiseLevel(boolean willRaiseLevel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,10 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.boss.DragonBattle;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when the {@link EnderDragon} is defeated (killed) in a {@link DragonBattle},
|
||||
@@ -18,18 +14,7 @@ import org.jspecify.annotations.NullMarked;
|
||||
* <b>This event might be cancelled by default depending on
|
||||
* e.g. {@link DragonBattle#hasBeenPreviouslyKilled()} and server configuration.</b>
|
||||
*/
|
||||
@NullMarked
|
||||
public class DragonEggFormEvent extends BlockFormEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final DragonBattle dragonBattle;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public DragonEggFormEvent(final Block block, final BlockState newState, final DragonBattle dragonBattle) {
|
||||
super(block, newState);
|
||||
this.dragonBattle = dragonBattle;
|
||||
}
|
||||
public interface DragonEggFormEvent extends BlockFormEvent {
|
||||
|
||||
/**
|
||||
* Gets the {@link DragonBattle} associated with this event.
|
||||
@@ -38,16 +23,12 @@ public class DragonEggFormEvent extends BlockFormEvent {
|
||||
*
|
||||
* @return the dragon battle
|
||||
*/
|
||||
public DragonBattle getDragonBattle() {
|
||||
return this.dragonBattle;
|
||||
}
|
||||
DragonBattle getDragonBattle();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Called when a player uses shears on a block.
|
||||
@@ -19,62 +16,28 @@ import org.jspecify.annotations.NullMarked;
|
||||
* <p>
|
||||
* Examples include shearing a pumpkin to turn it into a carved pumpkin or shearing a beehive to get honeycomb.
|
||||
*/
|
||||
@NullMarked
|
||||
public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Block block;
|
||||
private final ItemStack item;
|
||||
private final EquipmentSlot hand;
|
||||
private final List<ItemStack> drops;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public PlayerShearBlockEvent(final Player player, final Block block, final ItemStack item, final EquipmentSlot hand, final List<ItemStack> drops) {
|
||||
super(player);
|
||||
this.block = block;
|
||||
this.item = item;
|
||||
this.hand = hand;
|
||||
this.drops = drops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block being sheared in this event.
|
||||
*
|
||||
* @return The {@link Block} which block is being sheared in this event.
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
public interface PlayerShearBlockEvent extends PlayerEvent, BlockEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the item used to shear the block.
|
||||
*
|
||||
* @return The {@link ItemStack} of the shears.
|
||||
*/
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
ItemStack getItem();
|
||||
|
||||
/**
|
||||
* Gets the hand used to shear the block.
|
||||
*
|
||||
* @return Either {@link EquipmentSlot#HAND} OR {@link EquipmentSlot#OFF_HAND}.
|
||||
*/
|
||||
public EquipmentSlot getHand() {
|
||||
return this.hand;
|
||||
}
|
||||
EquipmentSlot getHand();
|
||||
|
||||
/**
|
||||
* Gets the resulting drops of this event.
|
||||
*
|
||||
* @return A mutable {@link List list} of {@link ItemStack items} that will be dropped as result of this event.
|
||||
*/
|
||||
public List<ItemStack> getDrops() {
|
||||
return this.drops;
|
||||
}
|
||||
List<ItemStack> getDrops();
|
||||
|
||||
/**
|
||||
* Gets whether the shearing of the block should be cancelled or not.
|
||||
@@ -82,9 +45,7 @@ public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable {
|
||||
* @return Whether the shearing of the block should be cancelled or not.
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Sets whether the shearing of the block should be cancelled or not.
|
||||
@@ -92,16 +53,12 @@ public class PlayerShearBlockEvent extends PlayerEvent implements Cancellable {
|
||||
* @param cancel whether the shearing of the block should be cancelled or not.
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
void setCancelled(boolean cancel);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Range;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.checkerframework.common.value.qual.IntRange;
|
||||
|
||||
/**
|
||||
* Called when a Target Block is hit by a projectile.
|
||||
@@ -17,44 +11,26 @@ import org.jspecify.annotations.NullMarked;
|
||||
* and in the case that the shooter is a player, will stop them from receiving
|
||||
* advancement criteria.
|
||||
*/
|
||||
@NullMarked
|
||||
public class TargetHitEvent extends ProjectileHitEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private int signalStrength;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public TargetHitEvent(final Projectile projectile, final Block block, final BlockFace blockFace, final int signalStrength) {
|
||||
super(projectile, null, block, blockFace);
|
||||
this.signalStrength = signalStrength;
|
||||
}
|
||||
public interface TargetHitEvent extends ProjectileHitEvent {
|
||||
|
||||
/**
|
||||
* Gets the strength of the redstone signal to be emitted by the Target block
|
||||
*
|
||||
* @return the strength of the redstone signal to be emitted
|
||||
*/
|
||||
public @Range(from = 0, to = 15) int getSignalStrength() {
|
||||
return this.signalStrength;
|
||||
}
|
||||
@IntRange(from = 0, to = 15) int getSignalStrength();
|
||||
|
||||
/**
|
||||
* Sets the strength of the redstone signal to be emitted by the Target block
|
||||
*
|
||||
* @param signalStrength the strength of the redstone signal to be emitted
|
||||
*/
|
||||
public void setSignalStrength(final @Range(from = 0, to = 15) int signalStrength) {
|
||||
Preconditions.checkArgument(signalStrength >= 0 && signalStrength <= 15, "Signal strength out of range (%s), must be in range [0,15]", signalStrength);
|
||||
this.signalStrength = signalStrength;
|
||||
}
|
||||
void setSignalStrength(@IntRange(from = 0, to = 15) int signalStrength);
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +1,42 @@
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.type.Vault;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Called when a vault block changes state.
|
||||
*/
|
||||
@NullMarked
|
||||
public class VaultChangeStateEvent extends BlockEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final @Nullable Player player;
|
||||
private final Vault.State currentState;
|
||||
private final Vault.State newState;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public VaultChangeStateEvent(final Block vaultBlock, final @Nullable Player player, final Vault.State currentState, final Vault.State newState) {
|
||||
super(vaultBlock);
|
||||
this.player = player;
|
||||
this.currentState = currentState;
|
||||
this.newState = newState;
|
||||
}
|
||||
public interface VaultChangeStateEvent extends BlockEvent, Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the player associated with this state change, if applicable.
|
||||
*
|
||||
* @return The associated player, or {@code null} if not known.
|
||||
*/
|
||||
public @Nullable Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
@Nullable Player getPlayer();
|
||||
|
||||
/**
|
||||
* Gets the state the vault is currently in.
|
||||
*
|
||||
* @return The current vault state.
|
||||
*/
|
||||
public Vault.State getCurrentState() {
|
||||
return this.currentState;
|
||||
}
|
||||
Vault.State getCurrentState();
|
||||
|
||||
/**
|
||||
* Gets the state the vault is attempting to transition to.
|
||||
*
|
||||
* @return The new vault state.
|
||||
*/
|
||||
public Vault.State getNewState() {
|
||||
return this.newState;
|
||||
}
|
||||
Vault.State getNewState();
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
static HandlerList getHandlerList() {
|
||||
final class Holder {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
}
|
||||
return Holder.HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@NullMarked
|
||||
package io.papermc.paper.event.block;
|
||||
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.papermc.paper.event.connection;
|
||||
|
||||
import io.papermc.paper.connection.PlayerConnection;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
* Represents a connection related event
|
||||
*/
|
||||
public interface ConnectionEvent extends Event {
|
||||
|
||||
/**
|
||||
* {@return the player connection involved in this event}
|
||||
*/
|
||||
PlayerConnection getConnection();
|
||||
}
|
||||
Loaded 100 of 1049 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user