make api accessable. Documentation coming soon.

This commit is contained in:
ajgeiss0702
2021-08-21 10:09:17 -07:00
parent 959c2b860e
commit f9c2eed94c
2 changed files with 129 additions and 1 deletions
@@ -0,0 +1,112 @@
package us.ajg0702.queue.common;
import us.ajg0702.queue.api.AliasManager;
import us.ajg0702.queue.api.EventHandler;
import us.ajg0702.queue.api.PlatformMethods;
import us.ajg0702.queue.api.QueueManager;
import us.ajg0702.queue.api.premium.Logic;
import us.ajg0702.queue.api.premium.LogicGetter;
import us.ajg0702.queue.api.util.QueueLogger;
import us.ajg0702.utils.common.Config;
import us.ajg0702.utils.common.Messages;
public abstract class AjQueueAPI {
public static AjQueueAPI INSTANCE;
/**
* Gets the instance of the ajQueue API
* @return the ajQueue API
*/
@SuppressWarnings("unused")
public static AjQueueAPI getInstance() {
return INSTANCE;
}
/**
* Gets the time that ajQueue will wait between sending players. In seconds
* @return The time, in seconds, ajQueue will wait between attempting to send players
*/
public abstract double getTimeBetweenPlayers();
/**
* Updates the time between players. Takes it from the config.
*/
public abstract void setTimeBetweenPlayers();
/**
* Gets the ajQueue config
* @return the ajQueue config
*/
public abstract Config getConfig();
/**
* Gets the ajQueue messages manager
* @return the messages manager
*/
public abstract Messages getMessages();
/**
* Gets the alias manager. Used to get aliases of servers set in ajqueue's config.
* Note that the alias manager on the free version will just return the server's name
* @return The alias manager
*/
public abstract AliasManager getAliasManager();
/**
* Gets the priority logic. Note that the priority logic for the free version does nothing.
* @return The priority logic
*/
public abstract Logic getLogic();
/**
* Checks if the plugin is the premium version or not.
* @return True if ajQueuePlus, false if ajQueue
*/
public abstract boolean isPremium();
/**
* Gets the PlatformMethods for the platform (e.g. bungee, velocity)
* The methods in this class do things that the code for each is different on the platform.
* @return the PlatformMethods
*/
public abstract PlatformMethods getPlatformMethods();
/**
* Gets the ajQueue logger. If you are using this, please add your own prefix to it.
* @return The ajQueue logger
*/
public abstract QueueLogger getLogger();
/**
* Gets the repeating task manager
* @return The TaskManager
*/
public abstract TaskManager getTaskManager();
/**
* Gets the event handler.
*
* This class will probably be replaced in the future with an actual event system
* @return the EventHandler
*/
public abstract EventHandler getEventHandler();
/**
* Gets the queue manager. Most things you do interacting with queues will be through this.
* @return the QueueManager
*/
public abstract QueueManager getQueueManager();
/**
* Gets the logic getter.
* @return The logic getter
*/
public abstract LogicGetter getLogicGetter();
/**
* Tells ajQueue to shut down.
*/
public abstract void shutdown();
}
@@ -13,7 +13,7 @@ import us.ajg0702.utils.common.Messages;
import java.io.File; import java.io.File;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
public class QueueMain { public class QueueMain extends AjQueueAPI {
private static QueueMain instance; private static QueueMain instance;
public static QueueMain getInstance() { public static QueueMain getInstance() {
@@ -21,67 +21,81 @@ public class QueueMain {
} }
private double timeBetweenPlayers; private double timeBetweenPlayers;
@Override
public double getTimeBetweenPlayers() { public double getTimeBetweenPlayers() {
return timeBetweenPlayers; return timeBetweenPlayers;
} }
@Override
public void setTimeBetweenPlayers() { public void setTimeBetweenPlayers() {
this.timeBetweenPlayers = config.getDouble("wait-time"); this.timeBetweenPlayers = config.getDouble("wait-time");
} }
private Config config; private Config config;
@Override
public Config getConfig() { public Config getConfig() {
return config; return config;
} }
private Messages messages; private Messages messages;
@Override
public Messages getMessages() { public Messages getMessages() {
return messages; return messages;
} }
private AliasManager aliasManager; private AliasManager aliasManager;
@Override
public AliasManager getAliasManager() { public AliasManager getAliasManager() {
return aliasManager; return aliasManager;
} }
private Logic logic; private Logic logic;
@Override
public Logic getLogic() { public Logic getLogic() {
return logic; return logic;
} }
@Override
public boolean isPremium() { public boolean isPremium() {
return getLogic().isPremium(); return getLogic().isPremium();
} }
private final PlatformMethods platformMethods; private final PlatformMethods platformMethods;
@Override
public PlatformMethods getPlatformMethods() { public PlatformMethods getPlatformMethods() {
return platformMethods; return platformMethods;
} }
private final QueueLogger logger; private final QueueLogger logger;
@Override
public QueueLogger getLogger() { public QueueLogger getLogger() {
return logger; return logger;
} }
private final TaskManager taskManager = new TaskManager(this); private final TaskManager taskManager = new TaskManager(this);
@Override
public TaskManager getTaskManager() { public TaskManager getTaskManager() {
return taskManager; return taskManager;
} }
private final EventHandler eventHandler = new EventHandlerImpl(this); private final EventHandler eventHandler = new EventHandlerImpl(this);
@Override
public EventHandler getEventHandler() { public EventHandler getEventHandler() {
return eventHandler; return eventHandler;
} }
private QueueManager queueManager; private QueueManager queueManager;
@Override
public QueueManager getQueueManager() { public QueueManager getQueueManager() {
return queueManager; return queueManager;
} }
private final LogicGetter logicGetter; private final LogicGetter logicGetter;
@Override
public LogicGetter getLogicGetter() { public LogicGetter getLogicGetter() {
return logicGetter; return logicGetter;
} }
@Override
public void shutdown() { public void shutdown() {
taskManager.shutdown(); taskManager.shutdown();
} }
@@ -103,6 +117,8 @@ public class QueueMain {
} }
instance = this; instance = this;
AjQueueAPI.INSTANCE = this;
this.logger = logger; this.logger = logger;
this.platformMethods = platformMethods; this.platformMethods = platformMethods;