clean some stuff up
This commit is contained in:
+4
-3
@@ -2,6 +2,7 @@ package us.ajg0702.queue.platforms.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.PlatformMethods;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
@@ -13,8 +14,8 @@ import java.util.logging.Logger;
|
||||
|
||||
public class PlatformMethodImpl implements PlatformMethods {
|
||||
|
||||
ProxyServer proxyServer;
|
||||
Logger logger;
|
||||
final ProxyServer proxyServer;
|
||||
final Logger logger;
|
||||
|
||||
public PlatformMethodImpl(ProxyServer proxyServer, Logger logger) {
|
||||
this.proxyServer = proxyServer;
|
||||
@@ -25,7 +26,7 @@ public class PlatformMethodImpl implements PlatformMethods {
|
||||
public void sendJoinQueueChannelMessages(QueueServer queueServer, QueuePlayer queuePlayer) {
|
||||
AdaptedPlayer player = queuePlayer.getPlayer();
|
||||
if(player == null) return;
|
||||
|
||||
player.sendMessage(Component.text());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -32,12 +32,12 @@ import java.util.logging.Logger;
|
||||
)
|
||||
|
||||
public class VelocityQueue {
|
||||
ProxyServer proxyServer;
|
||||
Logger logger;
|
||||
final ProxyServer proxyServer;
|
||||
final Logger logger;
|
||||
|
||||
QueueMain main;
|
||||
|
||||
File dataFolder;
|
||||
final File dataFolder;
|
||||
|
||||
@Inject
|
||||
public VelocityQueue(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataFolder) {
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ import java.util.List;
|
||||
|
||||
public class VelocityCommand implements RawCommand {
|
||||
|
||||
QueueMain main;
|
||||
BaseCommand command;
|
||||
final QueueMain main;
|
||||
final BaseCommand command;
|
||||
|
||||
public VelocityCommand(QueueMain main, BaseCommand command) {
|
||||
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.proxy.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
|
||||
public class VelocitySender implements ICommandSender {
|
||||
|
||||
CommandSource handle;
|
||||
final CommandSource handle;
|
||||
|
||||
public VelocitySender(CommandSource handle) {
|
||||
this.handle = handle;
|
||||
@@ -25,7 +25,7 @@ public class VelocitySender implements ICommandSender {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component message) {
|
||||
public void sendMessage(@NotNull Component 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.text.Component;
|
||||
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.server.AdaptedServer;
|
||||
|
||||
@@ -14,7 +15,7 @@ import java.util.UUID;
|
||||
|
||||
public class VelocityPlayer implements AdaptedPlayer, Audience {
|
||||
|
||||
Player handle;
|
||||
final Player handle;
|
||||
|
||||
public VelocityPlayer(Player player) {
|
||||
handle = player;
|
||||
@@ -26,13 +27,13 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Component message) {
|
||||
public void sendMessage(@NotNull Component message) {
|
||||
if(PlainTextComponentSerializer.plainText().serialize(message).isEmpty()) return;
|
||||
handle.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(Component message) {
|
||||
public void sendActionBar(@NotNull Component message) {
|
||||
handle.sendActionBar(message);
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ public class VelocityPlayer implements AdaptedPlayer, Audience {
|
||||
@Override
|
||||
public String getServerName() {
|
||||
Optional<ServerConnection> serverConnection = handle.getCurrentServer();
|
||||
if(!serverConnection.isPresent()) return "none";
|
||||
if(serverConnection.isEmpty()) return "none";
|
||||
ServerConnection connection = serverConnection.get();
|
||||
return connection.getServerInfo().getName();
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class ServerBuilderImpl implements ServerBuilder {
|
||||
@Override
|
||||
public AdaptedServer getServer(String name) {
|
||||
Optional<RegisteredServer> serverOptional = proxyServer.getServer(name);
|
||||
if(serverOptional.isPresent()) return null;
|
||||
if(serverOptional.isEmpty()) return null;
|
||||
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 us.ajg0702.queue.api.server.AdaptedServerPing;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class VelocityServerPing implements AdaptedServerPing {
|
||||
|
||||
private final ServerPing handle;
|
||||
@@ -26,16 +24,12 @@ public class VelocityServerPing implements AdaptedServerPing {
|
||||
|
||||
@Override
|
||||
public int getPlayerCount() {
|
||||
Optional<ServerPing.Players> players = handle.getPlayers();
|
||||
if(!players.isPresent()) return 0;
|
||||
return players.get().getOnline();
|
||||
return handle.getPlayers().map(ServerPing.Players::getOnline).orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers() {
|
||||
Optional<ServerPing.Players> players = handle.getPlayers();
|
||||
if(!players.isPresent()) return 0;
|
||||
return players.get().getMax();
|
||||
return handle.getPlayers().map(ServerPing.Players::getMax).orElse(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user