Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-25 07:40:08 +01:00
Add a command to force search versions @ Bungee
Dieser Commit ist enthalten in:
Ursprung
ba3aa4566e
Commit
59620f7f93
@ -1,7 +1,15 @@
|
|||||||
package us.myles.ViaVersion.bungee.commands;
|
package us.myles.ViaVersion.bungee.commands;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.bungee.commands.subs.SearchServersSubCmd;
|
||||||
import us.myles.ViaVersion.commands.ViaCommandHandler;
|
import us.myles.ViaVersion.commands.ViaCommandHandler;
|
||||||
|
|
||||||
public class BungeeCommandHandler extends 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package us.myles.ViaVersion.bungee.service;
|
package us.myles.ViaVersion.bungee.service;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.api.Callback;
|
import net.md_5.bungee.api.Callback;
|
||||||
import net.md_5.bungee.api.ServerPing;
|
import net.md_5.bungee.api.ServerPing;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
@ -11,9 +12,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
public class ProtocolDetectorService implements Runnable {
|
public class ProtocolDetectorService implements Runnable {
|
||||||
private static final Map<String, Integer> protocolIds = new ConcurrentHashMap<>();
|
private static final Map<String, Integer> protocolIds = new ConcurrentHashMap<>();
|
||||||
private BungeePlugin plugin;
|
private BungeePlugin plugin;
|
||||||
|
@Getter
|
||||||
|
private static ProtocolDetectorService instance;
|
||||||
|
|
||||||
public ProtocolDetectorService(BungeePlugin plugin) {
|
public ProtocolDetectorService(BungeePlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getProtocolId(String serverName) {
|
public static Integer getProtocolId(String serverName) {
|
||||||
@ -39,8 +43,6 @@ public class ProtocolDetectorService implements Runnable {
|
|||||||
public void done(ServerPing serverPing, Throwable throwable) {
|
public void done(ServerPing serverPing, Throwable throwable) {
|
||||||
if (throwable == null)
|
if (throwable == null)
|
||||||
protocolIds.put(key, serverPing.getVersion().getProtocol());
|
protocolIds.put(key, serverPing.getVersion().getProtocol());
|
||||||
else
|
|
||||||
throwable.printStackTrace();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public class ViaIdleThread implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (UserConnection info : Via.getManager().getPortedPlayers().values()) {
|
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();
|
long nextIdleUpdate = info.get(MovementTracker.class).getNextIdlePacket();
|
||||||
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
if (nextIdleUpdate <= System.currentTimeMillis()) {
|
||||||
if (info.getChannel().isOpen()) {
|
if (info.getChannel().isOpen()) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren