Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Add ViaManager#addPostEnableListener (#4038)
Dieser Commit ist enthalten in:
Ursprung
40a44d5dc5
Commit
24d0ae7607
@ -140,6 +140,13 @@ public interface ViaManager {
|
||||
*/
|
||||
void addEnableListener(Runnable runnable);
|
||||
|
||||
/**
|
||||
* Adds a runnable to be executed when ViaVersion has finished its init after the full server load.
|
||||
*
|
||||
* @param runnable runnable to be executed
|
||||
*/
|
||||
void addPostEnableListener(Runnable runnable);
|
||||
|
||||
/**
|
||||
* Returns whether the manager has been initialized (and protocols have been loaded).
|
||||
*
|
||||
|
@ -67,6 +67,7 @@ public class ViaManagerImpl implements ViaManager {
|
||||
private final ViaPlatformLoader loader;
|
||||
private final Set<String> subPlatforms = new HashSet<>();
|
||||
private List<Runnable> enableListeners = new ArrayList<>();
|
||||
private List<Runnable> postEnableListeners = new ArrayList<>();
|
||||
private PlatformTask<?> mappingLoadingTask;
|
||||
private boolean initialized;
|
||||
|
||||
@ -184,6 +185,11 @@ public class ViaManagerImpl implements ViaManager {
|
||||
|
||||
// Refresh Versions
|
||||
protocolManager.refreshVersions();
|
||||
|
||||
for (final Runnable listener : postEnableListeners) {
|
||||
listener.run();
|
||||
}
|
||||
postEnableListeners = null;
|
||||
}
|
||||
|
||||
private void loadServerProtocol() {
|
||||
@ -317,25 +323,21 @@ public class ViaManagerImpl implements ViaManager {
|
||||
return configurationProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mutable set of self-added subplatform version strings.
|
||||
* This set is expanded by the subplatform itself (e.g. ViaBackwards), and may not contain all running ones.
|
||||
*
|
||||
* @return mutable set of subplatform versions
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getSubPlatforms() {
|
||||
return subPlatforms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a runnable to be executed when ViaVersion has finished its init before the full server load.
|
||||
*
|
||||
* @param runnable runnable to be executed
|
||||
*/
|
||||
@Override
|
||||
public void addEnableListener(Runnable runnable) {
|
||||
enableListeners.add(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPostEnableListener(final Runnable runnable) {
|
||||
postEnableListeners.add(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
|
@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.platform.ViaPlatformLoader;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||
import com.viaversion.viaversion.protocol.version.BaseVersionProvider;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.provider.BossBarProvider;
|
||||
import com.viaversion.viaversion.velocity.listeners.UpdateListener;
|
||||
import com.viaversion.viaversion.velocity.providers.VelocityBossBarProvider;
|
||||
@ -44,10 +43,7 @@ public class VelocityViaLoader implements ViaPlatformLoader {
|
||||
providers.use(BossBarProvider.class, new VelocityBossBarProvider());
|
||||
}
|
||||
|
||||
// Allow platforms to override the version provider
|
||||
if (providers.get(VersionProvider.class) instanceof BaseVersionProvider) {
|
||||
providers.use(VersionProvider.class, new VelocityVersionProvider());
|
||||
}
|
||||
providers.use(VersionProvider.class, new VelocityVersionProvider());
|
||||
// We probably don't need a EntityIdProvider because velocity sends a Join packet on server change
|
||||
// We don't need main hand patch because Join Game packet makes client send hand data again
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren