Repository: PaperMC/Paper
File: paper-server/src/main/java/io/papermc/paper/registry/data/PaperDamageTypeRegistryEntry.java (Java)

Code before:
package io.papermc.paper.registry.data;

import io.papermc.paper.registry.PaperRegistryBuilder;
import io.papermc.paper.registry.data.util.Conversions;
import net.minecraft.world.damagesource.*;
import org.bukkit.craftbukkit.damage.CraftDamageEffect;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.damage.DamageEffect;
import org.jspecify.annotations.Nullable;

import static io.papermc.paper.registry.data.util.Checks.asConfigured;

public class PaperDamageTypeRegistryEntry implements DamageTypeRegistryEntry {
    protected @Nullable String messageId;
    protected float exhaustion;
    protected @Nullable DamageScaling damageScaling;
    protected @Nullable DamageEffects damageEffects;
    protected @Nullable DeathMessageType deathMessageType;

    protected final Conversions conversions;

    public PaperDamageTypeRegistryEntry(
            final Conversions conversions,
            final @Nullable DamageType internal
    ) {
        this.conversions = conversions;
        if (internal == null) return;

        this.messageId = internal.msgId();
        this.exhaustion = internal.exhaustion();
        this.damageScaling = internal.scaling();
        this.damageEffects = internal.effects();
        this.deathMessageType = internal.deathMessageType();
    }

    @Override
    public String messageId() {
        return asConfigured(messageId, "messsageId");
    }

    @Override
    public float exhaustion() {
        return exhaustion;

Review comment (suggestion):
I think these should be initialized to their defaults from the codec. That way you don't need to do the big complicated `build` method that chooses one of 3 constructors.

Code after:
package io.papermc.paper.registry.data;

import io.papermc.paper.registry.PaperRegistryBuilder;
import io.papermc.paper.registry.data.util.Conversions;
import net.minecraft.world.damagesource.DamageEffects;
import net.minecraft.world.damagesource.DamageScaling;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.damagesource.DeathMessageType;
import org.bukkit.craftbukkit.damage.CraftDamageEffect;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.damage.DamageEffect;
import org.jspecify.annotations.Nullable;

import static io.papermc.paper.registry.data.util.Checks.asConfigured;

public class PaperDamageTypeRegistryEntry implements DamageTypeRegistryEntry {

    protected @Nullable String messageId;
    protected @Nullable Float exhaustion;
    protected @Nullable DamageScaling damageScaling;
    protected DamageEffects damageEffects = DamageEffects.HURT;
    protected DeathMessageType deathMessageType = DeathMessageType.DEFAULT;

    protected final Conversions conversions;

    public PaperDamageTypeRegistryEntry(
        final Conversions conversions,
        final @Nullable DamageType internal
    ) {
        this.conversions = conversions;
        if (internal == null) return;

        this.messageId = internal.msgId();
        this.exhaustion = internal.exhaustion();
        this.damageScaling = internal.scaling();
        this.damageEffects = internal.effects();
        this.deathMessageType = internal.deathMessageType();
    }

    @Override
    public String messageId() {
        return asConfigured(messageId, "messsageId");
    }