lot of progress
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package us.ajg0702.queue.api;
|
||||
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
@@ -23,4 +24,11 @@ public interface PlatformMethods {
|
||||
*/
|
||||
void sendPluginMessage(AdaptedPlayer player, String channel, String... data);
|
||||
|
||||
/**
|
||||
* Converts a command sender to an AdaptedPlayer
|
||||
* @param sender the commandsender
|
||||
* @return the AdaptedPlayer
|
||||
*/
|
||||
AdaptedPlayer senderToPlayer(ICommandSender sender);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package us.ajg0702.queue.api.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IBaseCommand {
|
||||
|
||||
String getName();
|
||||
|
||||
ImmutableList<String> getAliases();
|
||||
|
||||
ImmutableList<ISubCommand> getSubCommands();
|
||||
|
||||
String getPermission();
|
||||
|
||||
Messages getMessages();
|
||||
|
||||
void addSubCommand(ISubCommand subCommand);
|
||||
|
||||
void execute(ICommandSender ssender, String[] args);
|
||||
|
||||
List<String> autoComplete(ICommandSender sender, String[] args);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package us.ajg0702.queue.api.commands;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import us.ajg0702.queue.api.util.Handle;
|
||||
|
||||
public interface ICommandSender extends Handle, Audience {
|
||||
boolean hasPermission(String permission);
|
||||
boolean isPlayer();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package us.ajg0702.queue.api.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISubCommand extends IBaseCommand {
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package us.ajg0702.queue.api.players;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.api.util.Handle;
|
||||
@@ -9,7 +10,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* Represents a cross-platform player
|
||||
*/
|
||||
public interface AdaptedPlayer extends Handle {
|
||||
public interface AdaptedPlayer extends Handle, Audience {
|
||||
|
||||
/**
|
||||
* Check if the plauer is currently connected
|
||||
|
||||
+4
-3
@@ -1,12 +1,13 @@
|
||||
package us.ajg0702.queue.api;
|
||||
package us.ajg0702.queue.api.server;
|
||||
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ServerBuilder {
|
||||
List<QueueServer> getServers();
|
||||
List<QueueServer> buildServers();
|
||||
|
||||
AdaptedServer getServer(String name);
|
||||
|
||||
QueueServer buildGroup(String name, List<AdaptedServer> servers);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package us.ajg0702.queue.commands;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import us.ajg0702.queue.api.commands.IBaseCommand;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BaseCommand implements IBaseCommand {
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ISubCommand> getSubCommands() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubCommand(ISubCommand subCommand) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public boolean checkPermission(ICommandSender sender) {
|
||||
if(getPermission() != null && !sender.hasPermission(getPermission())) {
|
||||
sender.sendMessage(getMessages().getComponent("noperm"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package us.ajg0702.queue.commands;
|
||||
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
|
||||
public class SubCommand extends BaseCommand implements ISubCommand {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package us.ajg0702.queue.commands.commands.queue;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class QueueCommand extends BaseCommand {
|
||||
|
||||
private final QueueMain main;
|
||||
|
||||
public QueueCommand(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "queue";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of("move", "server", "joinqueue", "joinq");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ISubCommand> getSubCommands() {
|
||||
return ImmutableList.<ISubCommand>builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubCommand(ISubCommand subCommand) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
if(!sender.isPlayer()) {
|
||||
sender.sendMessage(getMessages().getComponent("errors.player-only"));
|
||||
return;
|
||||
}
|
||||
AdaptedPlayer player = main.getPlatformMethods().senderToPlayer(sender);
|
||||
|
||||
if(args.length > 0) {
|
||||
if(main.getConfig().getBoolean("require-permission") && !player.hasPermission("ajqueue.queue."+args[0])) {
|
||||
sender.sendMessage(getMessages().getComponent("noperm"));
|
||||
return;
|
||||
}
|
||||
main.getQueueManager().addToQueue(player, args[0]);
|
||||
} else {
|
||||
sender.sendMessage(getMessages().getComponent("commands.joinqueue.usage"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
if(!main.getConfig().getBoolean("tab-complete-queues")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if(args.length == 1) {
|
||||
return main.getQueueManager().getServerNames();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,20 @@
|
||||
package us.ajg0702.queue.common;
|
||||
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import us.ajg0702.queue.api.*;
|
||||
import us.ajg0702.queue.api.AliasManager;
|
||||
import us.ajg0702.queue.api.Logic;
|
||||
import us.ajg0702.queue.api.PlatformMethods;
|
||||
import us.ajg0702.queue.api.QueueManager;
|
||||
import us.ajg0702.queue.api.server.ServerBuilder;
|
||||
import us.ajg0702.queue.logic.LogicGetter;
|
||||
import us.ajg0702.utils.common.Config;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class QueueMain {
|
||||
@@ -41,20 +49,36 @@ public class QueueMain {
|
||||
return getLogic().isPremium();
|
||||
}
|
||||
|
||||
private PlatformMethods platformMethods;
|
||||
private final PlatformMethods platformMethods;
|
||||
public PlatformMethods getPlatformMethods() {
|
||||
return platformMethods;
|
||||
}
|
||||
|
||||
private Logger logger;
|
||||
private final Logger logger;
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
private List<CompletableFuture<ServerBuilder>> serverCompletableFutures = new ArrayList<>();
|
||||
private ServerBuilder serverBuilder;
|
||||
public ServerBuilder getServerBuilder() {
|
||||
return serverBuilder;
|
||||
}
|
||||
public CompletableFuture<ServerBuilder> getFutureServerBuilder() {
|
||||
CompletableFuture<ServerBuilder> completableFuture = new CompletableFuture<>();
|
||||
if(serverBuilder != null) {
|
||||
completableFuture.complete(serverBuilder);
|
||||
}
|
||||
serverCompletableFutures.add(completableFuture);
|
||||
return completableFuture;
|
||||
}
|
||||
public void setServerBuilder(ServerBuilder serverBuilder) {
|
||||
if(this.serverBuilder != null) throw new IllegalStateException("SeverBuilder already set");
|
||||
this.serverBuilder = serverBuilder;
|
||||
for(CompletableFuture<ServerBuilder> future : serverCompletableFutures) {
|
||||
future.complete(serverBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
private QueueManager queueManager;
|
||||
public QueueManager getQueueManager() {
|
||||
@@ -62,10 +86,15 @@ public class QueueMain {
|
||||
}
|
||||
|
||||
|
||||
public QueueMain(Logger logger, ServerBuilder serverBuilder, PlatformMethods platformMethods, File dataFolder) {
|
||||
private File dataFolder;
|
||||
|
||||
|
||||
public QueueMain(Logger logger, PlatformMethods platformMethods, File dataFolder) {
|
||||
this.logger = logger;
|
||||
this.serverBuilder = serverBuilder;
|
||||
this.platformMethods = platformMethods;
|
||||
this.dataFolder = dataFolder;
|
||||
|
||||
constructMessages();
|
||||
|
||||
try {
|
||||
config = new Config(dataFolder, logger);
|
||||
@@ -79,7 +108,14 @@ public class QueueMain {
|
||||
|
||||
queueManager = new QueueManagerImpl(this);
|
||||
|
||||
logic = new LogicGetter().constructLogic();
|
||||
aliasManager = new LogicGetter().constructAliasManager(config);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void constructMessages() {
|
||||
LinkedHashMap<String, String> d = new LinkedHashMap<>();
|
||||
|
||||
d.put("status.offline.base", "&c{SERVER} is {STATUS}. &7You are in position &f{POS}&7 of &f{LEN}&7.");
|
||||
|
||||
@@ -6,13 +6,14 @@ import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServerInfo;
|
||||
import us.ajg0702.queue.api.server.ServerBuilder;
|
||||
import us.ajg0702.queue.common.players.QueuePlayerImpl;
|
||||
import us.ajg0702.utils.bungee.BungeeUtils;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
import us.ajg0702.utils.common.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class QueueManagerImpl implements QueueManager {
|
||||
|
||||
@@ -24,6 +25,16 @@ public class QueueManagerImpl implements QueueManager {
|
||||
public QueueManagerImpl(QueueMain main) {
|
||||
this.main = main;
|
||||
this.msgs = main.getMessages();
|
||||
|
||||
CompletableFuture<ServerBuilder> serverBuilderFuture = main.getFutureServerBuilder();
|
||||
serverBuilderFuture.thenRunAsync(() -> {
|
||||
try {
|
||||
servers = serverBuilderFuture.get().buildServers();
|
||||
// TODO: groups
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,12 +118,14 @@ public class QueueManagerImpl implements QueueManager {
|
||||
"SERVER:"+server.getAlias()));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(msgs.getComponent("status.now-in-queue",
|
||||
player.sendMessage(
|
||||
msgs.getComponent("status.now-in-queue",
|
||||
"POS:"+pos,
|
||||
"LEN:"+len,
|
||||
"SERVER:"+server.getAlias(),
|
||||
"SERVERNAME:"+server.getName()
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
main.getPlatformMethods().sendJoinQueueChannelMessages(server, queuePlayer);
|
||||
@@ -167,7 +180,7 @@ public class QueueManagerImpl implements QueueManager {
|
||||
|
||||
servers.clear();
|
||||
|
||||
servers.addAll(main.getServerBuilder().getServers());
|
||||
servers.addAll(main.getServerBuilder().buildServers());
|
||||
|
||||
List<String> groupsraw = main.getConfig().getStringList("server-groups");
|
||||
for(String groupraw : groupsraw) {
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
# Dont touch this number please
|
||||
config-version: 21
|
||||
|
||||
# The time the server will wait between sending people in the queue
|
||||
# Default: 5
|
||||
wait-time: 5
|
||||
|
||||
# The time that a server has to be offline to be marked as offline instead of restarting
|
||||
# Default: 120
|
||||
offline-time: 120
|
||||
|
||||
# The time the server will wait between sending players update messages on what position they are in the queue.
|
||||
# Default: 10
|
||||
message-time: 10
|
||||
|
||||
# If a player is in a server, you can have the plugin make them automatically join a queue for another server
|
||||
# Example with the default values: Player joins survivalqueue server, they will auto-join the queue for survival
|
||||
queue-servers:
|
||||
- 'survivalqueue:survival'
|
||||
|
||||
# Should the plugin send an actionbar to the player?
|
||||
# The actionbar contains some info such as which server they are queued for, what position they are in, estimated time remaining, etc.
|
||||
send-actionbar: true
|
||||
|
||||
# What kick reasons should cause the player to be removed from the queue?
|
||||
# For example, if one of the below kick reasons is 'banned' and the player gets kicked when trying to connect to
|
||||
# a server in a queue with a message saying "You are banned from this server!" then it will kick them from the queue too.
|
||||
kick-reasons:
|
||||
- 'banned'
|
||||
- 'blacklisted'
|
||||
|
||||
|
||||
# Should we remove a player from the queue if they move servers?
|
||||
# If they join another queue, they will be removed from the previous one no matter what
|
||||
# This is more meant for if you have multiple lobbies if you want to let the player switch
|
||||
# between them without losing their queue position
|
||||
# Default: false
|
||||
remove-player-on-server-switch: false
|
||||
|
||||
|
||||
# Should we wait until the server is done loading to load the servers?
|
||||
# Enable this if you have a plugin that adds servers to the server list during startup.
|
||||
# Default: false
|
||||
wait-to-load-servers: false
|
||||
|
||||
# How long should we wait after the server finishes loading to load the server list?
|
||||
# Only works if the above is enabled.
|
||||
# This is in miliseconds so 1000 = 1 second
|
||||
# Default: 500
|
||||
wait-to-load-servers-delay: 500
|
||||
|
||||
|
||||
# How often (in seconds) we should check for new servers to add queues for.
|
||||
# If you dynamicly add servers, set this to something other than 0.
|
||||
# To disable, set to 0
|
||||
reload-servers-interval: 0
|
||||
|
||||
|
||||
# Should we require permissions for players to be able to join queues?
|
||||
# If enabled, players will be required to have the permission ajqueue.queue.<server>
|
||||
# Default: false
|
||||
require-permission: false
|
||||
|
||||
|
||||
# Should we let players join more than one queue?
|
||||
# If enabled, players will be able to be in multiple queues at once.
|
||||
# Default: true
|
||||
allow-multiple-queues: true
|
||||
|
||||
# If the player is queued for multiple servers, which server should we pick to use in things like placeholders and actionbars
|
||||
# Options are first and last
|
||||
# Default: last
|
||||
multi-server-queue-pick: last
|
||||
|
||||
|
||||
# THIS FEATURE IS ONLY AVAILABLE ON ajQueuePlus (https://www.spigotmc.org/resources/ajqueueplus.79123/)
|
||||
# This will show players a different name than the actual bungeecord server name
|
||||
# for example, instead of showing players "event-a", this option can make it appear as "Event A"
|
||||
# With this example, you would use this: - "event-a:Event A"
|
||||
# Note that currently players still have to use the normal names in queue commands and leave commands
|
||||
# Format: "realname:Alias"
|
||||
server-aliases:
|
||||
- "event-a:Event A"
|
||||
|
||||
|
||||
# How long should we wait after a server is online before sending players?
|
||||
# The server will still show up as offline or restarting until this amount of time after its up
|
||||
# Meant to let your server 'cool down' after lag from starting up
|
||||
# In seconds
|
||||
# Default: 1
|
||||
wait-after-online: 1
|
||||
|
||||
|
||||
# This is for helping with finding issues with the server pinged
|
||||
# This will spam the console when enabled
|
||||
# When this enabled, if servers are offline then it will spam errors. You can ignore them.
|
||||
# Default: false
|
||||
pinger-debug: false
|
||||
|
||||
|
||||
# When a queue is paused, should we prevent players from joining it?
|
||||
# Default: false
|
||||
prevent-joining-paused: false
|
||||
|
||||
# When a server goes back online, should we send all players in the queue instantly?
|
||||
# Default: false
|
||||
send-all-when-back-online: false
|
||||
|
||||
# Require a permission for players to be able to join a queue from a server
|
||||
# If enabled, players will need the permission ajqueue.joinfrom.<server> to join queues.
|
||||
# Replace <server> with the name of the server
|
||||
# Default: false
|
||||
joinfrom-server-permission: false
|
||||
|
||||
# Server groups are a group of servers that you can queue for. It will send you to the server that is the least full.
|
||||
# If all servers in the group are full, it will act the same as it would when a single server is full.
|
||||
# Same if all servers are offline. It will only send players to servers that are online.
|
||||
# Format: "groupname:server1,server2,etc"
|
||||
server-groups:
|
||||
- "lobbys:lobby-1,lobby-2,lobby-3"
|
||||
|
||||
|
||||
# Should we allow tab-completing in the /queue command?
|
||||
# Default: true
|
||||
tab-complete-queues: true
|
||||
|
||||
# Should we have no wait time for these servers?
|
||||
# If the server is joinable, the plugin will attempt to send players who join these queues as soon as they join.
|
||||
# If the server is not immidiatly joinable, they will have to wait for the normal wait-time
|
||||
# This also works with group
|
||||
# NOTE: Server names are caps sensitive
|
||||
send-instantly:
|
||||
- "lobbys"
|
||||
|
||||
# Should we log to the bungeecord console when a player fails to get sent to a server from the queue?
|
||||
# Enable this if you are having an issue with one player stopping the queue
|
||||
# Default: false
|
||||
send-fail-debug: false
|
||||
|
||||
# After how many (unsuccessfull) attempts of sending the player should we remove them from the queue?
|
||||
# Set to -1 to disable
|
||||
# Default: 10
|
||||
max-tries: 10
|
||||
|
||||
# Should we enable the ajqueue.bypasspaused permission?
|
||||
# If enabled, anyone with the permission ajqueue.bypasspaused will be able to join paused servers
|
||||
# Default: false
|
||||
enable-bypasspaused-permission: false
|
||||
|
||||
# Should we check to make sure that people dont get sent quicker than wait-time?
|
||||
# Default: true
|
||||
check-last-player-sent-time: true
|
||||
|
||||
# Should we send debug info to the console when priority queue is used?
|
||||
# This will print several lines to the console when a player joins a queue,
|
||||
# so you should probably only use this for debugging purposes
|
||||
# Default: false
|
||||
priority-queue-debug: false
|
||||
|
||||
# When a player is kicked from a server, should we automatically add that player to the queue?
|
||||
# You will still need to use another plugin to make sure the player doesnt get kicked from bungee completly.
|
||||
# Default: false
|
||||
auto-add-to-queue-on-kick: false
|
||||
# The delay for the above option.
|
||||
# In seconds, decimals supported.
|
||||
auto-add-to-queue-on-kick-delay: 1
|
||||
|
||||
# With what kick reasons should we auto-add the player to the queue
|
||||
# This wont work if auto-add-to-queue-on-kick is disabled.
|
||||
# If you set it to [], then all kick messages will cause the player to be added to the queue
|
||||
# This works on contains, so you dont have to include the whole kick message, just a few words.
|
||||
auto-add-kick-reasons:
|
||||
- "restarting"
|
||||
- "closed"
|
||||
@@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
id("com.github.johnrengelman.shadow")
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "us.ajg0702.queue"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.ajg0702.us") }
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("net.kyori:adventure-api:4.8.1")
|
||||
compileOnly("com.google.guava:guava:30.1.1-jre")
|
||||
compileOnly("org.spongepowered:configurate-yaml:4.0.0")
|
||||
|
||||
implementation("us.ajg0702:ajUtils:1.1.6")
|
||||
|
||||
//implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT")
|
||||
|
||||
implementation(project(":platforms:velocity"))
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
relocate("us.ajg0702.utils", "us.ajg0702.queue.libs.utils")
|
||||
relocate("org.bstats", "us.ajg0702.queue.libs.bstats")
|
||||
//relocate("net.kyori", "us.ajg0702.queue.libs.kyori")
|
||||
relocate("io.leangen.geantyref", "us.ajg0702.queue.libs.geantyref")
|
||||
relocate("org.spongepowered", "us.ajg0702.queue.libs.sponge")
|
||||
relocate("org.yaml", "us.ajg0702.queue.libs.yaml")
|
||||
archiveFileName.set("${baseName}-${version}.${extension}")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
artifact(tasks["jar"])
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
val mavenUrl = "https://repo.ajg0702.us/releases"
|
||||
|
||||
if(!System.getenv("REPO_TOKEN").isNullOrEmpty()) {
|
||||
maven {
|
||||
url = uri(mavenUrl)
|
||||
name = "ajRepo"
|
||||
|
||||
credentials {
|
||||
username = "plugins"
|
||||
password = System.getenv("REPO_TOKEN")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ dependencies {
|
||||
|
||||
compileOnly("com.velocitypowered:velocity-api:3.0.0")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.0.0")
|
||||
compileOnly("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT")
|
||||
|
||||
implementation(project(":common"))
|
||||
implementation(project(":api"))
|
||||
|
||||
+8
@@ -1,10 +1,13 @@
|
||||
package us.ajg0702.queue.platforms.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import us.ajg0702.queue.api.PlatformMethods;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.platforms.velocity.players.VelocityPlayer;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -29,4 +32,9 @@ public class PlatformMethodImpl implements PlatformMethods {
|
||||
public void sendPluginMessage(AdaptedPlayer player, String channel, String... data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdaptedPlayer senderToPlayer(ICommandSender sender) {
|
||||
return new VelocityPlayer((Player) sender.getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package us.ajg0702.queue.platforms.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import us.ajg0702.queue.api.ServerBuilder;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerBuilderImpl implements ServerBuilder {
|
||||
|
||||
private final ProxyServer proxyServer;
|
||||
public ServerBuilderImpl(ProxyServer proxyServer) {
|
||||
this.proxyServer = proxyServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QueueServer> getServers() {
|
||||
List<QueueServer> result = new ArrayList<>();
|
||||
Collection<RegisteredServer> servers = proxyServer.getAllServers();
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueueServer buildGroup(String name, List<AdaptedServer> servers) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+24
-2
@@ -1,14 +1,22 @@
|
||||
package us.ajg0702.queue.platforms.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.commands.commands.queue.QueueCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.queue.platforms.velocity.commands.VelocityCommand;
|
||||
import us.ajg0702.queue.platforms.velocity.server.ServerBuilderImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Plugin(
|
||||
@@ -29,7 +37,7 @@ public class VelocityQueue {
|
||||
File dataFolder;
|
||||
|
||||
@Inject
|
||||
public VelocityQueue(ProxyServer proxyServer, Logger logger, Path dataFolder) {
|
||||
public VelocityQueue(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataFolder) {
|
||||
this.proxyServer = proxyServer;
|
||||
this.logger = logger;
|
||||
|
||||
@@ -40,9 +48,23 @@ public class VelocityQueue {
|
||||
public void onProxyInit(ProxyInitializeEvent e) {
|
||||
main = new QueueMain(
|
||||
logger,
|
||||
new ServerBuilderImpl(proxyServer),
|
||||
new PlatformMethodImpl(proxyServer, logger),
|
||||
dataFolder
|
||||
);
|
||||
main.setServerBuilder(new ServerBuilderImpl(main, proxyServer));
|
||||
|
||||
CommandManager commandManager = proxyServer.getCommandManager();
|
||||
|
||||
|
||||
List<BaseCommand> commands = Arrays.asList(new QueueCommand(main));
|
||||
|
||||
for(BaseCommand command : commands) {
|
||||
commandManager.register(
|
||||
commandManager.metaBuilder(command.getName())
|
||||
.aliases(command.getAliases().toArray(new String[]{}))
|
||||
.build(),
|
||||
new VelocityCommand(main, command)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package us.ajg0702.queue.platforms.velocity.commands;
|
||||
|
||||
import com.velocitypowered.api.command.RawCommand;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityCommand implements RawCommand {
|
||||
|
||||
QueueMain main;
|
||||
BaseCommand command;
|
||||
|
||||
public VelocityCommand(QueueMain main, BaseCommand command) {
|
||||
this.main = main;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
command.execute(new VelocitySender(invocation.source()), invocation.arguments().split(" "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(final Invocation invocation) {
|
||||
return command.autoComplete(new VelocitySender(invocation.source()), invocation.arguments().split(" "));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Invocation invocation) {
|
||||
return command.checkPermission(new VelocitySender(invocation.source()));
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package us.ajg0702.queue.platforms.velocity.commands;
|
||||
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
|
||||
public class VelocitySender implements ICommandSender {
|
||||
|
||||
CommandSource handle;
|
||||
|
||||
public VelocitySender(CommandSource handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return handle.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return !(handle instanceof ConsoleCommandSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSource getHandle() {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -3,6 +3,7 @@ package us.ajg0702.queue.platforms.velocity.players;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
@@ -10,7 +11,7 @@ import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VelocityPlayer implements AdaptedPlayer {
|
||||
public class VelocityPlayer implements AdaptedPlayer, Audience {
|
||||
|
||||
Player handle;
|
||||
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package us.ajg0702.queue.platforms.velocity.server;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import us.ajg0702.queue.api.server.ServerBuilder;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.queue.common.queues.QueueServerImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ServerBuilderImpl implements ServerBuilder {
|
||||
|
||||
private final ProxyServer proxyServer;
|
||||
private final QueueMain main;
|
||||
public ServerBuilderImpl(QueueMain main, ProxyServer proxyServer) {
|
||||
this.proxyServer = proxyServer;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QueueServer> buildServers() {
|
||||
List<QueueServer> result = new ArrayList<>();
|
||||
Collection<RegisteredServer> servers = proxyServer.getAllServers();
|
||||
|
||||
for(RegisteredServer server : servers) {
|
||||
AdaptedServer adaptedServer = new VelocityServer(server);
|
||||
result.add(new QueueServerImpl(adaptedServer.getName(), main, adaptedServer));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdaptedServer getServer(String name) {
|
||||
Optional<RegisteredServer> serverOptional = proxyServer.getServer(name);
|
||||
if(serverOptional.isEmpty()) return null;
|
||||
return new VelocityServer(serverOptional.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueueServer buildGroup(String name, List<AdaptedServer> servers) {
|
||||
return new QueueServerImpl(name, main, servers);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package us.ajg0702.queue.platforms.velocity.server;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServerInfo;
|
||||
import us.ajg0702.queue.api.server.AdaptedServerPing;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class VelocityServer implements AdaptedServer {
|
||||
|
||||
private final RegisteredServer handle;
|
||||
public VelocityServer(RegisteredServer handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdaptedServerInfo getServerInfo() {
|
||||
return new VelocityServerInfo(handle.getServerInfo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return handle.getServerInfo().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<AdaptedServerPing> ping() {
|
||||
CompletableFuture<AdaptedServerPing> future = new CompletableFuture<>();
|
||||
CompletableFuture<ServerPing> serverPing = handle.ping();
|
||||
serverPing.thenRunAsync(() -> {
|
||||
AdaptedServerPing aPing = null;
|
||||
try {
|
||||
aPing = new VelocityServerPing(serverPing.get());
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
future.complete(aPing);
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccess(AdaptedPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegisteredServer getHandle() {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package us.ajg0702.queue.platforms.velocity.server;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||
import us.ajg0702.queue.api.server.AdaptedServerInfo;
|
||||
|
||||
public class VelocityServerInfo implements AdaptedServerInfo {
|
||||
|
||||
private final ServerInfo handle;
|
||||
|
||||
public VelocityServerInfo(ServerInfo handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return handle.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerInfo getHandle() {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package us.ajg0702.queue.platforms.velocity.server;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import us.ajg0702.queue.api.server.AdaptedServerPing;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class VelocityServerPing implements AdaptedServerPing {
|
||||
|
||||
private final ServerPing handle;
|
||||
public VelocityServerPing(ServerPing handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDescriptionComponent() {
|
||||
return handle.getDescriptionComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlainDescription() {
|
||||
return PlainTextComponentSerializer.plainText().serialize(handle.getDescriptionComponent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerCount() {
|
||||
Optional<ServerPing.Players> players = handle.getPlayers();
|
||||
if(players.isEmpty()) return 0;
|
||||
return players.get().getOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers() {
|
||||
Optional<ServerPing.Players> players = handle.getPlayers();
|
||||
if(players.isEmpty()) return 0;
|
||||
return players.get().getMax();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerPing getHandle() {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,7 @@ rootProject.name = "ajQueue"
|
||||
|
||||
include(":api")
|
||||
include(":common")
|
||||
|
||||
include(":platforms:velocity")
|
||||
|
||||
include(":free")
|
||||
Reference in New Issue
Block a user