-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # platforms/velocity/src/main/java/us/ajg0702/queue/platforms/velocity/players/VelocityPlayer.java
- Loading branch information
Showing
54 changed files
with
919 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
api/src/main/java/us/ajg0702/queue/api/events/AutoQueueOnKickEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package us.ajg0702.queue.api.events; | ||
|
||
import us.ajg0702.queue.api.players.AdaptedPlayer; | ||
|
||
/** | ||
* Called before AjQueue auto-queues a player for a server. (on player kick) | ||
* Use Case: View/Change the server that the player is auto-queued for. | ||
* If canceled, the player will not be queued to any server. | ||
* If you cancel this event, it is up to you to send a message telling the player why they were not auto-queued. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class AutoQueueOnKickEvent implements Event, Cancellable { | ||
private final AdaptedPlayer player; | ||
private String targetServer; | ||
|
||
private boolean cancelled = false; | ||
|
||
public AutoQueueOnKickEvent(AdaptedPlayer player, String targetServer) { | ||
this.player = player; | ||
this.targetServer = targetServer; | ||
} | ||
|
||
/** | ||
* @return the player that is being re-queued | ||
*/ | ||
public AdaptedPlayer getPlayer() { | ||
return player; | ||
} | ||
|
||
/** | ||
* @return The name of the server AjQueue will queue the player for. | ||
*/ | ||
public String getTargetServer() { | ||
return targetServer; | ||
} | ||
|
||
/** | ||
* Set the name of the server AjQueue will queue the player for. | ||
* @param targetServer The name of the server to queue the player for. | ||
*/ | ||
public void setTargetServer(String targetServer) { | ||
this.targetServer = targetServer; | ||
} | ||
|
||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
public void setCancelled(boolean cancelled) { | ||
this.cancelled = cancelled; | ||
} | ||
} | ||
|
97 changes: 97 additions & 0 deletions
97
api/src/main/java/us/ajg0702/queue/api/events/BuildServersEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package us.ajg0702.queue.api.events; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
import us.ajg0702.queue.api.server.AdaptedServer; | ||
|
||
import java.util.*; | ||
|
||
/** | ||
* Called before AjQueue attempts to re-compile its list of QueueServers | ||
* Use Case: Add/Remove an AdaptedServer from being registered as a QueueServer. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class BuildServersEvent implements Event { | ||
private final Map<String, AdaptedServer> servers = new HashMap<>(); | ||
private final Map<String, List<AdaptedServer>> groups = new HashMap<>(); | ||
|
||
public BuildServersEvent(List<? extends AdaptedServer> servers) { | ||
// Compile a map of server names to servers | ||
for(AdaptedServer server : servers) { | ||
this.servers.put(server.getName(), server); | ||
} | ||
} | ||
|
||
/** | ||
* @see #addServer(AdaptedServer) | ||
* @see #removeServer(AdaptedServer) | ||
* @see #removeServer(String) | ||
* @return an immutable view of the servers that will be registered as QueueServers. | ||
*/ | ||
public List<AdaptedServer> getServers() { | ||
return Collections.unmodifiableList(new ArrayList<>(servers.values())); | ||
} | ||
|
||
/** | ||
* Add a server to be registered as a QueueServer. | ||
* @param server The server to add | ||
* @return The previous AdaptedServer with that name, or null if there was no previous server | ||
*/ | ||
public @Nullable AdaptedServer addServer(AdaptedServer server) { | ||
return servers.put(server.getName(), server); | ||
} | ||
|
||
/** | ||
* Remove a server, preventing it from being registered as a QueueServer. | ||
* @param server The AdaptedServer to remove | ||
* @return true if the server was removed, false if it was not found | ||
*/ | ||
public boolean removeServer(AdaptedServer server) { | ||
return servers.remove(server.getName()) != null; | ||
} | ||
|
||
/** | ||
* Remove a server, preventing it from being registered as a QueueServer. | ||
* @param name The name of the server to remove | ||
* @return true if the server was removed, false if it was not found | ||
*/ | ||
public boolean removeServer(String name) { | ||
return servers.remove(name) != null; | ||
} | ||
|
||
|
||
/** | ||
* @see #addGroup(String, List) | ||
* @see #removeGroup(String) | ||
* @return an immutable list of the sets of servers that will be registered as group QueueServers. | ||
*/ | ||
public List<List<AdaptedServer>> getGroups() { | ||
return Collections.unmodifiableList(new ArrayList<>(groups.values())); | ||
} | ||
|
||
/** | ||
* Used internally | ||
*/ | ||
public Set<Map.Entry<String, List<AdaptedServer>>> groupEntrySet() { | ||
return groups.entrySet(); | ||
} | ||
|
||
/** | ||
* Add a server-group to be registered by the Queue Manager. | ||
* @param name The name of the server-group | ||
* @param servers The servers to add to the group | ||
* @return The previous server list with that name, or null if there was no previous data | ||
*/ | ||
public @Nullable List<AdaptedServer> addGroup(String name, List<AdaptedServer> servers) { | ||
return groups.put(name, servers); | ||
} | ||
|
||
/** | ||
* Remove a server, preventing it from being registered as a QueueServer. | ||
* @param name The name of the server to remove | ||
* @return true if the server was removed, false if it was not found | ||
*/ | ||
public boolean removeGroup(String name) { | ||
return groups.remove(name) != null; | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
api/src/main/java/us/ajg0702/queue/api/events/PreConnectEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package us.ajg0702.queue.api.events; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import us.ajg0702.queue.api.players.QueuePlayer; | ||
import us.ajg0702.queue.api.server.AdaptedServer; | ||
|
||
/** | ||
* Called before AjQueue attempts to connect a player to an AdaptedServer (via Bungee or Velocity) | ||
* You can use setTargetServer to provide a custom AdaptedServer object for the player to connect to. | ||
* If canceled, the player will not be connected to the target server. | ||
* If you cancel this event, it is up to you to send a message telling the player why they were not connected. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class PreConnectEvent implements Event, Cancellable { | ||
private @NotNull AdaptedServer targetServer; | ||
private final @NotNull QueuePlayer queuePlayer; | ||
|
||
private boolean cancelled = false; | ||
|
||
public PreConnectEvent(@NotNull AdaptedServer targetServer, @NotNull QueuePlayer queuePlayer) { | ||
this.targetServer = targetServer; | ||
this.queuePlayer = queuePlayer; | ||
} | ||
|
||
/** | ||
* Set the target server to connect the player to. (Override default behavior with a custom server) | ||
* | ||
* @param targetServer the target server (AdaptedServer) | ||
*/ | ||
public void setTargetServer(@NotNull AdaptedServer targetServer) { | ||
this.targetServer = targetServer; | ||
} | ||
|
||
/** | ||
* @return The target server that the player is trying to connect to | ||
*/ | ||
public @NotNull AdaptedServer getTargetServer() { | ||
return targetServer; | ||
} | ||
|
||
/** | ||
* @return The player that is being connected to the server | ||
*/ | ||
public @NotNull QueuePlayer getPlayer() { | ||
return queuePlayer; | ||
} | ||
|
||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
public void setCancelled(boolean cancelled) { | ||
this.cancelled = cancelled; | ||
} | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
api/src/main/java/us/ajg0702/queue/api/events/PriorityCalculationEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package us.ajg0702.queue.api.events; | ||
|
||
import us.ajg0702.queue.api.players.AdaptedPlayer; | ||
|
||
/** | ||
* Event that is called when priorities are calculated. | ||
* You can provide dynamic priorities for your players based on your own criteria | ||
* instead of just permissions<br> | ||
* <br> | ||
* Just listen to this event, and use the addPriority method to add a priority. | ||
* If it is higher than a player's other priorities, it will be used.<br> | ||
* <br> | ||
* If running ajQueue (not ajQueuePlus), then any number bigger than 0 will count as priority | ||
*/ | ||
public class PriorityCalculationEvent implements Event { | ||
private final AdaptedPlayer player; | ||
private int highestPriority; | ||
|
||
public PriorityCalculationEvent(AdaptedPlayer player, int highestPriority) { | ||
this.player = player; | ||
this.highestPriority = highestPriority; | ||
} | ||
|
||
/** | ||
* Gets the current highest priority | ||
* @return The highest priority number | ||
*/ | ||
public int getHighestPriority() { | ||
return highestPriority; | ||
} | ||
|
||
/** | ||
* Adds a priority. Does nothing if the priority is lower than the player already has | ||
* @param priority the priority to add | ||
*/ | ||
public void addPriority(int priority) { | ||
if(priority < highestPriority) return; // do nothing if this isnt going to change the highest priority | ||
highestPriority = priority; | ||
} | ||
} |
Oops, something went wrong.