Skip to content

Commit 9719d61

Browse files
committed
Add config options: openDebugPort, smartDebuggerSneakScroll
1 parent 1555f82 commit 9719d61

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

Common/src/main/java/gay/object/hexdebug/mixin/MixinShiftScrollListener.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package gay.object.hexdebug.mixin;
22

33
import at.petrak.hexcasting.client.ShiftScrollListener;
4-
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
5-
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
4+
import gay.object.hexdebug.config.HexDebugConfig;
65
import gay.object.hexdebug.items.ItemDebugger;
76
import gay.object.hexdebug.registry.HexDebugItems;
87
import net.minecraft.client.Minecraft;
98
import net.minecraft.world.item.Item;
109
import org.jetbrains.annotations.Contract;
1110
import org.spongepowered.asm.mixin.Mixin;
1211
import org.spongepowered.asm.mixin.Shadow;
13-
import org.spongepowered.asm.mixin.gen.Accessor;
1412
import org.spongepowered.asm.mixin.gen.Invoker;
1513
import org.spongepowered.asm.mixin.injection.At;
1614
import org.spongepowered.asm.mixin.injection.Inject;
@@ -45,6 +43,7 @@ public abstract class MixinShiftScrollListener {
4543
&& (player.isShiftKeyDown() || !needsSneaking)
4644
&& !player.isSpectator()
4745
// additional logic
46+
&& HexDebugConfig.INSTANCE.get().getClient().getSmartDebuggerSneakScroll()
4847
&& !ItemDebugger.isDebugging()
4948
&& player.getMainHandItem().getItem() == HexDebugItems.DEBUGGER.getValue()
5049
&& hexdebug$invokeIsScrollableItem(player.getOffhandItem().getItem())

Common/src/main/kotlin/gay/object/hexdebug/adapter/proxy/DebugProxyClient.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ data class DebugProxyClient(val input: InputStream, val output: OutputStream) {
4141
var instance: DebugProxyClient? = null
4242
private set
4343

44+
private val enabled get() = HexDebugConfig.get().client.openDebugPort
4445
private val port get() = HexDebugConfig.get().client.debugPort
4546

4647
private val executorService = Executors.newCachedThreadPool()
@@ -96,6 +97,9 @@ data class DebugProxyClient(val input: InputStream, val output: OutputStream) {
9697
}
9798

9899
private suspend fun runServer(selector: SelectorManager) {
100+
if (!enabled) {
101+
awaitCancellation()
102+
}
99103
HexDebug.LOGGER.info("Listening for debug client on port {}...", port)
100104
aSocket(selector).tcp().bind(port = port).use { serverSocket ->
101105
while (true) {

Common/src/main/kotlin/gay/object/hexdebug/config/HexDebugConfig.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import me.shedaniel.autoconfig.AutoConfig
55
import me.shedaniel.autoconfig.ConfigData
66
import me.shedaniel.autoconfig.annotation.Config
77
import me.shedaniel.autoconfig.annotation.ConfigEntry.Category
8+
import me.shedaniel.autoconfig.annotation.ConfigEntry.Gui.Tooltip
89
import me.shedaniel.autoconfig.annotation.ConfigEntry.Gui.TransitiveObject
910
import me.shedaniel.autoconfig.serializer.PartitioningSerializer
1011
import me.shedaniel.autoconfig.serializer.PartitioningSerializer.GlobalData
@@ -37,6 +38,13 @@ object HexDebugConfig {
3738

3839
@Config(name = "client")
3940
class Client : ConfigData {
41+
@Tooltip
42+
val openDebugPort: Boolean = true
43+
44+
@Tooltip
4045
val debugPort: Int = 4444
46+
47+
@Tooltip
48+
val smartDebuggerSneakScroll: Boolean = true
4149
}
4250
}

Common/src/main/resources/assets/hexdebug/lang/en_us.flatten.json5

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,18 @@
2020
},
2121
option: {
2222
client: {
23-
debugPort: "Debug Port",
23+
openDebugPort: {
24+
"": "Open Debug Port",
25+
"@Tooltip": "Whether or not a port should be opened. If false, the Debugger effectively becomes useless.",
26+
},
27+
debugPort: {
28+
"": "Debug Port",
29+
"@Tooltip": "Port number (1024-65535) to open for the debug client (eg. VSCode) to connect to.",
30+
},
31+
smartDebuggerSneakScroll: {
32+
"": "Smart Debugger Sneak-Scroll",
33+
"@Tooltip": "If a hex is not currently being debugged and a Debugger is in your main hand, prefer shift-scrolling whatever item is in your offhand (eg. a spellbook).",
34+
},
2435
},
2536
},
2637
},

0 commit comments

Comments
 (0)