package net.minecraft.world.scores;

import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;

public class Objective {
    private final Scoreboard scoreboard;
    private final String name;
    private final ObjectiveCriteria criteria;
    private Component displayName;
    private ObjectiveCriteria.RenderType renderType;
    
    public Objective(final Scoreboard cwl, final String string, final ObjectiveCriteria cwo, final Component lf, final ObjectiveCriteria.RenderType a) {
        this.scoreboard = cwl;
        this.name = string;
        this.criteria = cwo;
        this.displayName = lf;
        this.renderType = a;
    }
    
    public Scoreboard getScoreboard() {
        return this.scoreboard;
    }
    
    public String getName() {
        return this.name;
    }
    
    public ObjectiveCriteria getCriteria() {
        return this.criteria;
    }
    
    public Component getDisplayName() {
        return this.displayName;
    }
    
    public Component getFormattedDisplayName() {
        final HoverEvent hoverEvent;
        return ComponentUtils.wrapInSquareBrackets(this.displayName.deepCopy().withStyle(ln -> {
            new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent(this.getName()));
            ln.setHoverEvent(hoverEvent);
        }));
    }
    
    public void setDisplayName(final Component lf) {
        this.displayName = lf;
        this.scoreboard.onObjectiveChanged(this);
    }
    
    public ObjectiveCriteria.RenderType getRenderType() {
        return this.renderType;
    }
    
    public void setRenderType(final ObjectiveCriteria.RenderType a) {
        this.renderType = a;
        this.scoreboard.onObjectiveChanged(this);
    }
}
