Skip to content

Commit

Permalink
Version 1.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
EssentialGGBot committed Aug 19, 2024
1 parent 900b282 commit a60d90b
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 119 deletions.
10 changes: 2 additions & 8 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,13 @@ dependencies {

// Core Gui Libraries
val ucMcVersion = when (platform.mcVersion) {
11900, 11902, 11903, 11904, 12000, 12001, 12002, 12004, 12006, 12100 -> mcVersionStr.also {
// Elementa and Vigilance 1.18.1 are good enough for MC 1.19 so we only update UC.
// We do need to exclude the tranitive 1.18 UC though.
configurations.modApi.configure { exclude("gg.essential", "universalcraft-1.18.1-${platform.loaderStr}") }
}
11802 -> "1.18.1"
else -> mcVersionStr
}
val libMcVersion = if (platform.mcVersion >= 11802) "1.18.1" else mcVersionStr
// These versions are configured in gradle/libs.versions.toml
modApi("gg.essential:vigilance-${libMcVersion}-${mcPlatform}:${libs.versions.vigilance.get()}") { exclude(group = "org.jetbrains.kotlin") }
modApi("gg.essential:universalcraft-${ucMcVersion}-${mcPlatform}:${libs.versions.universalcraft.get()}") { exclude(group = "org.jetbrains.kotlin") }
modApi("gg.essential:elementa-${libMcVersion}-${mcPlatform}:${libs.versions.elementa.get()}") { exclude(group = "org.jetbrains.kotlin") }
modApi(libs.elementa)
modApi(libs.vigilance)

// Miscellaneous Utility Libraries
api("com.github.videogame-hacker:Koffee:88ba1b0") {
Expand Down
10 changes: 2 additions & 8 deletions build-logic/src/main/kotlin/essential/universal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,11 @@ fun Project.universalLibs() {
compileOnly("commons-codec:commons-codec:1.9")
compileOnly("org.apache.httpcomponents:httpclient:4.3.3") // TODO ideally switch to one of the libs we bundle
// These versions are configured in gradle/libs.versions.toml
compileOnly("gg.essential:vigilance-1.8.9-forge:${getVersion("vigilance")}") {
attributes { attribute(universalAttr, true) }
isTransitive = false
}
compileOnly("gg.essential:universalcraft-1.8.9-forge:${getVersion("universalcraft")}") {
attributes { attribute(universalAttr, true) }
isTransitive = false
}
compileOnly("gg.essential:elementa-1.8.9-forge:${getVersion("elementa")}") {
attributes { attribute(universalAttr, true) }
isTransitive = false
}
compileOnly(catalog.findLibrary("elementa").orElseThrow())
compileOnly(catalog.findLibrary("vigilance").orElseThrow())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private fun Project.configureForFabricLoader(configurations: Configurations, pla
.map { it.moduleVersion.id }
.forEach {
// exclude them from the bundled configuration
bundle.exclude(module = it.name) // name-only so we get the remapped one as well
bundle.exclude(group = it.group, module = it.name)
// and instead add them to loom's include configuration
dependencies {
include(group = it.group, name = it.name, version = it.version)
Expand Down
9 changes: 9 additions & 0 deletions changelog/release-1.3.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Title: World Hosting Stability Update
Summary: Improved World Hosting stability and performance

## World Hosting
- Improved time it takes to connect
- Fixed various "ICE failed" and other timeout on connect issues

## Bug Fixes
- Added support for Fabric Loader 0.16.1 and above
2 changes: 1 addition & 1 deletion features.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
always=true
new_ice_backend=0
new_ice_backend=true
updated_gifting_modal=true
updated_coins_purchase_modal=true
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ org.gradle.configureondemand=true
org.gradle.parallel.threads=128
org.gradle.jvmargs=-Xmx16G
minecraftVersion=11202
version=1.3.3.2
version=1.3.4
9 changes: 6 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
[versions]
universalcraft = "342"
elementa = "657"
vigilance = "297"
universalcraft = "362"
elementa = "665"
vigilance = "306"
mixinextras = "0.3.5"

[libraries]
universalcraft-standalone = { module = "gg.essential:universalcraft-standalone", version.ref = "universalcraft" }
elementa = { module = "gg.essential:elementa", version.ref = "elementa" }
vigilance = { module = "gg.essential:vigilance", version.ref = "vigilance" }
# This is the version shipped by MC 1.19.3, the oldest version on which we used the builtin slf4j.
# Do not change this unless you also change on which MC versions we use our relocated slf4j.
# Also note that `SELF4JServiceProviderImpl.getRequestedApiVersion` may need to be updated when this is changed.
Expand Down
2 changes: 1 addition & 1 deletion loader
24 changes: 0 additions & 24 deletions src/main/java/gg/essential/config/FeatureFlagAbUserIdProvider.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package gg.essential.mixins.transformers.client.network;

import gg.essential.Essential;
import gg.essential.config.FeatureFlags;
import gg.essential.network.connectionmanager.ice.IIceManager;
import gg.essential.network.pingproxy.ProxyPingServer;
import gg.essential.network.pingproxy.ProxyPingServerKt;
Expand Down Expand Up @@ -89,15 +88,6 @@ private static ChannelFuture injectLocalChannel(Bootstrap bootstrap, InetAddress
if (user != null) {
// ICE connection
IIceManager iceManager = Essential.getInstance().getConnectionManager().getIceManager();
boolean asyncSafe =
//#if FORGE && MC>=11400
//$$ FeatureFlags.NEW_ICE_BACKEND_ENABLED;
//#else
true;
//#endif
if (!asyncSafe) {
return bootstrap.connect(iceManager.createClientAgent(user));
}
Channel channel = bootstrap.register().syncUninterruptibly().channel();
ChannelPromise connectPromise = channel.newPromise();
Dispatchers.getIO().dispatch(EmptyCoroutineContext.INSTANCE, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
package gg.essential.network.connectionmanager;

import gg.essential.config.FeatureFlags;
import gg.essential.connectionmanager.common.packet.Packet;
import gg.essential.connectionmanager.common.packet.connection.*;
import gg.essential.connectionmanager.common.packet.multiplayer.ServerMultiplayerJoinServerPacket;
Expand All @@ -29,7 +28,6 @@
import gg.essential.network.connectionmanager.handler.mojang.ServerUuidNameMapPacketHandler;
import gg.essential.network.connectionmanager.handler.multiplayer.ServerMultiplayerJoinServerPacketHandler;
import gg.essential.network.connectionmanager.ice.IIceManager;
import gg.essential.network.connectionmanager.ice.IceManager;
import gg.essential.network.connectionmanager.ice.IceManagerMcImpl;
import gg.essential.network.connectionmanager.media.ScreenshotManager;
import gg.essential.network.connectionmanager.notices.NoticesManager;
Expand Down Expand Up @@ -162,13 +160,7 @@ public ConnectionManager(@NotNull final MinecraftHook minecraftHook, File baseDi
this.managers.add(this.socialManager = new SocialManager(this));

// Ice
if (FeatureFlags.NEW_ICE_BACKEND_ENABLED) {
this.iceManager = new IceManagerMcImpl(this, baseDir.toPath(), uuid -> this.spsManager.getInvitedUsers().contains(uuid));
} else {
IceManager iceManagerImpl = new IceManager(this, this.spsManager);
this.managers.add(iceManagerImpl);
this.iceManager = iceManagerImpl;
}
this.iceManager = new IceManagerMcImpl(this, baseDir.toPath(), uuid -> this.spsManager.getInvitedUsers().contains(uuid));

//Screenshots
this.managers.add(this.screenshotManager = new ScreenshotManager(this, baseDir, lwjgl3));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/essential/commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5372d82914
ffe87e84d7
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;

/**
* A class loader which strongly prefers loading its own instance of a class rather than using the one from its parent.
Expand All @@ -50,6 +51,8 @@ public class IsolatedClassLoader extends URLClassLoader {

private final Map<String, Class<?>> classes = new ConcurrentHashMap<>();

private Predicate<String> resourceFilter;

/**
* The conceptual (but not actual) parent of this class loader.
* <p>
Expand All @@ -73,6 +76,14 @@ public void addClassExclusion(String className) {
this.classExclusions.add(className);
}

/**
* Sets a resource filter. Resources that match this filter will exclusively be loaded
* from this classloader, and will not be delegated to the parent.
*/
public void setResourceFilter(Predicate<String> resourceFilter) {
this.resourceFilter = resourceFilter;
}

@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
// Fast path
Expand Down Expand Up @@ -146,11 +157,19 @@ public URL getResource(String name) {
return url;
}

if (resourceFilter != null && resourceFilter.test(name)) {
return null;
}

return delegateParent.getResource(name);
}

@Override
public Enumeration<URL> getResources(String name) throws IOException {
if (resourceFilter != null && resourceFilter.test(name)) {
return super.getResources(name);
}

return Iterators.asEnumeration(Iterators.concat(
Iterators.forEnumeration(super.getResources(name)),
Iterators.forEnumeration(delegateParent.getResources(name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Supplier;

/**
* Various feature flags which control the behavior of Essential.<br>
Expand All @@ -47,55 +41,9 @@ public class FeatureFlags {

private static final Logger LOGGER = LogManager.getLogger("Essential Logger");

// Dropping Ice4J in favor of less buggy homebrew ICE implementation
public static final String NEW_ICE_BACKEND = "NEW_ICE_BACKEND";
public static final boolean NEW_ICE_BACKEND_ENABLED = property(NEW_ICE_BACKEND, abTesting(NEW_ICE_BACKEND, 0));


// Add any features here that should be displayed in the FeaturesEnabledModal
public static final Map<String, Pair<String, Boolean>> abTestingFlags = new HashMap<>();


private static boolean property(String featureName, boolean defaultValue) {
boolean result = defaultValue;
String str = System.getProperty("essential.feature." + featureName.toLowerCase(Locale.ROOT));
if (str != null) {
result = Boolean.parseBoolean(str);
LOGGER.warn("Explicitly {} feature flags \"{}\".", result ? "enabled" : "disabled", featureName);
}
return result;
}

@SuppressWarnings("unused") // used at build time depending on configuration
private static boolean abTesting(String featureName, int enabledPercentage) {
// To decide which group this user belongs to, we combine their UUID with the feature name, hash it, treat the
// result as an integer and modulo it by 100, at which point we can directly compare it to the percentage.
// This allows us to get an effectively random choice (sha1 results are uniformly distributed) that's the same
// every time (as long as it's the same user) even if we add/remove or re-order the feature flags.
// Additionally, given the algorithm does not depend on the percentage, even when we change how many people are
// in each group, it does not flip for more people than strictly necessary.
Supplier<String> userIdSupplier;
try {
Class<?> cls = Class.forName("gg.essential.config.FeatureFlagAbUserIdProvider");
//noinspection unchecked
userIdSupplier = (Supplier<String>) cls.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
String userId = userIdSupplier.get();
String combinedId = featureName + ":" + userId;
byte[] combinedHash;
try {
combinedHash = MessageDigest.getInstance("SHA-1").digest(combinedId.getBytes(StandardCharsets.UTF_8));
} catch (NoSuchAlgorithmException var2) {
throw new RuntimeException(var2);
}
int userValue = new BigInteger(combinedHash).mod(BigInteger.valueOf(100)).intValue();
boolean enabled = userValue < enabledPercentage;
if (enabled) {
LOGGER.info("Rolled a {}, enabling feature flag \"{}\".", userValue, featureName);
}
return enabled;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ private static URL findExtractedBundleJar() {

loader.addClassExclusion(QuicBackend.class.getName());
loader.addClassExclusion(QuicListener.class.getName());

// Netty's NativeLibraryLoader will throw an error if multiple resources for the same native are found on the
// classpath. This is the case with mods such as e4mc and Luna, which include netty-incubator-codec-quic
// without relocating it or loading it in an isolated classloader. We can fix this by only loading natives
// from our classloader, and not allowing delegation to the parent.
loader.setResourceFilter(name -> name.startsWith("META-INF/native/"));
}

public QuicBackend createImpl(Logger logger, QuicListener listener) {
Expand Down

0 comments on commit a60d90b

Please sign in to comment.