Repository: PaperMC/Paper
File: paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftVault.java (Java)

Code before:
        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(config.lootTable(), activationRange, config.deactivationRange(), config.keyItem(), config.overrideLootTableToDisplay()));
    }

    @Override
    public double getDeactivationRange() {
        return this.getSnapshot().getConfig().deactivationRange();
    }

    @Override
    public void setDeactivationRange(final double deactivationRange) {
        Preconditions.checkArgument(Double.isFinite(deactivationRange), "deactivation range must be a number");
        Preconditions.checkArgument(deactivationRange >= getActivationRange(), "New deactivation range (%f) must be more or equal to activation range (%f)".formatted(deactivationRange, getActivationRange()));

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(config.lootTable(), config.activationRange(), deactivationRange, config.keyItem(), config.overrideLootTableToDisplay()));
    }

    @Override
    public ItemStack getKeyItem() {
        return this.getSnapshot().getConfig().keyItem().asBukkitCopy();
    }

    @Override
    public void setKeyItem(final ItemStack key) {
        Preconditions.checkNotNull(key, "key must not be null");

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(config.lootTable(), config.activationRange(), config.deactivationRange(), CraftItemStack.asNMSCopy(key), config.overrideLootTableToDisplay()));
    }

    @Override
    public LootTable getLootTable() {
        return CraftLootTable.minecraftToBukkit(this.getSnapshot().getConfig().lootTable());
    }

    @Override
    public void setLootTable(final LootTable lootTable) {
        final ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTableKey = CraftLootTable.bukkitToMinecraft(lootTable);
        Preconditions.checkNotNull(lootTableKey, "lootTable must not be null");

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(lootTableKey, config.activationRange(), config.deactivationRange(), config.keyItem(), config.overrideLootTableToDisplay()));
    }

    @Override
    public @Nullable LootTable getDisplayLootTable() {
        return this.getSnapshot().getConfig().overrideLootTableToDisplay().map(CraftLootTable::minecraftToBukkit).orElse(null);
    }

    @Override

Review comment (bug):
This throw a NPE and not a IllegalArgumentException like another cases where this type of check is made.

Code after:

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(config.lootTable(), activationRange, config.deactivationRange(), config.keyItem(), config.overrideLootTableToDisplay()));
    }

    @Override
    public double getDeactivationRange() {
        return this.getSnapshot().getConfig().deactivationRange();
    }

    @Override
    public void setDeactivationRange(final double deactivationRange) {
        Preconditions.checkArgument(Double.isFinite(deactivationRange), "deactivation range must not be NaN or infinite");
        Preconditions.checkArgument(deactivationRange >= this.getActivationRange(), "New deactivation range (%s) must be more or equal to activation range (%s)", deactivationRange, this.getActivationRange());

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(config.lootTable(), config.activationRange(), deactivationRange, config.keyItem(), config.overrideLootTableToDisplay()));
    }

    @Override
    public ItemStack getKeyItem() {
        return this.getSnapshot().getConfig().keyItem().asBukkitCopy();
    }

    @Override
    public void setKeyItem(final ItemStack key) {
        Preconditions.checkArgument(key != null, "key must not be null");

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(config.lootTable(), config.activationRange(), config.deactivationRange(), CraftItemStack.asNMSCopy(key), config.overrideLootTableToDisplay()));
    }

    @Override
    public LootTable getLootTable() {
        return CraftLootTable.minecraftToBukkit(this.getSnapshot().getConfig().lootTable());
    }

    @Override
    public void setLootTable(final LootTable lootTable) {
        final ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTableKey = CraftLootTable.bukkitToMinecraft(lootTable);
        Preconditions.checkArgument(lootTableKey != null, "lootTable must not be null");

        final VaultConfig config = this.getSnapshot().getConfig();
        this.getSnapshot().setConfig(new VaultConfig(lootTableKey, config.activationRange(), config.deactivationRange(), config.keyItem(), config.overrideLootTableToDisplay()));
    }

    @Override
    public @Nullable LootTable getDisplayedLootTable() {
        return this.getSnapshot().getConfig().overrideLootTableToDisplay().map(CraftLootTable::minecraftToBukkit).orElse(null);
    }