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);
}
}
}
@@ -45,9 +45,6 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
public class CommonProxy {
protected CompletableFuture<List<ModUpdateInfo>> updatesFuture;
public void construct(FMLConstructionEvent e) {
FalsePatternLib.NETWORK.registerMessage(SyncRequestHandler.class, SyncRequest.class, 0, Side.SERVER);
FalsePatternLib.NETWORK.registerMessage(SyncReplyHandler.class, SyncReply.class, 1, Side.CLIENT);
@@ -58,7 +55,7 @@ public class CommonProxy {
CommonEventHandlerPre.registerBus();
if (LibraryConfig.ENABLE_UPDATE_CHECKER) {
Share.LOG.info("Launching asynchronous update check.");
updatesFuture = UpdateChecker.fetchUpdatesAsyncV2(FalsePatternLib.UPDATE_URL).thenApplyAsync(updates -> {
UpdateChecker.fetchUpdatesAsyncV2(FalsePatternLib.UPDATE_URL).thenApplyAsync(updates -> {
if (updates == null) {
updates = Collections.emptyList();
}
@@ -75,8 +72,6 @@ public class CommonProxy {
Share.LOG.error("Failed to check for updates!", ex);
return Collections.emptyList();
});
} else {
updatesFuture = CompletableFuture.completedFuture(Collections.emptyList());
}
}