Skip to content

Commit

Permalink
Version 1.3.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
EssentialGGBot committed May 15, 2024
1 parent d362a50 commit 972b97a
Show file tree
Hide file tree
Showing 57 changed files with 450 additions and 302 deletions.
5 changes: 3 additions & 2 deletions api/src/main/kotlin/gg/essential/api/commands/Command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
package gg.essential.api.commands

import gg.essential.api.EssentialAPI
import gg.essential.api.utils.Multithreading
import gg.essential.api.utils.SerialExecutor
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.asExecutor
import java.lang.reflect.Method
import java.lang.reflect.Parameter
import java.util.*
Expand Down Expand Up @@ -123,7 +124,7 @@ abstract class Command @JvmOverloads constructor(

private companion object {
/** Warms the cache. One task at a time as to not flood the pool; concurrency won't help much anyway. */
private val cacheCooker = SerialExecutor(Multithreading.scheduledPool)
private val cacheCooker = SerialExecutor(Dispatchers.IO.asExecutor())
}
}
}
4 changes: 2 additions & 2 deletions api/src/main/kotlin/gg/essential/api/utils/Multithreading.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Multithreading {

@JvmStatic
val scheduledPool: ScheduledExecutorService = Executors.newScheduledThreadPool(10) { target: Runnable? ->
Thread(target, "Essential Thread " + counter.incrementAndGet())
Thread(target, "Thread " + counter.incrementAndGet())
}

@JvmStatic
Expand All @@ -33,7 +33,7 @@ object Multithreading {
10, 30,
0L, TimeUnit.SECONDS,
LinkedBlockingQueue()
) { target: Runnable? -> Thread(target, "Essential ${counter.incrementAndGet()}") }
) { target: Runnable? -> Thread(target, "Thread ${counter.incrementAndGet()}") }

fun schedule(r: Runnable, initialDelay: Long, delay: Long, unit: TimeUnit): ScheduledFuture<*> {
return scheduledPool.scheduleAtFixedRate(r, initialDelay, delay, unit)
Expand Down
2 changes: 1 addition & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
implementation(gradleApi())
implementation(localGroovy())

val kotlinCompilerVersion = "1.9.23" // FIXME when kotlin 1.9.24 is available
val kotlinCompilerVersion = "1.9.24"

implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinCompilerVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinCompilerVersion")
Expand Down
10 changes: 10 additions & 0 deletions changelog/release-1.3.2.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Title: Bug Patch
Summary: Minor bug fixes

## Bug Fixes
- Fixed message channels not moving to the top of the list after sending a message
- Fixed skins failing to load in the Wardrobe under certain conditions
- Fixed Gift Received notification

## Compatibility
- Fixed game crashing with OptiFine on 1.20.4
4 changes: 3 additions & 1 deletion cosmetics/src/commonMain/kotlin/gg/essential/mod/Skin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ data class Skin(

companion object {

const val SKIN_URL = "https://textures.minecraft.net/texture/%s"
// EM-2483: Minecraft uses http for skin textures and using https causes issues due to missing CA certs on outdated java versions.
@Suppress("HttpUrlsUsage")
const val SKIN_URL = "http://textures.minecraft.net/texture/%s"

@JvmStatic
fun fromUrl(url: String, model: Model) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ModelInstance(
val animationTargets: Set<AnimationTarget>,
val onAnimation: (String) -> Unit,
) {
val locator = WearableLocator(entity.locator)
var locator = WearableLocator(entity.locator)
var animationState = ModelAnimationState(entity, locator)
var textureAnimationSync = TextureAnimationSync(model.textureFrameCount)
var essentialAnimationSystem = EssentialAnimationSystem(model, entity, animationState, textureAnimationSync, animationTargets, onAnimation)
Expand All @@ -43,6 +43,8 @@ class ModelInstance(
textureAnimationSync = TextureAnimationSync(model.textureFrameCount)
}
if (newAnimations) {
locator.isValid = false
locator = WearableLocator(entity.locator)
animationState = ModelAnimationState(entity, locator)
}
if (newAnimations || newTextureAnimation) {
Expand Down
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.2.3+g6a2d13e09b
version=1.3.2.4+g6b55293e12
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ abstract class AbstractTextInput(
copySelection()
deleteSelection()
} else if (UKeyboard.isKeyComboCtrlV(keyCode)) {
commitTextAddition(UDesktop.getClipboardString())
val filteredClipboardString = UDesktop.getClipboardString().filter { isAllowedCharacter(it) }
if (filteredClipboardString.isNotBlank()) {
commitTextAddition(filteredClipboardString)
}
} else if (UKeyboard.isKeyComboCtrlZ(keyCode)) {
undoLastOperation()
} else if (UKeyboard.isKeyComboCtrlShiftZ(keyCode) || UKeyboard.isKeyComboCtrlY(keyCode)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private static class DynamicTextureManager implements RemovalListener<MaskedSkin
private final Cache<MaskedSkinProvider, ResourceLocation> loaded = Caffeine.newBuilder()
.expireAfterAccess(1, TimeUnit.MINUTES)
.executor(Multithreading.POOL)
.scheduler(Scheduler.forScheduledExecutorService(gg.essential.api.utils.Multithreading.getScheduledPool()))
.scheduler(Scheduler.forScheduledExecutorService(Multithreading.getScheduledPool()))
.removalListener(this)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ private void initEssentialGui(CallbackInfo ci) {
);
}

@Inject(method = "refreshServerList", at = @At("HEAD"))
private void essential$markRefresh(CallbackInfo ci) {
EssentialMultiplayerGui.Companion.setRefreshing(true);
}

//#if MC < 11200
//$$ private GuiButton addButton(GuiButton button) {
//$$ this.buttonList.add(button);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ public abstract class Mixin_RenderParticleSystemOfClientWorld {

@Group(name = "render_particles", min = 1, max = 1)
@Inject(
method = RENDER_PARTICLES,
method = {
RENDER_PARTICLES,
//#if MC>=12004 && FORGE
//$$ // OptiFine 1.20.4 uses the pre-1.17 method name
//$$ "renderParticles",
//#endif
},
//#if MC>=12005
//$$ at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;depthMask(Z)V")
//#elseif MC>=11700
Expand Down Expand Up @@ -174,7 +180,8 @@ public abstract class Mixin_RenderParticleSystemOfClientWorld {
//$$ @Inject(
//$$ // These are forge names, we mustn't try to remap them using fabric mappings (luckily the yarn class names are the same across versions)
//#disable-remap
//#if MC>=11700
//$$ // OptiFine 1.20.4 uses the pre-1.17 method name
//#if MC>=11700 && MC<12004
//$$ method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/render/LightmapTextureManager;Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/render/Frustum;)V",
//#else
//$$ method = "renderParticles(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;Lnet/minecraft/client/render/LightmapTextureManager;Lnet/minecraft/client/render/Camera;FLnet/minecraft/client/render/Frustum;)V",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import com.google.common.primitives.Bytes;
import gg.essential.Essential;
import gg.essential.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.Packet;
import gg.essential.connectionmanager.common.packet.connection.ConnectionKeepAlivePacket;
import gg.essential.handlers.CertChain;
Expand All @@ -22,6 +21,7 @@
import gg.essential.network.connectionmanager.legacyjre.LegacyJreDnsResolver;
import gg.essential.network.connectionmanager.legacyjre.LegacyJreSocketFactory;
import gg.essential.util.LimitedExecutor;
import gg.essential.util.Multithreading;
import kotlin.Lazy;
import kotlin.LazyKt;
import org.java_websocket.client.DnsResolver;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void send(@NotNull final Packet packet) {
final Packet fakeReplyPacket = packet.getFakeReplyPacket();
if (fakeReplyPacket != null) {
fakeReplyPacket.setUniqueId(packet.getPacketUniqueId());
Multithreading.schedule(() -> onMessage(fakeReplyPacket), packet.getFakeReplyDelayMs(), TimeUnit.MILLISECONDS);
Multithreading.scheduleOnBackgroundThread(() -> onMessage(fakeReplyPacket), packet.getFakeReplyDelayMs(), TimeUnit.MILLISECONDS);
return;
}

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.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.Packet;
import gg.essential.connectionmanager.common.packet.connection.*;
import gg.essential.connectionmanager.common.packet.multiplayer.ServerMultiplayerJoinServerPacket;
Expand Down Expand Up @@ -40,6 +39,7 @@
import gg.essential.network.connectionmanager.subscription.SubscriptionManager;
import gg.essential.network.connectionmanager.telemetry.TelemetryManager;
import gg.essential.util.ModLoaderUtil;
import gg.essential.util.Multithreading;
import gg.essential.util.lwjgl3.Lwjgl3Loader;
import kotlin.collections.MapsKt;
import me.kbrewster.eventbus.Subscribe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import gg.essential.network.cosmetics.Cosmetic;
import gg.essential.network.cosmetics.cape.CapeCosmeticsManager;
import gg.essential.universal.UMinecraft;
import gg.essential.util.ExtensionsKt;
import gg.essential.util.GuiUtil;
import gg.essential.util.Multithreading;
import kotlin.Pair;
Expand Down Expand Up @@ -346,13 +345,12 @@ public void populateEmoteWheels(List<gg.essential.cosmetics.model.EmoteWheel> em
public void flushSelectedEmoteWheel(boolean debounce) {
int taskId = ++currentFlushEmoteWheelTaskId;
if (debounce) {
Multithreading.schedule(
() -> ExtensionsKt.getExecutor(Minecraft.getMinecraft()).execute(() -> {
if (taskId != currentFlushEmoteWheelTaskId) {
return;
}
flushSelectedEmoteWheel(false);
}), 3, TimeUnit.SECONDS);
Multithreading.scheduleOnMainThread(() -> {
if (taskId != currentFlushEmoteWheelTaskId) {
return;
}
flushSelectedEmoteWheel(false);
}, 3, TimeUnit.SECONDS);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package gg.essential.network.connectionmanager.cosmetics;

import com.google.common.collect.Maps;
import gg.essential.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.Packet;
import gg.essential.lib.caffeine.cache.Cache;
import gg.essential.lib.caffeine.cache.Caffeine;
Expand All @@ -25,6 +24,7 @@
import gg.essential.network.connectionmanager.handler.PacketHandler;
import gg.essential.universal.UMinecraft;
import gg.essential.util.ExtensionsKt;
import gg.essential.util.Multithreading;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,28 @@
*/
package gg.essential.network.connectionmanager.handler.multiplayer;

import gg.essential.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.multiplayer.ServerMultiplayerJoinServerPacket;
import gg.essential.network.connectionmanager.ConnectionManager;
import gg.essential.network.connectionmanager.handler.PacketHandler;
import gg.essential.universal.UMinecraft;
import gg.essential.util.MinecraftUtils;
import gg.essential.util.Multithreading;
import net.minecraft.client.multiplayer.ServerData;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

public class ServerMultiplayerJoinServerPacketHandler extends PacketHandler<ServerMultiplayerJoinServerPacket> {
private final Set<String> cooldowns = Collections.newSetFromMap(new ConcurrentHashMap<>());
private final Set<String> cooldowns = new HashSet<>();

@Override
protected void onHandle(@NotNull final ConnectionManager connectionManager, @NotNull final ServerMultiplayerJoinServerPacket packet) {
String serverIP = packet.getAddress();
if (cooldowns.contains(serverIP)) return;
cooldowns.add(serverIP);
Multithreading.schedule(() -> cooldowns.remove(serverIP), 7, TimeUnit.SECONDS);
Multithreading.scheduleOnMainThread(() -> cooldowns.remove(serverIP), 7, TimeUnit.SECONDS);
//#if MC>=11602
//$$ UMinecraft.getMinecraft().execute(() -> {
//#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package gg.essential.network.connectionmanager.ice;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import gg.essential.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.ice.IceCandidatePacket;
import gg.essential.connectionmanager.common.packet.ice.IceSessionPacket;
import gg.essential.gui.modals.FirewallBlockingModal;
Expand All @@ -35,6 +34,7 @@
import gg.essential.sps.quic.jvm.ForkedJvmServerQuicStreamPool;
import gg.essential.universal.UMinecraft;
import gg.essential.util.GuiUtil;
import gg.essential.util.Multithreading;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
Expand Down Expand Up @@ -678,7 +678,7 @@ private static CompletableFuture<Void> createReadyFuture(Agent agent, boolean cl
CompletableFuture<Void> future = new CompletableFuture<>();

// We only want to wait so long (the agent itself doesn't necessarily fail if it never fully starts)
Multithreading.schedule(() -> future.completeExceptionally(new IceFailedException(client)), ICE_TIMEOUT, TimeUnit.SECONDS);
Multithreading.scheduleOnBackgroundThread(() -> future.completeExceptionally(new IceFailedException(client)), ICE_TIMEOUT, TimeUnit.SECONDS);

Runnable update = () -> {
IceProcessingState state = agent.getState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
package gg.essential.network.connectionmanager.ice;

import gg.essential.api.utils.Multithreading;
import gg.essential.mixins.impl.feature.ice.common.AgentExt;
import gg.essential.mixins.impl.feature.ice.common.rtt.CandidatePairExt;
import gg.essential.util.Multithreading;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.ice4j.ice.Agent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,14 @@ public void handleNewScreenshot(File imgFile, ClientScreenshotMetadata metadata,
callScreenshotCollectionChangeHandlers(new ScreenshotCollectionChangeEvent(true, Collections.emptySet()));

int currentId = ++latestScreenshotActionId;
Multithreading.schedule(
() -> ExtensionsKt.getExecutor(Minecraft.getMinecraft()).execute(() -> {
Multithreading.scheduleOnMainThread(
() -> {
if (currentId != latestScreenshotActionId) {
return;
}

PostScreenshotAction.current().run(imgFile);
}),
},
// We want to run the post-screenshot action with a short delay after the screenshot has been taken.
// If another screenshot was taken in this time-span, we cancel the original scheduled runnable and
// create a new one for the latest screenshot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import com.google.common.collect.Maps;
import gg.essential.Essential;
import gg.essential.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.Packet;
import gg.essential.connectionmanager.common.packet.notices.ClientNoticeDismissPacket;
import gg.essential.connectionmanager.common.packet.notices.ClientNoticeRequestPacket;
Expand All @@ -30,9 +29,8 @@
import gg.essential.network.cosmetics.Cosmetic;
import gg.essential.notices.NoticeType;
import gg.essential.notices.model.Notice;
import gg.essential.util.ExtensionsKt;
import gg.essential.util.Multithreading;
import kotlin.collections.SetsKt;
import net.minecraft.client.Minecraft;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -364,13 +362,13 @@ private void scheduleUpdate() {
Optional<Sale> first = salesMap.values().stream().min(Comparator.comparing(Sale::getExpiration));
if (first.isPresent()) {
final Sale sale = first.get();
nextUpdateFuture = Multithreading.schedule(() -> ExtensionsKt.getExecutor(Minecraft.getMinecraft()).execute(() -> {
nextUpdateFuture = Multithreading.scheduleOnMainThread(() -> {
final Instant now = Instant.now();

if (salesMap.entrySet().removeIf(entry -> entry.getValue().getExpiration().isBefore(now))) {
refreshState();
}
}), Instant.now().until(sale.getExpiration(), ChronoUnit.MILLIS) + 1000, TimeUnit.MILLISECONDS);
}, Instant.now().until(sale.getExpiration(), ChronoUnit.MILLIS) + 1000, TimeUnit.MILLISECONDS);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.google.common.collect.Maps;
import com.sparkuniverse.toolbox.chat.enums.ChannelType;
import com.sparkuniverse.toolbox.chat.model.Channel;
import gg.essential.api.utils.Multithreading;
import gg.essential.config.EssentialConfig;
import gg.essential.connectionmanager.common.enums.ActivityType;
import gg.essential.connectionmanager.common.enums.ProfileStatus;
Expand Down Expand Up @@ -51,6 +50,7 @@
import gg.essential.profiles.model.TrustedHost;
import gg.essential.util.CachedAvatarImage;
import gg.essential.util.GuiUtil;
import gg.essential.util.Multithreading;
import gg.essential.util.StringsKt;
import gg.essential.util.UUIDUtil;
import gg.essential.util.WebUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
*/
package gg.essential.network.connectionmanager.queue;

import gg.essential.api.utils.Multithreading;
import gg.essential.connectionmanager.common.packet.Packet;
import gg.essential.network.connectionmanager.ConnectionManager;
import gg.essential.util.Multithreading;
import kotlin.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Loading

0 comments on commit 972b97a

Please sign in to comment.