Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
hypixel game id
Browse files Browse the repository at this point in the history
  • Loading branch information
CubeWhy committed Aug 6, 2023
1 parent 34538f7 commit fefe02e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
20 changes: 16 additions & 4 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {

annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT")

include 'org.jetbrains.kotlin:kotlin-stdlib:1.8.20-RC'
include 'org.jetbrains.kotlin:kotlin-stdlib:1.9.0'
include 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'
include('com.jagrosh:DiscordIPC:0.4') {
exclude module: "gson"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void refresh() throws IOException {
}
}

/*
/**
* 将账户信息转化成json 以便存入配置文件中
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class HypixelMod : ModuleDraggable() {

// Current server info
private var subServer: String? = null
private var gameType: String? = null
private var gameType: GameType? = null
private var lastLobby: String? = null
private var serverType: ServerType = ServerType.LOBBY
private lateinit var json: JsonObject;

private val addresses = ServerConfigFile.getInstance().getServerAddressesList(ServerConfigFile.ServerEnum.HYPIXEL)

Expand Down Expand Up @@ -98,7 +99,7 @@ class HypixelMod : ModuleDraggable() {

override fun renderDummy(position: ScreenPosition?) {
if (this.texts.size == 0) {
this.texts.add("Hypixel Mod")
this.texts.add("Hypixel Module")
}
render(position)
}
Expand Down Expand Up @@ -167,20 +168,24 @@ class HypixelMod : ModuleDraggable() {
if (msgRaw.startsWith("{") && msgRaw.endsWith("}")) {
// parse the json
val gson = Gson()
val json = gson.fromJson(msgRaw, JsonObject::class.java)
json = gson.fromJson(msgRaw, JsonObject::class.java)
this.subServer = json.get("server").asString // sub server name
if (this.subServer.equals("limbo")) {
// AFK Server
this.serverType = ServerType.LIMBO
} else {
this.gameType = json.get("gametype").asString // the game type, etc. BEDWARS, SKYWARS
this.gameType = GameType.getType(json.get("gametype").asString) // the game type, etc. BEDWARS, SKYWARS
this.serverType = if (json.has("lobby")) ServerType.LOBBY else ServerType.GAME
}
if (serverType == ServerType.LOBBY) {
this.lastLobby = json.get("lobby").asString
} else if (serverType == ServerType.GAME) {
this.processGame(json)
}
// remove the message
mc.ingameGUI.chatGUI.sentMessages.removeIf {
it == msgRaw
}
}
}

Expand All @@ -196,14 +201,41 @@ class HypixelMod : ModuleDraggable() {
if (this.serverType == ServerType.LIMBO) {
this.texts.add("I'm AFK.")
} else {
val gameType = json.get("gametype").asString // game type
this.texts.add("Game type: $gameType")
// val gameType = json.get("gametype").asString // game type
this.texts.add("Game type: ${gameType?.displayName}")
}
}

enum class GameType(val gameInJson: String, val displayName: String) {
// the enum about gameTypes of the Hypixel server
MAIN("MAIN", "MainLobby"),
DUELS("DUELS", "Duels"),
PIT("PIT", "Pit"),
PROTOTYPE("PROTOTYPE", "Prototype"),
BUILDBATTLE("BUILD_BATTLE", "BuildBattle"),
MEGAWALLS("WALLS3", "MegaWalls"),
CAC("MCGO", "CopsAndCrims"),
CLASSICAL("LEGARY", "Classical"),
SKYBLOCK("SKYBLOCK", "SkyBlock"),
ARCADE("ARCADE", "ArcadeGames"),
UHC("UHC", "UHC"),
MURDERMYSTERY("MURDER_MYSTERY", "MurderMystery"),
BEDWARS("BEDWARS", "BedWars"),
SKYWARS("SKYWARS", "SkyWars")
SKYWARS("SKYWARS", "SkyWars");

companion object {
fun getType(name: String): GameType? {
for (value in entries) {
if (value.gameInJson == name) {
return value
}
}
return null
}

fun getDisplayName(name: String): String {
return getType(name)!!.displayName
}
}
}
}

0 comments on commit fefe02e

Please sign in to comment.