Skip to content

Commit 4dcb85d

Browse files
committed
fixed pb config issue (dumb issue) only compatible with beta 16 actions
1 parent e8a2497 commit 4dcb85d

File tree

13 files changed

+140
-167
lines changed

13 files changed

+140
-167
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ blossom {
3131
}
3232

3333
tasks.register("downloadOdin") {
34-
val downloadUrl = "https://github.com/odtheking/Odin/releases/download/${requiredOdinVersion}/${requiredOdin}"
34+
val downloadUrl = "https://github.com/SubAt0m1c/Odin/releases/download/${requiredOdinVersion}/${requiredOdin}"
3535
val targetFile = file("build/resources/Odin")
3636

3737
doLast {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ baseGroup = com.github.subat0m1c.hatecheaters
44
mcVersion = 1.8.9
55
modid = hatecheaters
66
version = 0.1.1
7-
requiredOdin = Odin-1.2.5.beta14.jar
7+
requiredOdin = Odin-1.2.5.beta16.jar
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.github.subat0m1c.hatecheaters.mixin;
2+
3+
import com.github.subat0m1c.hatecheaters.HateCheaters;
4+
import me.odinmain.OdinMain;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
9+
10+
@Mixin(OdinMain.class)
11+
public class MixinOdinMain {
12+
13+
@Inject(method = "loadComplete", at = @At("RETURN"), remap = false)
14+
public void loadComplete(CallbackInfo ci) {
15+
HateCheaters.Companion.onOdinLoad();
16+
}
17+
}

src/main/kotlin/com/github/subat0m1c/hatecheaters/HateCheaters.kt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
package com.github.subat0m1c.hatecheaters
22

3-
import com.github.subat0m1c.hatecheaters.commands.impl.*
4-
import com.github.subat0m1c.hatecheaters.commands.registerCommands
3+
import com.github.subat0m1c.hatecheaters.commands.impl.PVCommand
54
import com.github.subat0m1c.hatecheaters.modules.BetterPartyFinder
65
import com.github.subat0m1c.hatecheaters.modules.ClearSecrets
76
import com.github.subat0m1c.hatecheaters.modules.HateCheatersModule
87
import com.github.subat0m1c.hatecheaters.modules.ProfileViewer
8+
import com.github.subat0m1c.hatecheaters.modules.ProfileViewer.pvCommand
99
import com.github.subat0m1c.hatecheaters.utils.LogHandler
1010
import com.github.subat0m1c.hatecheaters.utils.LogHandler.Logger
1111
import com.github.subat0m1c.hatecheaters.utils.OdinCheck.checkIfOdinIsLoaded
1212
import kotlinx.coroutines.*
1313
import me.odinmain.OdinMain.mc
14+
import com.github.subat0m1c.hatecheaters.commands.CommandRegistry
1415
import me.odinmain.features.ModuleManager
1516
import net.minecraft.client.gui.GuiScreen
1617
import net.minecraftforge.common.MinecraftForge
1718
import net.minecraftforge.fml.common.Mod
1819
import net.minecraftforge.fml.common.event.FMLInitializationEvent
20+
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent
1921
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
2022
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
2123
import kotlin.coroutines.CoroutineContext
@@ -26,17 +28,8 @@ class HateCheaters {
2628
@Mod.EventHandler
2729
fun init(event: FMLInitializationEvent) {
2830
LogHandler
29-
3031
checkIfOdinIsLoaded()
3132

32-
ModuleManager.addModules(
33-
BetterPartyFinder, HateCheatersModule, ProfileViewer, ClearSecrets
34-
)
35-
36-
registerCommands(DevCommand, ItemCommand, HCPVCommand, StatsCommand, HCCommand)
37-
38-
Logger.info("Hate Cheaters Loaded!")
39-
4033
listOf(
4134
this
4235
).forEach { MinecraftForge.EVENT_BUS.register(it) }
@@ -50,12 +43,24 @@ class HateCheaters {
5043
screen = null
5144
}
5245

46+
@Mod.EventHandler
47+
fun postInit(event: FMLLoadCompleteEvent) {
48+
ModuleManager.addModules(
49+
BetterPartyFinder, HateCheatersModule, ProfileViewer, ClearSecrets
50+
)
51+
}
52+
5353
companion object {
5454
val version = "@MODVERSION@"
5555

5656
var screen: GuiScreen? = null
5757
val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
5858

59+
fun onOdinLoad() {
60+
if (pvCommand) CommandRegistry.add(PVCommand)
61+
CommandRegistry.register()
62+
}
63+
5964
fun launch(context: CoroutineContext = Dispatchers.IO, func: suspend CoroutineScope.() -> Unit) = scope.launch(context) { func(this) }
6065

6166
fun <R> launchDeferred(fn: suspend () -> R): Deferred<R> {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
package com.github.subat0m1c.hatecheaters.commands
3+
4+
import com.github.stivais.commodore.Commodore
5+
import com.github.stivais.commodore.nodes.Executable
6+
import com.github.stivais.commodore.nodes.LiteralNode
7+
import com.github.stivais.commodore.utils.findCorrespondingNode
8+
import com.github.stivais.commodore.utils.getArgumentsRequired
9+
import com.github.stivais.commodore.utils.getRootNode
10+
import com.github.subat0m1c.hatecheaters.commands.impl.*
11+
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.modMessage
12+
13+
/**
14+
* Contains [Commodore] commands to register when the mod is initialized.
15+
*
16+
* Code by Odin under BSD 3.0
17+
*
18+
* @author Stivias
19+
*/
20+
object CommandRegistry {
21+
22+
val commands: ArrayList<Commodore> = arrayListOf(
23+
DevCommand, ItemCommand, HCPVCommand,
24+
StatsCommand, HCCommand
25+
)
26+
27+
fun add(vararg commands: Commodore) {
28+
commands.forEach { commodore ->
29+
CommandRegistry.commands.add(commodore)
30+
}
31+
}
32+
33+
fun register() {
34+
commands.forEach { commodore ->
35+
commodore.register { problem, cause ->
36+
val builder = StringBuilder()
37+
38+
builder.append("§c$problem\n\n")
39+
builder.append(" Did you mean to run:\n\n")
40+
buildTreeString(cause, builder)
41+
42+
findCorrespondingNode(getRootNode(cause), "help")?.let {
43+
builder.append("\n §7Run /${getArgumentsRequired(it).joinToString(" ")} for more help.")
44+
}
45+
modMessage(builder.toString())
46+
}
47+
}
48+
}
49+
50+
private fun buildTreeString(from: LiteralNode, builder: StringBuilder) {
51+
for (node in from.children) {
52+
when (node) {
53+
is LiteralNode -> buildTreeString(node, builder)
54+
is Executable -> {
55+
builder.append(" /${getArgumentsRequired(from).joinToString(" ")}")
56+
for (parser in node.parsers) {
57+
builder.append(" <${parser.name()}${if (parser.optional()) "?" else ""}>")
58+
}
59+
builder.append("\n")
60+
}
61+
}
62+
}
63+
}
64+
}

src/main/kotlin/com/github/subat0m1c/hatecheaters/commands/Commodore.kt

Lines changed: 0 additions & 112 deletions
This file was deleted.

src/main/kotlin/com/github/subat0m1c/hatecheaters/commands/impl/DevCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.github.subat0m1c.hatecheaters.commands.impl
22

3+
import com.github.stivais.commodore.Commodore
34
import com.github.stivais.commodore.utils.GreedyString
45
import com.github.subat0m1c.hatecheaters.HateCheaters.Companion.launch
5-
import com.github.subat0m1c.hatecheaters.commands.commodore
66
import com.github.subat0m1c.hatecheaters.modules.HateCheatersModule
77
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.modMessage
88
import com.github.subat0m1c.hatecheaters.utils.WebUtils
@@ -14,7 +14,7 @@ import net.minecraft.client.gui.GuiScreen
1414
import java.util.*
1515
import kotlin.concurrent.schedule
1616

17-
val DevCommand = commodore("hcdev") {
17+
val DevCommand = Commodore("hcdev") {
1818

1919
var server: String? = null
2020

src/main/kotlin/com/github/subat0m1c/hatecheaters/commands/impl/HCCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.github.subat0m1c.hatecheaters.commands.impl
22

3-
import com.github.subat0m1c.hatecheaters.commands.commodore
3+
import com.github.stivais.commodore.Commodore
44
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.modMessage
55

6-
val HCCommand = commodore("hc", "hatecheaters") {
6+
val HCCommand = Commodore("hc", "hatecheaters") {
77
runs {
88
modMessage("""
99
Commands List:

src/main/kotlin/com/github/subat0m1c/hatecheaters/commands/impl/ImportantItemsCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.github.subat0m1c.hatecheaters.commands.impl
22

3+
import com.github.stivais.commodore.Commodore
34
import com.github.stivais.commodore.utils.GreedyString
4-
import com.github.subat0m1c.hatecheaters.commands.commodore
55
import com.github.subat0m1c.hatecheaters.modules.BetterPartyFinder.importantItems
66
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.capitalizeWords
77
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.modMessage
88
import me.odinmain.config.Config
99

10-
val ItemCommand = commodore("hcitems") {
10+
val ItemCommand = Commodore("hcitems") {
1111
literal("add").runs { item: GreedyString ->
1212
val name = item.string.lowercase().replace("_", " ").capitalizeWords()
1313
if (name in importantItems) return@runs modMessage("$name is already in the list!")
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.subat0m1c.hatecheaters.commands.impl
22

3+
import com.github.stivais.commodore.Commodore
34
import com.github.subat0m1c.hatecheaters.HateCheaters.Companion.launch
4-
import com.github.subat0m1c.hatecheaters.commands.commodore
55
import com.github.subat0m1c.hatecheaters.modules.BetterPartyFinder.displayDungeonData
66
import com.github.subat0m1c.hatecheaters.utils.ChatUtils.modMessage
77
import com.github.subat0m1c.hatecheaters.utils.apiutils.ApiUtils.memberData
@@ -10,20 +10,24 @@ import me.odinmain.OdinMain.mc
1010
import me.odinmain.utils.containsOneOf
1111
import me.odinmain.utils.skyblock.getChatBreak
1212

13-
val StatsCommand = commodore("hcs", "ds", "hcstats") {
14-
runs { name: String? ->
15-
val ign = name ?: mc.thePlayer.name
16-
launch {
17-
val profiles = getSkyblockProfile(ign).getOrElse { return@launch modMessage(it.message) }
18-
profiles.memberData?.let { displayDungeonData(it, profiles.name) }
19-
?: return@launch modMessage("""
13+
val StatsCommand = Commodore("hcs", "ds", "hcstats") {
14+
executable {
15+
param("name") {
16+
suggests { mc.netHandler.playerInfoMap.mapNotNull { it.gameProfile.name.lowercase().takeUnless { it.containsOneOf("!", " ") } } }
17+
}
18+
19+
runs { name: String? ->
20+
val ign = name ?: mc.thePlayer.name
21+
launch {
22+
val profiles = getSkyblockProfile(ign).getOrElse { return@launch modMessage(it.message) }
23+
profiles.memberData?.let { displayDungeonData(it, profiles.name) }
24+
?: return@launch modMessage("""
2025
${getChatBreak()}
2126
Could not find info for player $ign
2227
${getChatBreak()}
2328
""".trimIndent(), ""
24-
)
29+
)
30+
}
2531
}
26-
} suggests {
27-
mc.netHandler.playerInfoMap.mapNotNull { it.gameProfile.name.lowercase().takeUnless { it.containsOneOf("!", " ") } }
2832
}
2933
}

0 commit comments

Comments
 (0)