Remove ServerBuilder
This commit is contained in:
+9
@@ -110,4 +110,13 @@ public class BungeeMethods implements PlatformMethods {
|
||||
if(server == null) return null;
|
||||
return new BungeeServer(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdaptedServer> getServers() {
|
||||
List<AdaptedServer> result = new ArrayList<>();
|
||||
|
||||
proxyServer.getServers().forEach((s, serverInfo) -> result.add(new BungeeServer(serverInfo)));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -20,7 +20,6 @@ import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.queue.platforms.bungeecord.commands.BungeeCommand;
|
||||
import us.ajg0702.queue.platforms.bungeecord.players.BungeePlayer;
|
||||
import us.ajg0702.queue.platforms.bungeecord.server.BungeeServer;
|
||||
import us.ajg0702.queue.platforms.bungeecord.server.BungeeServerBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -42,7 +41,6 @@ public class BungeeQueue extends Plugin implements Listener {
|
||||
new BungeeMethods(this, getProxy(), logger),
|
||||
dataFolder
|
||||
);
|
||||
main.setServerBuilder(new BungeeServerBuilder(getProxy()));
|
||||
|
||||
getProxy().registerChannel("ajqueue:tospigot");
|
||||
getProxy().registerChannel("ajqueue:toproxy");
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package us.ajg0702.queue.platforms.bungeecord.server;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import us.ajg0702.queue.api.server.AdaptedServer;
|
||||
import us.ajg0702.queue.api.server.ServerBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeeServerBuilder implements ServerBuilder {
|
||||
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
public BungeeServerBuilder(ProxyServer proxyServer) {
|
||||
this.proxyServer = proxyServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdaptedServer> getServers() {
|
||||
List<AdaptedServer> result = new ArrayList<>();
|
||||
|
||||
proxyServer.getServers().forEach((s, serverInfo) -> result.add(new BungeeServer(serverInfo)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdaptedServer getServer(String name) {
|
||||
ServerInfo server = proxyServer.getServerInfo(name);
|
||||
if(server == null) return null;
|
||||
return new BungeeServer(server);
|
||||
}
|
||||
}
|
||||
+10
@@ -132,4 +132,14 @@ public class VelocityMethods implements PlatformMethods {
|
||||
if(!server.isPresent()) return null;
|
||||
return new VelocityServer(server.get());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<AdaptedServer> getServers() {
|
||||
List<AdaptedServer> result = new ArrayList<>();
|
||||
|
||||
proxyServer.getAllServers().forEach(registeredServer -> result.add(new VelocityServer(registeredServer)));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -15,6 +15,7 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.slf4j.Logger;
|
||||
import us.ajg0702.queue.api.commands.IBaseCommand;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.commands.commands.leavequeue.LeaveCommand;
|
||||
@@ -24,7 +25,7 @@ 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.players.VelocityPlayer;
|
||||
import us.ajg0702.queue.platforms.velocity.server.VelocityServerBuilder;
|
||||
import us.ajg0702.queue.platforms.velocity.server.VelocityServer;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
@@ -32,9 +33,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import us.ajg0702.queue.platforms.velocity.server.VelocityServer;
|
||||
|
||||
@Plugin(
|
||||
id = "ajqueue",
|
||||
name = "ajQueue",
|
||||
@@ -69,7 +67,6 @@ public class VelocityQueue {
|
||||
new VelocityMethods(this, proxyServer, logger),
|
||||
dataFolder
|
||||
);
|
||||
main.setServerBuilder(new VelocityServerBuilder(proxyServer));
|
||||
|
||||
commands = Arrays.asList(
|
||||
new QueueCommand(main),
|
||||
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
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.AdaptedServer;
|
||||
import us.ajg0702.queue.api.server.ServerBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class VelocityServerBuilder implements ServerBuilder {
|
||||
|
||||
private final ProxyServer proxyServer;
|
||||
|
||||
public VelocityServerBuilder(ProxyServer proxyServer) {
|
||||
this.proxyServer = proxyServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdaptedServer> getServers() {
|
||||
List<AdaptedServer> result = new ArrayList<>();
|
||||
|
||||
proxyServer.getAllServers().forEach(registeredServer -> result.add(new VelocityServer(registeredServer)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("OptionalIsPresent")
|
||||
@Override
|
||||
public AdaptedServer getServer(String name) {
|
||||
Optional<RegisteredServer> serverOptional = proxyServer.getServer(name);
|
||||
if(!serverOptional.isPresent()) return null;
|
||||
return new VelocityServer(serverOptional.get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user