This commit is contained in:
ajgeiss0702
2021-07-05 20:32:23 -07:00
parent e10251048b
commit 726bb42bc8
13 changed files with 527 additions and 12 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ repositories {
}
dependencies {
compileOnly("net.kyori:adventure-api:4.8.1")
implementation("net.kyori:adventure-api:4.8.1")
compileOnly("com.google.guava:guava:30.1.1-jre")
}
@@ -2,6 +2,7 @@ package us.ajg0702.queue.api;
import us.ajg0702.queue.api.players.AdaptedPlayer;
import us.ajg0702.queue.api.players.QueuePlayer;
import us.ajg0702.queue.api.queues.QueueServer;
import java.util.List;
@@ -18,5 +19,5 @@ public interface Logic {
* @param server The server/group name that is being queued for
* @param player The player that is being queued
*/
void priorityLogic(List<QueuePlayer> list, String server, AdaptedPlayer player);
QueuePlayer priorityLogic(QueueServer server, AdaptedPlayer player);
}
@@ -2,6 +2,7 @@ package us.ajg0702.queue.api;
import com.google.common.collect.ImmutableList;
import us.ajg0702.queue.api.players.AdaptedPlayer;
import us.ajg0702.queue.api.players.QueuePlayer;
import us.ajg0702.queue.api.queues.QueueServer;
public interface QueueManager {
@@ -56,4 +57,57 @@ public interface QueueManager {
* Also creates/edits server groups
*/
void reloadServers();
/**
* Sends queue status action bars to players in queues
*/
void sendActionBars();
/**
* Tell the spigot sides to call the queue scoreboard event
*/
void sendQueueEvents();
/**
* Sends chat queue status messages to players in queues
*/
void sendMessages();
/**
* Send a chat queue status message to a specific player in a specific queue
* @param player The player that is in the queue
*/
void sendMessage(QueuePlayer player);
/**
* Find a server by its name
* @param name The name to look for
* @return The QueueServer if found, null if not
*/
QueueServer findServer(String name);
/**
* Attempts to send the first player in all queues to the server they are queued for
*/
void sendPlayers();
/**
* Attempts to send the first player in a specific queue
* @param server The queue that we should try to send.
*/
void sendPlayers(QueueServer server);
/**
* Finds QueuePlayers that represent this player
* @param p The player to look up
* @return A list of QueuePlayers that represent this player
*/
ImmutableList<QueuePlayer> findPlayerInQueues(AdaptedPlayer p);
/**
* Gets all of the queues the player is currently queued for
* @param p The player
* @return A list of QueueServers that this player is queued for
*/
ImmutableList<QueueServer> getPlayerQueues(AdaptedPlayer p);
}
@@ -3,11 +3,19 @@ package us.ajg0702.queue.api.players;
import net.kyori.adventure.text.Component;
import us.ajg0702.queue.api.util.Handle;
import java.util.UUID;
/**
* Represents a cross-platform player
*/
public interface AdaptedPlayer extends Handle {
/**
* Check if the plauer is currently connected
* @return True if connected, false if not
*/
boolean isConnected();
/**
* Send a player a message from a Component
* @param message The message to send
@@ -20,4 +28,23 @@ public interface AdaptedPlayer extends Handle {
* @param message The message to send
*/
void sendMessage(String message);
/**
* Checks if the player has a certain permission
* @param permission The permission to check
* @return True if they have the permission, false if not
*/
boolean hasPermission(String permission);
/**
* Gets the name of the server the player is currently on
* @return The name of the server
*/
String getServerName();
/**
* Gets the player's unique id (UUID)
* @return The player's uuid
*/
UUID getUniqueId();
}
@@ -1,19 +1,53 @@
package us.ajg0702.queue.api.players;
import us.ajg0702.queue.api.queues.QueueServer;
import javax.annotation.Nullable;
import java.util.UUID;
public interface QueuePlayer {
/**
* Returns the player's UUID
* @return the player's UUID
*/
UUID getUniqueId();
/**
* Gets the server or group this player is queued for
* @return The QueueServer this player is queued for
*/
QueueServer getQueueServer();
/**
* Gets the player's position in the queue
* @return The player's position. 1 being 1st, 2 being 2nd, etc
*/
int getPosition();
/**
* Get the player this represents.
* Can be null because the player could not be online
* @return The player if they are online, null otherwise
*/
@Nullable AdaptedPlayer getPlayer();
/**
* Sets the player that this represents.
* Will throw IllegalArgumentException if the player's uuid does not match the original.
* @param player The player to add
*/
void setPlayer(AdaptedPlayer player);
/**
* Gets the highest priority level the player has.
* In free ajQueue, no priority is 0 and priority is 1
* @return The priority level of this player for this server
*/
int getPriority();
/**
* Gets if this player has priority
*/
boolean hasPriority();
}
@@ -117,12 +117,52 @@ public interface QueueServer {
void removePlayer(QueuePlayer player);
/**
* Adds a player to a queue
* Removes a player from the queue
* @param player The player to remove
*/
void removePlayer(AdaptedPlayer player);
/**
* Adds a player to the end of the queue
* NOTE: It is reccomended to use QueueManager#addToQueue
* @param player The QueuePlayer that is being added
* @param player The QueuePlayer t add
*/
void addPlayer(QueuePlayer player);
/**
* Adds a player to the specified position in the queue
* NOTE: It is reccomended to use QueueManager#addToQueue
* @param player The QueuePlayer to add
* @param position The position to add them
*/
void addPlayer(QueuePlayer player, int position);
/**
* Sends the first player in the queue to the server
*/
void sendPlayer();
/**
* Gets the name of the server/group
* @return The name of the server/group
*/
String getName();
/**
* If the player can access the server. (Bungeecord's restricted servers)
* If on a platform that doesnt have restricted servers, this will always return true.
* @param ply The player
* @return True if the player can join based on bungeecord's restricted servers system
*/
boolean canAccess(AdaptedPlayer ply);
/**
* The alias of this server. For displaying.
* @return The alias of this server
*/
String getAlias();