Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Delay registration of protocols until the plugin has loaded to prevent it being done at the wrong time, #323 #316 Fixed
Dieser Commit ist enthalten in:
Ursprung
4431ca63c2
Commit
c7c6ee9fbc
@ -94,6 +94,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI, ViaVe
|
||||
|
||||
getCommand("viaversion").setExecutor(commandHandler = new ViaCommandHandler());
|
||||
getCommand("viaversion").setTabCompleter(commandHandler);
|
||||
|
||||
// Register Protocol Listeners
|
||||
ProtocolRegistry.registerListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,6 @@ public abstract class Protocol {
|
||||
|
||||
public Protocol() {
|
||||
registerPackets();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package us.myles.ViaVersion.api.protocol;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
@ -11,6 +12,7 @@ public class ProtocolRegistry {
|
||||
// Input Version -> Output Version & Protocol (Allows fast lookup)
|
||||
private static Map<Integer, Map<Integer, Protocol>> registryMap = new HashMap<>();
|
||||
private static Map<Pair<Integer, Integer>, List<Pair<Integer, Protocol>>> pathCache = new HashMap<>();
|
||||
private static List<Protocol> registerList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
// Register built in protocols
|
||||
@ -37,6 +39,12 @@ public class ProtocolRegistry {
|
||||
|
||||
registryMap.get(version).put(output, protocol);
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("ViaVersion").isEnabled()) {
|
||||
protocol.registerListeners();
|
||||
} else {
|
||||
registerList.add(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,6 +59,16 @@ public class ProtocolRegistry {
|
||||
return false; // No destination for protocol
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server is enabled, to register any non registered listeners.
|
||||
*/
|
||||
public static void registerListeners() {
|
||||
for (Protocol protocol : registerList) {
|
||||
protocol.registerListeners();
|
||||
}
|
||||
registerList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate a path to get from an input protocol to the servers protocol.
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren