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.registry;
018
019import com.google.common.base.Preconditions;
020import net.tridentsdk.Trident;
021import net.tridentsdk.concurrent.Scheduler;
022import net.tridentsdk.docs.InternalUseOnly;
023import net.tridentsdk.event.Events;
024import net.tridentsdk.inventory.Inventories;
025import net.tridentsdk.plugin.Plugins;
026import net.tridentsdk.plugin.channel.PluginChannels;
027import net.tridentsdk.plugin.cmd.Commands;
028import net.tridentsdk.service.ChatFormatter;
029import net.tridentsdk.service.Transactions;
030import net.tridentsdk.util.TridentLogger;
031import net.tridentsdk.world.World;
032
033import javax.annotation.concurrent.ThreadSafe;
034import java.util.Map;
035
036/**
037 * Allows access to the instance of various server objects
038 *
039 * @author The TridentSDK Team
040 * @since 0.4-alpha
041 */
042@ThreadSafe
043@Deprecated
044public class Registered {
045    private static volatile Implementation impl;
046
047    @InternalUseOnly
048    public static void setProvider(Implementation implementation) {
049        Preconditions.checkArgument(impl == null, "You may not set the provider of Registered");
050        impl = implementation;
051    }
052
053    @InternalUseOnly
054    public static Implementation impl() {
055        return impl;
056    }
057
058    /**
059     * Obtains the static instance of the channel handler
060     *
061     * @return the channel handler instance
062     */
063    public static PluginChannels channels() {
064        return impl.channels();
065    }
066
067    /**
068     * Obtains access to the players on the server
069     *
070     * @return the players access
071     */
072    public static Players players() {
073        return impl.players();
074    }
075
076    /**
077     * Obtains the status handler for the players
078     *
079     * @see PlayerStatus
080     * @return the statuses handler
081     */
082    public static PlayerStatus statuses() {
083        return impl.statuses();
084    }
085
086    /**
087     * Obtains the loaded worlds, name to world pairs
088     *
089     * @return the worlds that have been loaded
090     */
091    public static Map<String, World> worlds() {
092        return impl.worlds();
093    }
094
095    /**
096     * Obtains the inventory handler
097     *
098     * @return the inventory handler
099     */
100    public static Inventories inventories() {
101        return impl.inventories();
102    }
103
104    /**
105     * Obtains the scheduler
106     *
107     * @return the scheduler
108     */
109    public static Scheduler tasks() {
110        return impl.scheduler();
111    }
112
113    /**
114     * Obtains the event handler
115     *
116     * @return the event handler
117     */
118    public static Events events() {
119        return impl.events();
120    }
121
122    /**
123     * Obtains the plugin handler
124     *
125     * @return the plugin handler
126     */
127    public static Plugins plugins() {
128        return impl.plugins();
129    }
130
131    /**
132     * Obtains the command handler
133     *
134     * @return the command handler
135     */
136    public static Commands commands() {
137        return impl.cmds();
138    }
139
140    /**
141     * Obtains the root logger which contains the collection of all the loggers
142     *
143     * @return the root collection of loggers
144     */
145    public static TridentLogger loggers() {
146        return Trident.instance().logger();
147    }
148
149    /**
150     * Obtains the chat handler
151     *
152     * @return the chat handler
153     */
154    public static ChatFormatter chatFormatter() {
155        return impl.format();
156    }
157
158    /**
159     * Obtains the transaction handler
160     *
161     * @return the transaction handler
162     */
163    public static Transactions transactions() {
164        return impl.trasacts();
165    }
166}