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.event;
018
019import net.tridentsdk.docs.InternalUseOnly;
020import net.tridentsdk.plugin.Plugin;
021import net.tridentsdk.registry.Registry;
022
023import javax.annotation.concurrent.ThreadSafe;
024
025/**
026 * The access point to the server's event handler
027 *
028 * @author The TridentSDK Team
029 * @since 0.4-alpha
030 */
031@ThreadSafe
032public interface Events extends Registry<EventNotifier> {
033    /**
034     * Notifies listeners of the event type of the event to be fired
035     *
036     * @param event the event to fire
037     */
038    void fire(Event event);
039
040    /**
041     * Normally not needed to be used. Plugin listeners are automatically registered when they are loaded.
042     *
043     * @param listener the listener instance to use to register
044     */
045    @InternalUseOnly
046    void registerListener(Plugin plugin, Listener listener);
047
048    /**
049     * Removes the listener from the caller queue, preventing it from being invoked
050     *
051     * @param cls the listener class to unregister
052     */
053    void unregister(Class<? extends Listener> cls);
054}