Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Commit

Permalink
let me do this rq
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Sep 1, 2021
1 parent e1401f9 commit f84b6df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/main/kotlin/net/wyvest/simplerpc/SimpleRPC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import net.minecraftforge.common.MinecraftForge.EVENT_BUS
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import net.minecraftforge.fml.common.network.FMLNetworkEvent
Expand Down Expand Up @@ -100,6 +99,7 @@ object SimpleRPC {
@Mod.EventHandler
fun onFMLInitialization(event: FMLInitializationEvent) {
RPCConfig.preload()
RPCConfig.lastToggled = RPCConfig.toggled
SimpleRPCCommand.register()
Updater.update()
EVENT_BUS.register(this)
Expand All @@ -113,7 +113,6 @@ object SimpleRPC {
}
startTimestamp = startTime
}

ipc.connect()
timer.start()
}
Expand Down
21 changes: 7 additions & 14 deletions src/main/kotlin/net/wyvest/simplerpc/config/RPCConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ import net.wyvest.simplerpc.SimpleRPC.mc
import net.wyvest.simplerpc.gui.DownloadConfirmGui
import net.wyvest.simplerpc.utils.Updater
import java.io.File
import kotlin.properties.Delegates

@Suppress("unused")
object RPCConfig : Vigilant(File(SimpleRPC.modDir, "${SimpleRPC.ID}.toml"), NAME) {

var lastToggled by Delegates.notNull<Boolean>()

@Property(
type = PropertyType.SWITCH,
name = "Toggle Mod",
description = "Toggle the mod.\nCan be buggy and sometimes needs a restart to take effect.",
description = "Toggle the mod.\nRequires a restart to take effect.",
category = "General"
)
var toggled = true
Expand Down Expand Up @@ -94,20 +97,10 @@ object RPCConfig : Vigilant(File(SimpleRPC.modDir, "${SimpleRPC.ID}.toml"), NAME
init {
initialize()
registerListener("toggled") {
isToggled: Boolean ->
toggled: Boolean ->
run {
if (isToggled) {
try {
SimpleRPC.ipc.connect()
} catch (e: Exception) {
EssentialAPI.getNotifications().push("SimpleRPC", "There was an error trying to reconnect to the IPC. Please restart your game for your changes to take effect.")
}
} else {
try {
SimpleRPC.ipc.disconnect()
} catch (e: Exception) {
EssentialAPI.getNotifications().push("SimpleRPC", "There was an error trying to disconnect to the IPC. Please restart your game for your changes to take effect.")
}
if (toggled != lastToggled) {
EssentialAPI.getNotifications().push("SimpleRPC", "Successfully toggled. Please restart your game for it to take effect.")
}
}
}
Expand Down

0 comments on commit f84b6df

Please sign in to comment.