remove annoying updates in chat (RIPBOZO)

This commit is contained in:
FalsePattern committed 2023-01-19 20:04:44 +01:00
1 parent 6edb48be51
commit 4ef06d87b0
2 files changed
+1 -38

No files matched your search

@@ -20,23 +20,15 @@
*/
package com.falsepattern.lib.internal.proxy;
import com.falsepattern.lib.internal.Share;
import com.falsepattern.lib.internal.Tags;
import com.falsepattern.lib.internal.impl.config.event.ClientEventHandlerPost;
import com.falsepattern.lib.internal.impl.config.event.ClientEventHandlerPre;
import com.falsepattern.lib.internal.impl.toast.GuiToastImpl;
import com.falsepattern.lib.updates.UpdateChecker;
import lombok.val;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import cpw.mods.fml.common.event.FMLConstructionEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -46,8 +38,6 @@ import java.util.concurrent.CompletableFuture;
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy {
private CompletableFuture<List<IChatComponent>> chatFuture;
@Override
public void construct(FMLConstructionEvent e) {
super.construct(e);
@@ -65,27 +55,5 @@ public class ClientProxy extends CommonProxy {
public void postInit(FMLPostInitializationEvent e) {
super.postInit(e);
ClientEventHandlerPost.registerBus();
chatFuture = updatesFuture.handleAsync((updates, exception) -> {
if (exception != null || updates.isEmpty()) {
return Collections.emptyList();
}
return UpdateChecker.updateListToChatMessages(Tags.MODNAME, updates);
});
}
@SubscribeEvent
public void onSinglePlayer(EntityJoinWorldEvent e) {
if (chatFuture == null || !(e.entity instanceof EntityPlayerSP)) {
return;
}
val player = (EntityPlayerSP) e.entity;
try {
for (val line : chatFuture.get()) {
player.addChatMessage(line);
}
chatFuture = null;
} catch (Exception ex) {
Share.LOG.warn(ex);
}
}
}