clean some stuff up
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package us.ajg0702.queue.api;
|
package us.ajg0702.queue.api;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface AliasManager {
|
public interface AliasManager {
|
||||||
/**
|
/**
|
||||||
* Gets an alias from the server/group's name
|
* Gets an alias from the server/group's name
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import us.ajg0702.queue.api.players.AdaptedPlayer;
|
|||||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||||
import us.ajg0702.queue.api.queues.QueueServer;
|
import us.ajg0702.queue.api.queues.QueueServer;
|
||||||
|
|
||||||
import java.util.List;
|
@SuppressWarnings({"SameReturnValue", "unused"})
|
||||||
|
|
||||||
public interface Logic {
|
public interface Logic {
|
||||||
/**
|
/**
|
||||||
@@ -15,7 +15,6 @@ public interface Logic {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The priority logic that is executed if the plugin is premium.
|
* The priority logic that is executed if the plugin is premium.
|
||||||
* @param list The current queue
|
|
||||||
* @param server The server/group name that is being queued for
|
* @param server The server/group name that is being queued for
|
||||||
* @param player The player that is being queued
|
* @param player The player that is being queued
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package us.ajg0702.queue.api;
|
|||||||
|
|
||||||
import us.ajg0702.utils.common.Config;
|
import us.ajg0702.utils.common.Config;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface LogicGetter {
|
public interface LogicGetter {
|
||||||
Logic constructLogic();
|
Logic constructLogic();
|
||||||
AliasManager constructAliasManager(Config config);
|
AliasManager constructAliasManager(Config config);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import us.ajg0702.queue.api.commands.ICommandSender;
|
|||||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||||
import us.ajg0702.queue.api.queues.QueueServer;
|
import us.ajg0702.queue.api.queues.QueueServer;
|
||||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
|
||||||
|
|
||||||
public interface PlatformMethods {
|
public interface PlatformMethods {
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +21,7 @@ public interface PlatformMethods {
|
|||||||
* @param channel The (sub)channel
|
* @param channel The (sub)channel
|
||||||
* @param data The data
|
* @param data The data
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("EmptyMethod")
|
||||||
void sendPluginMessage(AdaptedPlayer player, String channel, String... data);
|
void sendPluginMessage(AdaptedPlayer player, String channel, String... data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public interface QueueManager {
|
|||||||
* @param serverName The name of the server or group to add the player too
|
* @param serverName The name of the server or group to add the player too
|
||||||
* @return True if adding was successfull, false if not.
|
* @return True if adding was successfull, false if not.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
boolean addToQueue(AdaptedPlayer player, String serverName);
|
boolean addToQueue(AdaptedPlayer player, String serverName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import us.ajg0702.utils.common.Messages;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface IBaseCommand {
|
public interface IBaseCommand {
|
||||||
|
|
||||||
String getName();
|
String getName();
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
package us.ajg0702.queue.api.commands;
|
package us.ajg0702.queue.api.commands;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ISubCommand extends IBaseCommand {
|
public interface ISubCommand extends IBaseCommand {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package us.ajg0702.queue.api.players;
|
|||||||
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||||
import us.ajg0702.queue.api.util.Handle;
|
import us.ajg0702.queue.api.util.Handle;
|
||||||
|
|
||||||
@@ -10,25 +11,27 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Represents a cross-platform player
|
* Represents a cross-platform player
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface AdaptedPlayer extends Handle, Audience {
|
public interface AdaptedPlayer extends Handle, Audience {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the plauer is currently connected
|
* Check if the plauer is currently connected
|
||||||
* @return True if connected, false if not
|
* @return True if connected, false if not
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
boolean isConnected();
|
boolean isConnected();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a player a message from a Component
|
* Send a player a message from a Component
|
||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
void sendMessage(Component message);
|
void sendMessage(@NotNull Component message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an actionbar message to the player
|
* Sends an actionbar message to the player
|
||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
void sendActionBar(Component message);
|
void sendActionBar(@NotNull Component message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a player a message from a string
|
* Send a player a message from a string
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Represents a server or a group that can be queued for
|
* Represents a server or a group that can be queued for
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface QueueServer {
|
public interface QueueServer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +53,12 @@ public interface QueueServer {
|
|||||||
*/
|
*/
|
||||||
long getLastSentTime();
|
long getLastSentTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the time the last person was sent
|
||||||
|
* @param lastSentTime the time the last person was sent
|
||||||
|
*/
|
||||||
|
void setLastSentTime(long lastSentTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +217,7 @@ public interface QueueServer {
|
|||||||
* elliot is bad
|
* elliot is bad
|
||||||
* @return true because elliot is bad
|
* @return true because elliot is bad
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "SameReturnValue"})
|
||||||
default boolean elliot_is_bad() {
|
default boolean elliot_is_bad() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import us.ajg0702.queue.api.util.Handle;
|
|||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface AdaptedServer extends Handle {
|
public interface AdaptedServer extends Handle {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,6 +33,7 @@ public interface AdaptedServer extends Handle {
|
|||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return False if the server is restricted and the player does not have permission to join.
|
* @return False if the server is restricted and the player does not have permission to join.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("SameReturnValue")
|
||||||
boolean canAccess(AdaptedPlayer player);
|
boolean canAccess(AdaptedPlayer player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package us.ajg0702.queue.api.server;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import us.ajg0702.queue.api.util.Handle;
|
import us.ajg0702.queue.api.util.Handle;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public interface AdaptedServerPing extends Handle {
|
public interface AdaptedServerPing extends Handle {
|
||||||
/**
|
/**
|
||||||
* Gets the component of the description (aka MOTD)
|
* Gets the component of the description (aka MOTD)
|
||||||
|
|||||||
@@ -47,11 +47,6 @@ public class LeaveCommand extends BaseCommand {
|
|||||||
return main.getMessages();
|
return main.getMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSubCommand(ISubCommand subCommand) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ICommandSender sender, String[] args) {
|
public void execute(ICommandSender sender, String[] args) {
|
||||||
System.out.println("leave command");
|
System.out.println("leave command");
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import us.ajg0702.queue.common.QueueMain;
|
|||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ListCommand extends BaseCommand {
|
public class ListCommand extends BaseCommand {
|
||||||
@@ -47,11 +46,6 @@ public class ListCommand extends BaseCommand {
|
|||||||
return main.getMessages();
|
return main.getMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSubCommand(ISubCommand subCommand) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ICommandSender sender, String[] args) {
|
public void execute(ICommandSender sender, String[] args) {
|
||||||
if(!checkPermission(sender)) return;
|
if(!checkPermission(sender)) return;
|
||||||
@@ -63,9 +57,7 @@ public class ListCommand extends BaseCommand {
|
|||||||
|
|
||||||
|
|
||||||
Component m = main.getMessages().getComponent("commands.listqueues.header");
|
Component m = main.getMessages().getComponent("commands.listqueues.header");
|
||||||
boolean none = true;
|
|
||||||
for(QueueServer s : main.getQueueManager().getServers()) {
|
for(QueueServer s : main.getQueueManager().getServers()) {
|
||||||
none = false;
|
|
||||||
String color = "&a";
|
String color = "&a";
|
||||||
if(!s.isOnline()) {
|
if(!s.isOnline()) {
|
||||||
color = "&c";
|
color = "&c";
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||||
import us.ajg0702.queue.commands.BaseCommand;
|
import us.ajg0702.queue.commands.BaseCommand;
|
||||||
import us.ajg0702.queue.commands.SubCommand;
|
|
||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
public class ManageCommand extends BaseCommand {
|
public class ManageCommand extends BaseCommand {
|
||||||
|
|
||||||
QueueMain main;
|
final QueueMain main;
|
||||||
|
|
||||||
public ManageCommand(QueueMain main) {
|
public ManageCommand(QueueMain main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
@@ -36,7 +35,7 @@ public class ManageCommand extends BaseCommand {
|
|||||||
return ImmutableList.of("ajq");
|
return ImmutableList.of("ajq");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ISubCommand> subCommands = new ArrayList<>();
|
final List<ISubCommand> subCommands = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableList<ISubCommand> getSubCommands() {
|
public ImmutableList<ISubCommand> getSubCommands() {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
|
||||||
import us.ajg0702.queue.commands.SubCommand;
|
import us.ajg0702.queue.commands.SubCommand;
|
||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
@@ -15,7 +14,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Reload extends SubCommand {
|
public class Reload extends SubCommand {
|
||||||
|
|
||||||
QueueMain main;
|
final QueueMain main;
|
||||||
public Reload(QueueMain main) {
|
public Reload(QueueMain main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
@@ -40,11 +39,6 @@ public class Reload extends SubCommand {
|
|||||||
return main.getMessages();
|
return main.getMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSubCommand(ISubCommand subCommand) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ICommandSender sender, String[] args) {
|
public void execute(ICommandSender sender, String[] args) {
|
||||||
if(!checkPermission(sender)) return;
|
if(!checkPermission(sender)) return;
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ package us.ajg0702.queue.commands.commands.manage;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
|
||||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
|
||||||
import us.ajg0702.queue.commands.SubCommand;
|
import us.ajg0702.queue.commands.SubCommand;
|
||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
@@ -15,7 +12,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Tasks extends SubCommand {
|
public class Tasks extends SubCommand {
|
||||||
|
|
||||||
QueueMain main;
|
final QueueMain main;
|
||||||
public Tasks(QueueMain main) {
|
public Tasks(QueueMain main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
@@ -40,11 +37,6 @@ public class Tasks extends SubCommand {
|
|||||||
return main.getMessages();
|
return main.getMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSubCommand(ISubCommand subCommand) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ICommandSender sender, String[] args) {
|
public void execute(ICommandSender sender, String[] args) {
|
||||||
if(!checkPermission(sender)) return;
|
if(!checkPermission(sender)) return;
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ public class QueueCommand extends BaseCommand {
|
|||||||
return main.getMessages();
|
return main.getMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addSubCommand(ISubCommand subCommand) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ICommandSender sender, String[] args) {
|
public void execute(ICommandSender sender, String[] args) {
|
||||||
if(!checkPermission(sender)) return;
|
if(!checkPermission(sender)) return;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class QueueMain {
|
|||||||
return taskManager;
|
return taskManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CompletableFuture<ServerBuilder>> serverCompletableFutures = new ArrayList<>();
|
private final List<CompletableFuture<ServerBuilder>> serverCompletableFutures = new ArrayList<>();
|
||||||
private ServerBuilder serverBuilder;
|
private ServerBuilder serverBuilder;
|
||||||
public ServerBuilder getServerBuilder() {
|
public ServerBuilder getServerBuilder() {
|
||||||
return serverBuilder;
|
return serverBuilder;
|
||||||
@@ -94,7 +94,7 @@ public class QueueMain {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private File dataFolder;
|
private final File dataFolder;
|
||||||
|
|
||||||
|
|
||||||
public QueueMain(Logger logger, PlatformMethods platformMethods, File dataFolder) {
|
public QueueMain(Logger logger, PlatformMethods platformMethods, File dataFolder) {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package us.ajg0702.queue.common;
|
package us.ajg0702.queue.common;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import us.ajg0702.queue.api.QueueManager;
|
import us.ajg0702.queue.api.QueueManager;
|
||||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||||
@@ -347,8 +345,8 @@ public class QueueManagerImpl implements QueueManager {
|
|||||||
sendPlayers(null);
|
sendPlayers(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<AdaptedPlayer, Long> sendingNowAntiSpam = new HashMap<>();
|
final HashMap<AdaptedPlayer, Long> sendingNowAntiSpam = new HashMap<>();
|
||||||
HashMap<QueuePlayer, Integer> sendingAttempts = new HashMap<>();
|
final HashMap<QueuePlayer, Integer> sendingAttempts = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPlayers(QueueServer queueServer) {
|
public void sendPlayers(QueueServer queueServer) {
|
||||||
@@ -439,6 +437,7 @@ public class QueueManagerImpl implements QueueManager {
|
|||||||
main.getLogger().severe("Could not find ideal server for server/group '"+server.getName()+"'");
|
main.getLogger().severe("Could not find ideal server for server/group '"+server.getName()+"'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
server.setLastSentTime(System.currentTimeMillis());
|
||||||
nextPlayer.connect(selected);
|
nextPlayer.connect(selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package us.ajg0702.queue.common;
|
package us.ajg0702.queue.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@@ -10,10 +9,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class TaskManager {
|
public class TaskManager {
|
||||||
|
|
||||||
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||||
ScheduledExecutorService updateExecutor = Executors.newScheduledThreadPool(1);
|
final ScheduledExecutorService updateExecutor = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
QueueMain main;
|
final QueueMain main;
|
||||||
public TaskManager(QueueMain main) {
|
public TaskManager(QueueMain main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
@@ -39,7 +38,6 @@ public class TaskManager {
|
|||||||
|
|
||||||
sendTask = scheduleAtFixedRate(
|
sendTask = scheduleAtFixedRate(
|
||||||
main.getQueueManager()::sendPlayers,
|
main.getQueueManager()::sendPlayers,
|
||||||
0L,
|
|
||||||
(long) (main.getConfig().getDouble("wait-time")*1000L),
|
(long) (main.getConfig().getDouble("wait-time")*1000L),
|
||||||
TimeUnit.MILLISECONDS
|
TimeUnit.MILLISECONDS
|
||||||
);
|
);
|
||||||
@@ -53,21 +51,18 @@ public class TaskManager {
|
|||||||
|
|
||||||
messageTask = scheduleAtFixedRate(
|
messageTask = scheduleAtFixedRate(
|
||||||
main.getQueueManager()::sendMessages,
|
main.getQueueManager()::sendMessages,
|
||||||
0L,
|
|
||||||
main.getConfig().getInt("message-time"),
|
main.getConfig().getInt("message-time"),
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
|
|
||||||
actionBarTask = scheduleAtFixedRate(
|
actionBarTask = scheduleAtFixedRate(
|
||||||
main.getQueueManager()::sendActionBars,
|
main.getQueueManager()::sendActionBars,
|
||||||
0L,
|
|
||||||
2L,
|
2L,
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
|
|
||||||
queueEventTask = scheduleAtFixedRate(
|
queueEventTask = scheduleAtFixedRate(
|
||||||
main.getQueueManager()::sendQueueEvents,
|
main.getQueueManager()::sendQueueEvents,
|
||||||
0L,
|
|
||||||
2L,
|
2L,
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
@@ -75,7 +70,6 @@ public class TaskManager {
|
|||||||
if(main.getConfig().getInt("reload-servers-interval") > 0) {
|
if(main.getConfig().getInt("reload-servers-interval") > 0) {
|
||||||
reloadServerTask = scheduleAtFixedRate(
|
reloadServerTask = scheduleAtFixedRate(
|
||||||
main.getQueueManager()::reloadServers,
|
main.getQueueManager()::reloadServers,
|
||||||
0L,
|
|
||||||
main.getConfig().getInt("reload-servers-interval"),
|
main.getConfig().getInt("reload-servers-interval"),
|
||||||
TimeUnit.SECONDS
|
TimeUnit.SECONDS
|
||||||
);
|
);
|
||||||
@@ -105,8 +99,8 @@ public class TaskManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
|
private ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long period, TimeUnit unit) {
|
||||||
return scheduleAtFixedRate(executor, command, initialDelay, period, unit);
|
return scheduleAtFixedRate(executor, command, 0, period, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import us.ajg0702.queue.api.players.AdaptedPlayer;
|
|||||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||||
import us.ajg0702.queue.api.queues.QueueServer;
|
import us.ajg0702.queue.api.queues.QueueServer;
|
||||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||||
import us.ajg0702.queue.api.server.AdaptedServerInfo;
|
|
||||||
import us.ajg0702.queue.api.server.AdaptedServerPing;
|
import us.ajg0702.queue.api.server.AdaptedServerPing;
|
||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.GenUtils;
|
import us.ajg0702.utils.common.GenUtils;
|
||||||
@@ -33,7 +32,7 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
|
|
||||||
private final QueueMain main;
|
private final QueueMain main;
|
||||||
|
|
||||||
private HashMap<AdaptedServer, AdaptedServerPing> pings = new HashMap<>();
|
private final HashMap<AdaptedServer, AdaptedServerPing> pings = new HashMap<>();
|
||||||
|
|
||||||
private final List<AdaptedServer> servers;
|
private final List<AdaptedServer> servers;
|
||||||
|
|
||||||
@@ -165,7 +164,11 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLastSentTime() {
|
public long getLastSentTime() {
|
||||||
return lastSentTime;
|
return System.currentTimeMillis() - lastSentTime;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void setLastSentTime(long lastSentTime) {
|
||||||
|
this.lastSentTime = lastSentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import us.ajg0702.queue.api.AliasManager;
|
|||||||
import us.ajg0702.utils.common.Config;
|
import us.ajg0702.utils.common.Config;
|
||||||
|
|
||||||
public class FreeAliasManager implements AliasManager {
|
public class FreeAliasManager implements AliasManager {
|
||||||
Config config;
|
@SuppressWarnings("unused")
|
||||||
|
final Config config;
|
||||||
public FreeAliasManager(Config config) {
|
public FreeAliasManager(Config config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -2,6 +2,7 @@ package us.ajg0702.queue.platforms.velocity;
|
|||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import us.ajg0702.queue.api.PlatformMethods;
|
import us.ajg0702.queue.api.PlatformMethods;
|
||||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||||
@@ -13,8 +14,8 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class PlatformMethodImpl implements PlatformMethods {
|
public class PlatformMethodImpl implements PlatformMethods {
|
||||||
|
|
||||||
ProxyServer proxyServer;
|
final ProxyServer proxyServer;
|
||||||
Logger logger;
|
final Logger logger;
|
||||||
|
|
||||||
public PlatformMethodImpl(ProxyServer proxyServer, Logger logger) {
|
public PlatformMethodImpl(ProxyServer proxyServer, Logger logger) {
|
||||||
this.proxyServer = proxyServer;
|
this.proxyServer = proxyServer;
|
||||||
@@ -25,7 +26,7 @@ public class PlatformMethodImpl implements PlatformMethods {
|
|||||||
public void sendJoinQueueChannelMessages(QueueServer queueServer, QueuePlayer queuePlayer) {
|
public void sendJoinQueueChannelMessages(QueueServer queueServer, QueuePlayer queuePlayer) {
|
||||||
AdaptedPlayer player = queuePlayer.getPlayer();
|
AdaptedPlayer player = queuePlayer.getPlayer();
|
||||||
if(player == null) return;
|
if(player == null) return;
|
||||||
|
player.sendMessage(Component.text());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-3
@@ -32,12 +32,12 @@ import java.util.logging.Logger;
|
|||||||
)
|
)
|
||||||
|
|
||||||
public class VelocityQueue {
|
public class VelocityQueue {
|
||||||
ProxyServer proxyServer;
|
final ProxyServer proxyServer;
|
||||||
Logger logger;
|
final Logger logger;
|
||||||
|
|
||||||
QueueMain main;
|
QueueMain main;
|
||||||
|
|
||||||
File dataFolder;
|
final File dataFolder;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public VelocityQueue(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataFolder) {
|
public VelocityQueue(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataFolder) {
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class VelocityCommand implements RawCommand {
|
public class VelocityCommand implements RawCommand {
|
||||||
|
|
||||||
QueueMain main;
|
final QueueMain main;
|
||||||
BaseCommand command;
|
final BaseCommand command;
|
||||||
|
|
||||||
public VelocityCommand(QueueMain main, BaseCommand command) {
|
public VelocityCommand(QueueMain main, BaseCommand command) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
|
|||||||
+3
-3
@@ -2,13 +2,13 @@ package us.ajg0702.queue.platforms.velocity.commands;
|
|||||||
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||||
|
|
||||||
public class VelocitySender implements ICommandSender {
|
public class VelocitySender implements ICommandSender {
|
||||||
|
|
||||||
CommandSource handle;
|
final CommandSource handle;
|
||||||
|
|
||||||
public VelocitySender(CommandSource handle) {
|
public VelocitySender(CommandSource handle) {
|
||||||
this.handle = handle;
|
this.handle = handle;
|
||||||
@@ -25,7 +25,7 @@ public class VelocitySender implements ICommandSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(Component message) {
|
public void sendMessage(@NotNull Component message) {
|
||||||
handle.sendMessage(message);
|
handle.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -6,6 +6,7 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
|||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class VelocityPlayer implements AdaptedPlayer, Audience {
|
public class VelocityPlayer implements AdaptedPlayer, Audience {
|
||||||
|
|
||||||
Player handle;
|
final Player handle;
|
||||||
|
|
||||||
public VelocityPlayer(Player player) {
|
public VelocityPlayer(Player player) {
|
||||||
handle = player;
|
handle = player;
|
||||||
@@ -26,13 +27,13 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(Component message) {
|
public void sendMessage(@NotNull Component message) {
|
||||||
if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
|
if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
|
||||||
handle.sendMessage(message);
|
handle.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendActionBar(Component message) {
|
public void sendActionBar(@NotNull Component message) {
|
||||||
handle.sendActionBar(message);
|
handle.sendActionBar(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
|
|||||||
@Override
|
@Override
|
||||||
public String getServerName() {
|
public String getServerName() {
|
||||||
Optional<ServerConnection> serverConnection = handle.getCurrentServer();
|
Optional<ServerConnection> serverConnection = handle.getCurrentServer();
|
||||||
if(!serverConnection.isPresent()) return "none";
|
if(serverConnection.isEmpty()) return "none";
|
||||||
ServerConnection connection = serverConnection.get();
|
ServerConnection connection = serverConnection.get();
|
||||||
return connection.getServerInfo().getName();
|
return connection.getServerInfo().getName();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ public class ServerBuilderImpl implements ServerBuilder {
|
|||||||
@Override
|
@Override
|
||||||
public AdaptedServer getServer(String name) {
|
public AdaptedServer getServer(String name) {
|
||||||
Optional<RegisteredServer> serverOptional = proxyServer.getServer(name);
|
Optional<RegisteredServer> serverOptional = proxyServer.getServer(name);
|
||||||
if(serverOptional.isPresent()) return null;
|
if(serverOptional.isEmpty()) return null;
|
||||||
return new VelocityServer(serverOptional.get());
|
return new VelocityServer(serverOptional.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-8
@@ -5,8 +5,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import us.ajg0702.queue.api.server.AdaptedServerPing;
|
import us.ajg0702.queue.api.server.AdaptedServerPing;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class VelocityServerPing implements AdaptedServerPing {
|
public class VelocityServerPing implements AdaptedServerPing {
|
||||||
|
|
||||||
private final ServerPing handle;
|
private final ServerPing handle;
|
||||||
@@ -26,16 +24,12 @@ public class VelocityServerPing implements AdaptedServerPing {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerCount() {
|
public int getPlayerCount() {
|
||||||
Optional<ServerPing.Players> players = handle.getPlayers();
|
return handle.getPlayers().map(ServerPing.Players::getOnline).orElse(0);
|
||||||
if(!players.isPresent()) return 0;
|
|
||||||
return players.get().getOnline();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxPlayers() {
|
public int getMaxPlayers() {
|
||||||
Optional<ServerPing.Players> players = handle.getPlayers();
|
return handle.getPlayers().map(ServerPing.Players::getMax).orElse(0);
|
||||||
if(!players.isPresent()) return 0;
|
|
||||||
return players.get().getMax();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user