3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-24 15:20:15 +01:00

Add a command to force search versions @ Bungee

Dieser Commit ist enthalten in:
Matsv 2016-10-01 15:38:53 +02:00
Ursprung ba3aa4566e
Commit 59620f7f93
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
4 geänderte Dateien mit 39 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,15 @@
package us.myles.ViaVersion.bungee.commands;
import us.myles.ViaVersion.bungee.commands.subs.SearchServersSubCmd;
import us.myles.ViaVersion.commands.ViaCommandHandler;
public class BungeeCommandHandler extends ViaCommandHandler {
public BungeeCommandHandler() {
try {
registerSubCommand(new SearchServersSubCmd());
} catch (Exception e) {
System.out.println("Failed to register Bungee subcommands");
e.printStackTrace();
}
}
}

Datei anzeigen

@ -0,0 +1,25 @@
package us.myles.ViaVersion.bungee.commands.subs;
import us.myles.ViaVersion.api.command.ViaCommandSender;
import us.myles.ViaVersion.api.command.ViaSubCommand;
import us.myles.ViaVersion.bungee.service.ProtocolDetectorService;
// TODO better name
public class SearchServersSubCmd extends ViaSubCommand {
@Override
public String name() {
return "searchservers";
}
@Override
public String description() {
return "Force ViaVersion to search for servers to update the version list (Also happens every minute)";
}
@Override
public boolean execute(ViaCommandSender sender, String[] args) {
ProtocolDetectorService.getInstance().run();
sendMessage(sender, "&6Started searching for subservers");
return true;
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.bungee.service;
import lombok.Getter;
import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.ServerPing;
import net.md_5.bungee.api.config.ServerInfo;
@ -11,9 +12,12 @@ import java.util.concurrent.ConcurrentHashMap;
public class ProtocolDetectorService implements Runnable {
private static final Map<String, Integer> protocolIds = new ConcurrentHashMap<>();
private BungeePlugin plugin;
@Getter
private static ProtocolDetectorService instance;
public ProtocolDetectorService(BungeePlugin plugin) {
this.plugin = plugin;
instance = this;
}
public static Integer getProtocolId(String serverName) {
@ -39,8 +43,6 @@ public class ProtocolDetectorService implements Runnable {
public void done(ServerPing serverPing, Throwable throwable) {
if (throwable == null)
protocolIds.put(key, serverPing.getVersion().getProtocol());
else
throwable.printStackTrace();
}
});
}

Datei anzeigen

@ -10,7 +10,7 @@ public class ViaIdleThread implements Runnable {
@Override
public void run() {
for (UserConnection info : Via.getManager().getPortedPlayers().values()) {
if (info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
if (info.has(ProtocolInfo.class) && info.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
if (nextIdleUpdate <= System.currentTimeMillis()) {
if (info.getChannel().isOpen()) {