001/*
002 * Trident - A Multithreaded Server Alternative
003 * Copyright 2014 The TridentSDK Team
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package net.tridentsdk.meta;
019
020import javax.annotation.concurrent.NotThreadSafe;
021
022/**
023 * This event occurs when a player clicks on a chat item
024 *
025 * @author The TridentSDK Team
026 * @since 0.3-alpha-DP
027 */
028@NotThreadSafe
029public class ClickEvent {
030    private ClickAction action;
031    private String value;
032
033    /**
034     * Sets the action that occurs when the player clicks the chat message
035     *
036     * @param action the action that occurs when the player clicks the chat
037     * @return the instance of the event
038     */
039    public ClickEvent action(ClickAction action) {
040        this.action = action;
041
042        return this;
043    }
044
045    /**
046     * Sets the value of the action when the player clicks the chat message
047     *
048     * @param value the value of the action that occurs when the player clicks the chat
049     * @return the instance of the event
050     */
051    public ClickEvent value(String value) {
052        this.value = value;
053
054        return this;
055    }
056
057    /**
058     * Obtains the action that occurs when the chat is clicked
059     *
060     * @return the action that occurs when the chat is clicked
061     */
062    public ClickAction action() {
063        return action;
064    }
065
066    /**
067     * Obtains the value of the action that occurs when the chat is clicked
068     *
069     * @return the value of the action that occurs when the chat is clicked
070     */
071    public String value() {
072        return value;
073    }
074
075    /**
076     * An action that occurs when the player clicks on the chat message
077     *
078     * @author The TridentSDK Team
079     * @since 0.3-alpha-DP
080     */
081    public enum ClickAction {
082        OPEN_URL,
083        OPEN_FILE,
084        RUN_COMMAND,
085        SUGGEST_COMMAND;
086
087        @Override
088        public String toString() {
089            return super.toString().toLowerCase();
090        }
091    }
092}