package net.minecraft.network.chat;

import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.Map;

public class HoverEvent {
    private final Action action;
    private final Component value;
    
    public HoverEvent(final Action a, final Component lf) {
        this.action = a;
        this.value = lf;
    }
    
    public Action getAction() {
        return this.action;
    }
    
    public Component getValue() {
        return this.value;
    }
    
    @Override
    public boolean equals(final Object object) {
        if (this == object) {
            return true;
        }
        if (object == null || this.getClass() != object.getClass()) {
            return false;
        }
        final HoverEvent li3 = (HoverEvent)object;
        if (this.action != li3.action) {
            return false;
        }
        if (this.value != null) {
            if (this.value.equals(li3.value)) {
                return true;
            }
        }
        else if (li3.value == null) {
            return true;
        }
        return false;
    }
    
    @Override
    public String toString() {
        return "HoverEvent{action=" + this.action + ", value='" + this.value + '\'' + '}';
    }
    
    @Override
    public int hashCode() {
        int integer2 = this.action.hashCode();
        integer2 = 31 * integer2 + ((this.value != null) ? this.value.hashCode() : 0);
        return integer2;
    }
    
    public enum Action {
        SHOW_TEXT("show_text", true), 
        SHOW_ITEM("show_item", true), 
        SHOW_ENTITY("show_entity", true);
        
        private static final Map<String, Action> LOOKUP;
        private final boolean allowFromServer;
        private final String name;
        
        private Action(final String string3, final boolean boolean4) {
            this.name = string3;
            this.allowFromServer = boolean4;
        }
        
        public boolean isAllowedFromServer() {
            return this.allowFromServer;
        }
        
        public String getName() {
            return this.name;
        }
        
        public static Action getByName(final String string) {
            return Action.LOOKUP.get(string);
        }
        
        static {
            LOOKUP = Arrays.<Action>stream(values()).collect(Collectors.toMap(Action::getName, a -> a));
        }
    }
}
