package info.u_team.u_team_core.intern.discord;

import info.u_team.u_team_core.UCoreMod;
import info.u_team.u_team_core.intern.discord.DiscordRichPresence.*;
import info.u_team.u_team_core.intern.init.UCoreNetwork;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.gui.screen.*;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.eventbus.api.*;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;

@EventBusSubscriber(modid = UCoreMod.MODID, value = Dist.CLIENT)
public class UpdateDiscordEventHandler {
	
	@SubscribeEvent
	public static void on(InitGuiEvent.Pre event) {
		if (!DiscordRichPresence.isEnabled()) {
			return;
		}
		if (event.getGui() instanceof MainMenuScreen || event.getGui() instanceof WorldSelectionScreen || event.getGui() instanceof MultiplayerScreen) {
			final State state = DiscordRichPresence.getCurrent();
			if (state == null || state.getState() != EnumState.MENU) {
				DiscordRichPresence.setIdling();
			}
		}
	}
	
	@SubscribeEvent
	public static void on(EntityJoinWorldEvent event) {
		if (!DiscordRichPresence.isEnabled()) {
			return;
		}
		if (event.getEntity() instanceof ClientPlayerEntity) {
			final ClientPlayerEntity player = (ClientPlayerEntity) event.getEntity();
			if (player.getUniqueID().equals(Minecraft.getInstance().player.getUniqueID())) {
				DiscordRichPresence.setDimension(player.getEntityWorld());
			}
		}
	}
	
	public static void registerMod(IEventBus bus) {
	}
	
	public static void registerForge(IEventBus bus) {
	}
}

@@ -125,37 +125,27 @@
 ern.
-discord.DiscordRichPresence.*
+config.ClientConfig
 ;%0Aim
@@ -184,25 +184,37 @@
 ern.
-init.UCoreNetwork
+discord.DiscordRichPresence.*
 ;%0Aim
@@ -632,16 +632,83 @@
 scriber;
+%0Aimport net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 %0A%0A@Event
@@ -1677,54 +1677,266 @@
 %09%0A%09p
-ublic static void registerMod(IEventBus bus) %7B
+rivate static void setup(FMLClientSetupEvent event) %7B%0A%09%09if (ClientConfig.getInstance().discordRichPresence.get()) %7B%0A%09%09%09DiscordRichPresence.start();%0A%09%09%7D%0A%09%7D%0A%09%0A%09public static void registerMod(IEventBus bus) %7B%0A%09%09bus.addListener(UpdateDiscordEventHandler::setup);
 %0A%09%7D%0A

Call the discord richpresence start code now in the event handler