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 */
017package net.tridentsdk.plugin.cmd;
018
019import net.tridentsdk.plugin.Plugin;
020import net.tridentsdk.registry.Registry;
021
022import javax.annotation.concurrent.ThreadSafe;
023
024/**
025 * /**
026 * Handles commands passed from the server
027 *
028 * <p>To access this handler, use this code:
029 * <pre><code>
030 *     Commands handler = Registered.commands();
031 * </code></pre></p>
032 *
033 * @author The TridentSDK Team
034 * @since 0.3-alpha-DP
035 */
036@ThreadSafe
037public interface Commands extends Registry<Command> {
038    /**
039     * Handles the message sent, without the preceding "/"
040     *
041     * @param message the command executed
042     */
043    void handle(String message, CommandIssuer issuer);
044
045    /**
046     * Registers the command for the plugin
047     *
048     * <p>You do not need to call this method unless the command is marked with
049     * {@link net.tridentsdk.plugin.annotation.IgnoreRegistration}</p>
050     *
051     * @param plugin the plugin to register for
052     * @param command the command to register
053     * @return unspecified
054     */
055    int register(Plugin plugin, Command command);
056
057    /**
058     * Unregisters the given command handler
059     *
060     * @param cls the command to unregister
061     */
062    void unregister(Class<? extends Command> cls);
063}