Add some missing annotations and an incorrect one (#12204)

This commit is contained in:
brickmonster 2025-05-18 23:31:49 +01:00 committed by GitHub
parent ce0fa4c438
commit fa360aa836
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 62 additions and 64 deletions

View File

@ -293,7 +293,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* set in the client, the {@link CompletableFuture} will complete with a * set in the client, the {@link CompletableFuture} will complete with a
* null value. * null value.
*/ */
CompletableFuture<byte[]> retrieveCookie(NamespacedKey key); CompletableFuture<byte @Nullable []> retrieveCookie(NamespacedKey key);
/** /**
* Stores a cookie in this player's client. * Stores a cookie in this player's client.
@ -1178,7 +1178,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* (constructed e.g. via {@link Material#createBlockData()}) * (constructed e.g. via {@link Material#createBlockData()})
*/ */
@Deprecated // Paper @Deprecated // Paper
public void sendSignChange(Location loc, @Nullable String[] lines) throws IllegalArgumentException; public void sendSignChange(Location loc, @Nullable String @Nullable [] lines) throws IllegalArgumentException;
/** /**
* Send a sign change. This fakes a sign change packet for a user at * Send a sign change. This fakes a sign change packet for a user at
@ -1204,7 +1204,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* (constructed e.g. via {@link Material#createBlockData()}) * (constructed e.g. via {@link Material#createBlockData()})
*/ */
@Deprecated // Paper @Deprecated // Paper
public void sendSignChange(Location loc, @Nullable String[] lines, DyeColor dyeColor) throws IllegalArgumentException; public void sendSignChange(Location loc, @Nullable String @Nullable [] lines, DyeColor dyeColor) throws IllegalArgumentException;
/** /**
* Send a sign change. This fakes a sign change packet for a user at * Send a sign change. This fakes a sign change packet for a user at
@ -1231,7 +1231,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* (constructed e.g. via {@link Material#createBlockData()}) * (constructed e.g. via {@link Material#createBlockData()})
*/ */
@Deprecated // Paper @Deprecated // Paper
public void sendSignChange(Location loc, @Nullable String[] lines, DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException; public void sendSignChange(Location loc, @Nullable String @Nullable [] lines, DyeColor dyeColor, boolean hasGlowingText) throws IllegalArgumentException;
/** /**
* Send a TileState change. This fakes a TileState change for a user at * Send a TileState change. This fakes a TileState change for a user at
@ -2836,7 +2836,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes * @throws IllegalArgumentException Thrown if the hash is not 20 bytes
* long. * long.
*/ */
public void addResourcePack(UUID id, String url, @Nullable byte[] hash, @Nullable String prompt, boolean force); public void addResourcePack(UUID id, String url, byte @Nullable [] hash, @Nullable String prompt, boolean force);
/** /**
* Request that the player's client remove a resource pack sent by the * Request that the player's client remove a resource pack sent by the

View File

@ -143,7 +143,7 @@ index 3a384175f8e7f204234bbaf3081bdc20c47a0d4b..5699bc15eba92e22433a20cb8326b59f
private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buffer) { private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buffer) {
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index ef201f4add358fbf1818f3b2ec9e75fe2cce4c8b..fe9b4484d683fe48f435a053c9c90557fdf80e7b 100644 index 6b67cc939851745718f919488c997eb6719a16fc..085040aa98704f2874bcd95b751b0a81dcdb15ad 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -343,7 +343,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -343,7 +343,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
@ -186,7 +186,7 @@ index 342bc843c384761e883de861044f4f8930ae8763..14878690a88fd4de3e2c127086607e6c
if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent(); new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent();
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index a2a4dbcfb77d44657b3dfbe97cb629de215c29eb..73717609fccd9af12e2cc39824106f49426b581c 100644 index 9b2ee3e16e2c443e8ff03faec59dd55d729e9274..5ec9e3b37e575e9805bf9f0ce5cae5c1284461d8 100644
--- a/net/minecraft/server/players/PlayerList.java --- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java
@@ -407,7 +407,7 @@ public abstract class PlayerList { @@ -407,7 +407,7 @@ public abstract class PlayerList {
@ -199,7 +199,7 @@ index a2a4dbcfb77d44657b3dfbe97cb629de215c29eb..73717609fccd9af12e2cc39824106f49
} }
// Paper end - Send empty chunk // Paper end - Send empty chunk
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 1f26826b2161cfeb27e5b2060e178b493e9142d9..63f8b0c47e3321b74f4b6bcbc1e28cd751911198 100644 index 1bb40f18b671d63719d96a58ff283767c2cfe383..ba50f21707a69bbf720345996d7c83d2064e5246 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -132,6 +132,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -132,6 +132,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@ -209,10 +209,10 @@ index 1f26826b2161cfeb27e5b2060e178b493e9142d9..63f8b0c47e3321b74f4b6bcbc1e28cd7
+ public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray + public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
private final CraftWorld world; private final CraftWorld world;
public boolean pvpMode; public boolean pvpMode;
public org.bukkit.generator.ChunkGenerator generator; public @Nullable org.bukkit.generator.ChunkGenerator generator;
@@ -201,7 +202,8 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -201,7 +202,8 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
org.bukkit.generator.BiomeProvider biomeProvider, // CraftBukkit @Nullable org.bukkit.generator.BiomeProvider biomeProvider, // Paper
org.bukkit.World.Environment env, // CraftBukkit org.bukkit.World.Environment environment, // Paper
java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config
- io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator // Paper - create paper world config - io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator // Paper - create paper world config
+ io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config + io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config

View File

@ -29729,7 +29729,7 @@ index 300f3ed58109219d97846082941b860585f66fed..892a7c1eb1b321ca6d5ca709142e7fea
// Paper start - Affects Spawning API // Paper start - Affects Spawning API
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d5be9e876 100644 index ba50f21707a69bbf720345996d7c83d2064e5246..e9751a95ffd88f365185d53f8764291d9d2473e2 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -81,6 +81,7 @@ import net.minecraft.world.level.storage.LevelData; @@ -81,6 +81,7 @@ import net.minecraft.world.level.storage.LevelData;
@ -30403,7 +30403,7 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
+ // Paper end - getblock optimisations - cache world height/sections + // Paper end - getblock optimisations - cache world height/sections
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
this.generator = gen; this.generator = generator;
@@ -281,6 +914,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -281,6 +914,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
}); });
// CraftBukkit end // CraftBukkit end

View File

@ -24,7 +24,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ private final CraftWorld world; + private final CraftWorld world;
+ public boolean pvpMode; + public boolean pvpMode;
+ public org.bukkit.generator.ChunkGenerator generator; + public @Nullable org.bukkit.generator.ChunkGenerator generator;
+ +
+ public boolean captureBlockStates = false; + public boolean captureBlockStates = false;
+ public boolean captureTreeGeneration = false; + public boolean captureTreeGeneration = false;
@ -81,16 +81,16 @@
long biomeZoomSeed, long biomeZoomSeed,
- int maxChainedNeighborUpdates - int maxChainedNeighborUpdates
+ int maxChainedNeighborUpdates, + int maxChainedNeighborUpdates,
+ org.bukkit.generator.ChunkGenerator gen, // CraftBukkit + @Nullable org.bukkit.generator.ChunkGenerator generator, // Paper
+ org.bukkit.generator.BiomeProvider biomeProvider, // CraftBukkit + @Nullable org.bukkit.generator.BiomeProvider biomeProvider, // Paper
+ org.bukkit.World.Environment env, // CraftBukkit + org.bukkit.World.Environment environment, // Paper
+ java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config + java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config
+ io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator // Paper - create paper world config + io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator // Paper - create paper world config
) { ) {
+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
+ this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
+ this.generator = gen; + this.generator = generator;
+ this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); + this.world = new CraftWorld((ServerLevel) this, generator, biomeProvider, environment);
+ +
+ for (SpawnCategory spawnCategory : SpawnCategory.values()) { + for (SpawnCategory spawnCategory : SpawnCategory.values()) {
+ if (org.bukkit.craftbukkit.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) { + if (org.bukkit.craftbukkit.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) {

View File

@ -157,8 +157,8 @@ public class CraftWorld extends CraftRegionAccessor implements World {
private WorldBorder worldBorder; private WorldBorder worldBorder;
private Environment environment; private Environment environment;
private final CraftServer server = (CraftServer) Bukkit.getServer(); private final CraftServer server = (CraftServer) Bukkit.getServer();
private final ChunkGenerator generator; private final @Nullable ChunkGenerator generator;
private final BiomeProvider biomeProvider; private final @Nullable BiomeProvider biomeProvider;
private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>(); private final List<BlockPopulator> populators = new ArrayList<BlockPopulator>();
private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this); private final BlockMetadataStore blockMetadata = new BlockMetadataStore(this);
private final Object2IntOpenHashMap<SpawnCategory> spawnCategoryLimit = new Object2IntOpenHashMap<>(); private final Object2IntOpenHashMap<SpawnCategory> spawnCategoryLimit = new Object2IntOpenHashMap<>();
@ -286,12 +286,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
private static final Random rand = new Random(); private static final Random rand = new Random();
public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) { public CraftWorld(ServerLevel world, @Nullable ChunkGenerator generator, @Nullable BiomeProvider biomeProvider, Environment environment) {
this.world = world; this.world = world;
this.generator = gen; this.generator = generator;
this.biomeProvider = biomeProvider; this.biomeProvider = biomeProvider;
this.environment = env; this.environment = environment;
// Paper start - per world spawn limits // Paper start - per world spawn limits
for (SpawnCategory spawnCategory : SpawnCategory.values()) { for (SpawnCategory spawnCategory : SpawnCategory.values()) {
if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { if (CraftSpawnCategory.isValidForLimits(spawnCategory)) {
@ -909,7 +909,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
} }
@Override @Override
public Environment getEnvironment() { public @NotNull Environment getEnvironment() {
return this.environment; return this.environment;
} }
@ -924,12 +924,12 @@ public class CraftWorld extends CraftRegionAccessor implements World {
} }
@Override @Override
public ChunkGenerator getGenerator() { public @Nullable ChunkGenerator getGenerator() {
return this.generator; return this.generator;
} }
@Override @Override
public BiomeProvider getBiomeProvider() { public @Nullable BiomeProvider getBiomeProvider() {
return this.biomeProvider; return this.biomeProvider;
} }

View File

@ -42,7 +42,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable; import net.kyori.adventure.util.TriState;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.minecraft.advancements.AdvancementProgress; import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.commands.Commands; import net.minecraft.commands.Commands;
@ -202,7 +202,8 @@ import org.bukkit.plugin.messaging.StandardMessenger;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import org.jetbrains.annotations.NotNull; import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
@DelegateDeserialization(CraftOfflinePlayer.class) @DelegateDeserialization(CraftOfflinePlayer.class)
public class CraftPlayer extends CraftHumanEntity implements Player { public class CraftPlayer extends CraftHumanEntity implements Player {
@ -328,7 +329,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
void kickPlayer(Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause); // Paper - kick event causes void kickPlayer(Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause); // Paper - kick event causes
} }
public record CookieFuture(ResourceLocation key, CompletableFuture<byte[]> future) { public record CookieFuture(ResourceLocation key, CompletableFuture<byte @Nullable []> future) {
} }
private final Queue<CookieFuture> requestedCookies = new LinkedList<>(); private final Queue<CookieFuture> requestedCookies = new LinkedList<>();
@ -357,10 +358,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public CompletableFuture<byte[]> retrieveCookie(NamespacedKey key) { public CompletableFuture<byte @Nullable []> retrieveCookie(final NamespacedKey key) {
Preconditions.checkArgument(key != null, "Cookie key cannot be null"); Preconditions.checkArgument(key != null, "Cookie key cannot be null");
CompletableFuture<byte[]> future = new CompletableFuture<>(); CompletableFuture<byte @Nullable []> future = new CompletableFuture<>();
ResourceLocation nms = CraftNamespacedKey.toMinecraft(key); ResourceLocation nms = CraftNamespacedKey.toMinecraft(key);
this.requestedCookies.add(new CookieFuture(nms, future)); this.requestedCookies.add(new CookieFuture(nms, future));
@ -458,7 +459,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override @Override
@Deprecated @Deprecated
public void sendActionBar(BaseComponent[] message) { public void sendActionBar(BaseComponent[] message) {
if (getHandle().connection == null) return; if (getHandle().connection == null || message == null) return;
net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket packet = new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket(org.bukkit.craftbukkit.util.CraftChatMessage.bungeeToVanilla(message)); net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket packet = new net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket(org.bukkit.craftbukkit.util.CraftChatMessage.bungeeToVanilla(message));
getHandle().connection.send(packet); getHandle().connection.send(packet);
} }
@ -478,7 +479,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) { public void setPlayerListHeaderFooter(BaseComponent @Nullable [] header, BaseComponent @Nullable [] footer) {
if (header != null) { if (header != null) {
String headerJson = CraftChatMessage.bungeeToJson(header); String headerJson = CraftChatMessage.bungeeToJson(header);
playerListHeader = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(headerJson); playerListHeader = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(headerJson);
@ -497,12 +498,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) { public void setPlayerListHeaderFooter(@Nullable BaseComponent header, @Nullable BaseComponent footer) {
this.setPlayerListHeaderFooter(header == null ? null : new BaseComponent[]{header}, this.setPlayerListHeaderFooter(header == null ? null : new BaseComponent[]{header},
footer == null ? null : new BaseComponent[]{footer}); footer == null ? null : new BaseComponent[]{footer});
} }
@Override @Override
public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks) { public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks) {
getHandle().connection.send(new ClientboundSetTitlesAnimationPacket(fadeInTicks, stayTicks, fadeOutTicks)); getHandle().connection.send(new ClientboundSetTitlesAnimationPacket(fadeInTicks, stayTicks, fadeOutTicks));
@ -736,7 +736,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void addAdditionalChatCompletions(@NotNull Collection<String> completions) { public void addAdditionalChatCompletions(@NonNull Collection<String> completions) {
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket( this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket(
net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.ADD, net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.ADD,
new ArrayList<>(completions) new ArrayList<>(completions)
@ -744,7 +744,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void removeAdditionalChatCompletions(@NotNull Collection<String> completions) { public void removeAdditionalChatCompletions(@NonNull Collection<String> completions) {
this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket( this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket(
net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.REMOVE, net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket.Action.REMOVE,
new ArrayList<>(completions) new ArrayList<>(completions)
@ -1101,17 +1101,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
// Paper end // Paper end
@Override @Override
public void sendSignChange(Location loc, String[] lines) { public void sendSignChange(Location loc, @Nullable String @Nullable [] lines) {
this.sendSignChange(loc, lines, DyeColor.BLACK); this.sendSignChange(loc, lines, DyeColor.BLACK);
} }
@Override @Override
public void sendSignChange(Location loc, String[] lines, DyeColor dyeColor) { public void sendSignChange(Location loc, @Nullable String @Nullable [] lines, DyeColor dyeColor) {
this.sendSignChange(loc, lines, dyeColor, false); this.sendSignChange(loc, lines, dyeColor, false);
} }
@Override @Override
public void sendSignChange(Location loc, String[] lines, DyeColor dyeColor, boolean hasGlowingText) { public void sendSignChange(Location loc, @Nullable String @Nullable [] lines, DyeColor dyeColor, boolean hasGlowingText) {
Preconditions.checkArgument(loc != null, "Location cannot be null"); Preconditions.checkArgument(loc != null, "Location cannot be null");
Preconditions.checkArgument(dyeColor != null, "DyeColor cannot be null"); Preconditions.checkArgument(dyeColor != null, "DyeColor cannot be null");
@ -1142,7 +1142,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void sendBlockUpdate(@NotNull Location location, @NotNull TileState tileState) throws IllegalArgumentException { public void sendBlockUpdate(@NonNull Location location, @NonNull TileState tileState) throws IllegalArgumentException {
Preconditions.checkArgument(location != null, "Location can not be null"); Preconditions.checkArgument(location != null, "Location can not be null");
Preconditions.checkArgument(tileState != null, "TileState can not be null"); Preconditions.checkArgument(tileState != null, "TileState can not be null");
@ -1153,12 +1153,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void sendEquipmentChange(LivingEntity entity, EquipmentSlot slot, ItemStack item) { public void sendEquipmentChange(LivingEntity entity, EquipmentSlot slot, @Nullable ItemStack item) {
this.sendEquipmentChange(entity, java.util.Collections.singletonMap(slot, item)); // Paper - replace Map.of to allow null values this.sendEquipmentChange(entity, java.util.Collections.singletonMap(slot, item));
} }
@Override @Override
public void sendEquipmentChange(LivingEntity entity, Map<EquipmentSlot, ItemStack> items) { public void sendEquipmentChange(LivingEntity entity, Map<EquipmentSlot, @Nullable ItemStack> items) {
Preconditions.checkArgument(entity != null, "Entity cannot be null"); Preconditions.checkArgument(entity != null, "Entity cannot be null");
Preconditions.checkArgument(items != null, "items cannot be null"); Preconditions.checkArgument(items != null, "items cannot be null");
Preconditions.checkArgument(!items.isEmpty(), "items cannot be empty"); Preconditions.checkArgument(!items.isEmpty(), "items cannot be empty");
@ -1380,7 +1380,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void lookAt(@NotNull org.bukkit.entity.Entity entity, @NotNull LookAnchor playerAnchor, @NotNull LookAnchor entityAnchor) { public void lookAt(org.bukkit.entity.@NonNull Entity entity, @NonNull LookAnchor playerAnchor, @NonNull LookAnchor entityAnchor) {
this.getHandle().lookAt(toNmsAnchor(playerAnchor), ((CraftEntity) entity).getHandle(), toNmsAnchor(entityAnchor)); this.getHandle().lookAt(toNmsAnchor(playerAnchor), ((CraftEntity) entity).getHandle(), toNmsAnchor(entityAnchor));
} }
@ -2006,8 +2006,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().connection.send(packet); this.getHandle().connection.send(packet);
} }
@Nullable private static @Nullable WeakReference<Plugin> getPluginWeakReference(@Nullable Plugin plugin) {
private static WeakReference<Plugin> getPluginWeakReference(@Nullable Plugin plugin) {
return (plugin == null) ? null : CraftPlayer.pluginWeakReferences.computeIfAbsent(plugin, WeakReference::new); return (plugin == null) ? null : CraftPlayer.pluginWeakReferences.computeIfAbsent(plugin, WeakReference::new);
} }
@ -2276,7 +2275,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public boolean unlistPlayer(@NotNull Player other) { public boolean unlistPlayer(@NonNull Player other) {
Preconditions.checkNotNull(other, "hidden entity cannot be null"); Preconditions.checkNotNull(other, "hidden entity cannot be null");
if (this.getHandle().connection == null) return false; if (this.getHandle().connection == null) return false;
if (!this.canSee(other)) return false; if (!this.canSee(other)) return false;
@ -2290,7 +2289,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public boolean listPlayer(@NotNull Player other) { public boolean listPlayer(@NonNull Player other) {
Preconditions.checkNotNull(other, "hidden entity cannot be null"); Preconditions.checkNotNull(other, "hidden entity cannot be null");
if (this.getHandle().connection == null) return false; if (this.getHandle().connection == null) return false;
if (!this.canSee(other)) throw new IllegalStateException("Player cannot see other player"); if (!this.canSee(other)) throw new IllegalStateException("Player cannot see other player");
@ -2445,29 +2444,29 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void setResourcePack(String url, byte[] hash) { public void setResourcePack(String url, byte @Nullable [] hash) {
this.setResourcePack(url, hash, false); this.setResourcePack(url, hash, false);
} }
@Override @Override
public void setResourcePack(String url, byte[] hash, String prompt) { public void setResourcePack(String url, byte @Nullable [] hash, String prompt) {
this.setResourcePack(url, hash, prompt, false); this.setResourcePack(url, hash, prompt, false);
} }
@Override @Override
public void setResourcePack(String url, byte[] hash, boolean force) { public void setResourcePack(String url, byte @Nullable [] hash, boolean force) {
this.setResourcePack(url, hash, (String) null, force); this.setResourcePack(url, hash, (String) null, force);
} }
@Override @Override
public void setResourcePack(String url, byte[] hash, String prompt, boolean force) { public void setResourcePack(String url, byte @Nullable [] hash, String prompt, boolean force) {
Preconditions.checkArgument(url != null, "Resource pack URL cannot be null"); Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
this.setResourcePack(UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8)), url, hash, prompt, force); this.setResourcePack(UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8)), url, hash, prompt, force);
} }
@Override @Override
public void setResourcePack(UUID id, String url, byte[] hash, String prompt, boolean force) { public void setResourcePack(UUID id, String url, byte @Nullable [] hash, String prompt, boolean force) {
Preconditions.checkArgument(id != null, "Resource pack ID cannot be null"); Preconditions.checkArgument(id != null, "Resource pack ID cannot be null");
Preconditions.checkArgument(url != null, "Resource pack URL cannot be null"); Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
@ -2481,7 +2480,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void addResourcePack(UUID id, String url, byte[] hash, String prompt, boolean force) { public void addResourcePack(UUID id, String url, byte @Nullable [] hash, String prompt, boolean force) {
Preconditions.checkArgument(url != null, "Resource pack URL cannot be null"); Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
String hashStr = ""; String hashStr = "";
@ -2495,7 +2494,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper start - adventure // Paper start - adventure
@Override @Override
public void setResourcePack(final UUID uuid, final String url, final byte[] hashBytes, final net.kyori.adventure.text.Component prompt, final boolean force) { public void setResourcePack(final UUID uuid, final String url, final byte @Nullable [] hashBytes, final net.kyori.adventure.text.Component prompt, final boolean force) {
Preconditions.checkArgument(uuid != null, "Resource pack UUID cannot be null"); Preconditions.checkArgument(uuid != null, "Resource pack UUID cannot be null");
Preconditions.checkArgument(url != null, "Resource pack URL cannot be null"); Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
final String hash; final String hash;
@ -2534,7 +2533,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void removeResourcePacks(final UUID id, final UUID ... others) { public void removeResourcePacks(final UUID id, final UUID... others) {
if (this.getHandle().connection == null) return; if (this.getHandle().connection == null) return;
this.sendBundle(net.kyori.adventure.util.MonkeyBars.nonEmptyArrayToList(pack -> new ClientboundResourcePackPopPacket(Optional.of(pack)), id, others)); this.sendBundle(net.kyori.adventure.util.MonkeyBars.nonEmptyArrayToList(pack -> new ClientboundResourcePackPopPacket(Optional.of(pack)), id, others));
} }
@ -2683,13 +2682,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper start - flying fall damage // Paper start - flying fall damage
@Override @Override
public void setFlyingFallDamage(@NotNull net.kyori.adventure.util.TriState flyingFallDamage) { public void setFlyingFallDamage(@NonNull TriState flyingFallDamage) {
getHandle().flyingFallDamage = flyingFallDamage; getHandle().flyingFallDamage = flyingFallDamage;
} }
@NotNull
@Override @Override
public net.kyori.adventure.util.TriState hasFlyingFallDamage() { public @NonNull TriState hasFlyingFallDamage() {
return getHandle().flyingFallDamage; return getHandle().flyingFallDamage;
} }
// Paper end - flying fall damage // Paper end - flying fall damage
@ -3035,7 +3033,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
@Override @Override
public void openSign(@NotNull Sign sign, @NotNull Side side) { public void openSign(@NonNull Sign sign, @NonNull Side side) {
CraftSign.openSign(sign, this, side); CraftSign.openSign(sign, this, side);
} }
@ -3205,7 +3203,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private @Nullable Set<net.kyori.adventure.bossbar.BossBar> activeBossBars; private @Nullable Set<net.kyori.adventure.bossbar.BossBar> activeBossBars;
@Override @Override
public @NotNull Iterable<? extends net.kyori.adventure.bossbar.BossBar> activeBossBars() { public @NonNull Iterable<? extends net.kyori.adventure.bossbar.BossBar> activeBossBars() {
if (this.activeBossBars != null) { if (this.activeBossBars != null) {
return java.util.Collections.unmodifiableSet(this.activeBossBars); return java.util.Collections.unmodifiableSet(this.activeBossBars);
} }
@ -3513,7 +3511,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
// Paper end - entity effect API // Paper end - entity effect API
@Override @Override
public @NotNull PlayerGiveResult give(@NotNull final Collection<@NotNull ItemStack> items, final boolean dropIfFull) { public @NonNull PlayerGiveResult give(final @NonNull Collection<@NonNull ItemStack> items, final boolean dropIfFull) {
Preconditions.checkArgument(items != null, "items cannot be null"); Preconditions.checkArgument(items != null, "items cannot be null");
if (items.isEmpty()) return PaperPlayerGiveResult.EMPTY; // Early opt out for empty input. if (items.isEmpty()) return PaperPlayerGiveResult.EMPTY; // Early opt out for empty input.