Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Async mapping loader change
Dieser Commit ist enthalten in:
Ursprung
48a69f1411
Commit
29908523b0
@ -15,8 +15,6 @@ import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
|||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public abstract class BackwardsProtocol extends Protocol {
|
public abstract class BackwardsProtocol extends Protocol {
|
||||||
|
|
||||||
protected BackwardsProtocol() {
|
protected BackwardsProtocol() {
|
||||||
@ -46,13 +44,6 @@ public abstract class BackwardsProtocol extends Protocol {
|
|||||||
* Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
|
* Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
|
||||||
*/
|
*/
|
||||||
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
|
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
|
||||||
CompletableFuture<Void> future = ProtocolRegistry.getMappingLoaderFuture(protocolClass);
|
ProtocolRegistry.addMappingLoaderFuture(getClass(), protocolClass, runnable);
|
||||||
if (future == null) {
|
|
||||||
runnable.run();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the protocol to depend on has been loaded, execute the new runnable async and schedule it for necessary completion
|
|
||||||
future.whenComplete((v, t) -> ProtocolRegistry.addMappingLoaderFuture(getClass(), runnable));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren