| 1 | package net.minecraft.event;
|
| 2 |
|
| 3 | import com.google.common.collect.Maps;
|
| 4 | import java.util.Map;
|
| 5 | import net.minecraft.util.IChatComponent;
|
| 6 |
|
| 7 | public class HoverEvent
|
| 8 | {
|
| 9 | private final HoverEvent.Action action;
|
| 10 | private final IChatComponent value;
|
| 11 |
|
| 12 | public HoverEvent(HoverEvent.Action actionIn, IChatComponent valueIn)
|
| 13 | {
|
| 14 | this.action = actionIn;
|
| 15 | this.value = valueIn;
|
| 16 | }
|
| 17 |
|
| 18 | /**
|
| 19 | * Gets the action to perform when this event is raised.
|
| 20 | */
|
| 21 | public HoverEvent.Action getAction()
|
| 22 | {
|
| 23 | return this.action;
|
| 24 | }
|
| 25 |
|
| 26 | /**
|
| 27 | * Gets the value to perform the action on when this event is raised. For example, if the action is "show item",
|
| 28 | * this would be the item to show.
|
| 29 | */
|
| 30 | public IChatComponent getValue()
|
| 31 | {
|
| 32 | return this.value;
|
| 33 | }
|
| 34 |
|
| 35 | public boolean equals(Object p_equals_1_)
|
| 36 | {
|
| 37 | if (this == p_equals_1_)
|
| 38 | {
|
| 39 | return true;
|
| 40 | }
|
| 41 | else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass())
|
| 42 | {
|
| 43 | HoverEvent hoverevent = (HoverEvent)p_equals_1_;
|
| 44 |
|
| 45 | if (this.action != hoverevent.action)
|
| 46 | {
|
| 47 | return false;
|
| 48 | }
|
| 49 | else
|
| 50 | {
|
| 51 | if (this.value != null)
|
| 52 | {
|
| 53 | if (!this.value.equals(hoverevent.value))
|
| 54 | {
|
| 55 | return false;
|
| 56 | }
|
| 57 | }
|
| 58 | else if (hoverevent.value != null)
|
| 59 | {
|
| 60 | return false;
|
| 61 | }
|
| 62 |
|
| 63 | return true;
|
| 64 | }
|
| 65 | }
|
| 66 | else
|
| 67 | {
|
| 68 | return false;
|
| 69 | }
|
| 70 | }
|
| 71 |
|
| 72 | public String toString()
|
| 73 | {
|
| 74 | return "HoverEvent{action=" + this.action + ", value=\'" + this.value + '\'' + '}';
|
| 75 | }
|
| 76 |
|
| 77 | public int hashCode()
|
| 78 | {
|
| 79 | int i = this.action.hashCode();
|
| 80 | i = 31 * i + (this.value != null ? this.value.hashCode() : 0);
|
| 81 | return i;
|
| 82 | }
|
| 83 |
|
| 84 | public static enum Action
|
| 85 | {
|
| 86 | SHOW_TEXT("show_text", true),
|
| 87 | SHOW_ACHIEVEMENT("show_achievement", true),
|
| 88 | SHOW_ITEM("show_item", true),
|
| 89 | SHOW_ENTITY("show_entity", true);
|
| 90 |
|
| 91 | private static final Map<String, HoverEvent.Action> nameMapping = Maps.<String, HoverEvent.Action>newHashMap();
|
| 92 | private final boolean allowedInChat;
|
| 93 | private final String canonicalName;
|
| 94 |
|
| 95 | private Action(String canonicalNameIn, boolean allowedInChatIn)
|
| 96 | {
|
| 97 | this.canonicalName = canonicalNameIn;
|
| 98 | this.allowedInChat = allowedInChatIn;
|
| 99 | }
|
| 100 |
|
| 101 | public boolean shouldAllowInChat()
|
| 102 | {
|
| 103 | return this.allowedInChat;
|
| 104 | }
|
| 105 |
|
| 106 | public String getCanonicalName()
|
| 107 | {
|
| 108 | return this.canonicalName;
|
| 109 | }
|
| 110 |
|
| 111 | public static HoverEvent.Action getValueByCanonicalName(String canonicalNameIn)
|
| 112 | {
|
| 113 | return (HoverEvent.Action)nameMapping.get(canonicalNameIn);
|
| 114 | }
|
| 115 |
|
| 116 | static {
|
| 117 | for (HoverEvent.Action hoverevent$action : values())
|
| 118 | {
|
| 119 | nameMapping.put(hoverevent$action.getCanonicalName(), hoverevent$action);
|
| 120 | }
|
| 121 | }
|
| 122 | }
|
| 123 | }
|
| 124 |
|