auto restart system
parent
f63d64b6e0
commit
9743f674a4
|
@ -3,8 +3,12 @@ package net.krakatoa.proxy.command;
|
||||||
import de.dytanic.cloudnet.driver.CloudNetDriver;
|
import de.dytanic.cloudnet.driver.CloudNetDriver;
|
||||||
import de.dytanic.cloudnet.driver.service.ServiceInfoSnapshot;
|
import de.dytanic.cloudnet.driver.service.ServiceInfoSnapshot;
|
||||||
import de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty;
|
import de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty;
|
||||||
|
import de.dytanic.cloudnet.ext.bridge.player.ICloudPlayer;
|
||||||
|
import de.dytanic.cloudnet.ext.bridge.player.IPlayerManager;
|
||||||
import de.dytanic.cloudnet.ext.bridge.player.ServicePlayer;
|
import de.dytanic.cloudnet.ext.bridge.player.ServicePlayer;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
@ -16,6 +20,8 @@ public class CodeCommand extends Command {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HashMap<String, UUID> playersServer = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender commandSender, String[] strings) {
|
public void execute(CommandSender commandSender, String[] strings) {
|
||||||
if (commandSender instanceof ProxiedPlayer) {
|
if (commandSender instanceof ProxiedPlayer) {
|
||||||
|
@ -48,10 +54,20 @@ public class CodeCommand extends Command {
|
||||||
ServiceInfoSnapshot serviceInfoSnapshot = CloudNetDriver.getInstance()
|
ServiceInfoSnapshot serviceInfoSnapshot = CloudNetDriver.getInstance()
|
||||||
.getCloudServiceProvider().getCloudServiceByName("lobby-1");
|
.getCloudServiceProvider().getCloudServiceByName("lobby-1");
|
||||||
|
|
||||||
|
IPlayerManager playerManager = CloudNetDriver.getInstance().getServicesRegistry()
|
||||||
|
.getFirstService(IPlayerManager.class);
|
||||||
|
|
||||||
assert serviceInfoSnapshot != null;
|
assert serviceInfoSnapshot != null;
|
||||||
serviceInfoSnapshot.getProperty(BridgeServiceProperty.PLAYERS).ifPresent(players -> {
|
serviceInfoSnapshot.getProperty(BridgeServiceProperty.PLAYERS).ifPresent(players -> {
|
||||||
for (ServicePlayer player : players) {
|
for (ServicePlayer player : players) {
|
||||||
System.out.println("player " + player.getName());
|
System.out.println("player " + player.getName());
|
||||||
|
playersServer.put("lobby-1", player.getUniqueId());
|
||||||
|
|
||||||
|
ICloudPlayer cloudPlayer = playerManager.getOnlinePlayer(
|
||||||
|
player.getUniqueId());
|
||||||
|
|
||||||
|
assert cloudPlayer != null;
|
||||||
|
cloudPlayer.getPlayerExecutor().connect("NewYork-1");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue