aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coleweight.csv28
-rw-r--r--commandManager.js45
-rw-r--r--commands/fetchDiscord.js26
-rw-r--r--commands/findColeweight.js22
-rw-r--r--config.toml4
-rw-r--r--gui/collectionGui.js43
-rw-r--r--index.js163
-rw-r--r--metadata.json2
-rw-r--r--util/apiNew.js23
-rw-r--r--util/constants.js10
-rw-r--r--util/updater.js39
11 files changed, 246 insertions, 159 deletions
diff --git a/coleweight.csv b/coleweight.csv
deleted file mode 100644
index c8b2be9..0000000
--- a/coleweight.csv
+++ /dev/null
@@ -1,28 +0,0 @@
-experience_skill_mining,800000
-powder_mithril_total,55000,mining_core
-powder_gemstone_total,40000,mining_core
-MITHRIL_ORE,500000,collection
-GEMSTONE_COLLECTION,1400000,collection
-GOLD_INGOT,500000,collection
-NETHERRACK,45000,collection
-DIAMOND,1000000,collection
-ICE,1000000,collection
-REDSTONE,2000000,collection
-INK_SACK:4,4000000,collection
-SULPHUR,9999999999,collection
-COAL,500000,collection
-EMERALD,400000,collection
-ENDER_STONE,400000,collection
-GLOWSTONE_DUST,1000000,collection
-GRAVEL,333333,collection
-IRON_INGOT,1000000,collection
-MYCEL,50000,collection
-QUARTZ,400000,collection
-OBSIDIAN,200000,collection
-SAND:1,50000,collection
-SAND,500000,collection
-COBBLESTONE,1000000,collection
-HARD_STONE,200000,collection
-kills_scatha_10,2.5,bestiary
-kills_worm_5,10,bestiary
-total_placed,4,mining_core,crystals,jade_crystal \ No newline at end of file
diff --git a/commandManager.js b/commandManager.js
index 9acc4e4..108559f 100644
--- a/commandManager.js
+++ b/commandManager.js
@@ -1,4 +1,3 @@
-import axios from '../axios'
import { help } from "./commands/help.js"
import { reload } from "./commands/reload.js"
import { setkey } from "./commands/setkey.js"
@@ -8,12 +7,12 @@ import { toggle } from "./commands/toggle.js"
import { leaderboard } from "./commands/leaderboard.js"
import { update } from './commands/update'
import { openCwGui } from './gui/cwGui'
-import Settings from "./gui/settingsGui";
-import constants from './util/constants.js'
-
-const PREFIX = constants.PREFIX
+import { fetchDiscord } from './commands/fetchDiscord'
+import { findColeweight } from './commands/findColeweight'
+import Settings from "./gui/settingsGui"
register("command", (arg, arg2, arg3) => {
+ if (arg == undefined) {findColeweight(arg); return}
switch(arg.toLowerCase())
{
case "setkey":
@@ -47,25 +46,11 @@ register("command", (arg, arg2, arg3) => {
Settings.openGUI()
break
default:
- ChatLib.chat(`${constants.PREFIX}Finding Coleweight!`)
- let username = ""
- if(arg == undefined)
- username = Player.getUUID()
- else
- username = arg
- axios.get(`https://ninjune.dev/api/coleweight?username=${username}`)
- .then(res => {
- let coleweightMessage = new TextComponent(`${constants.PREFIX}&b${res.data.rank}. ${res.data.name}&b's Coleweight: ${res.data.coleweight} (Top &l${res.data.percentile}&b%)`)
- .setHoverValue(`&fExperience&f: &a${res.data.exp}\n&fPowder&f: &a${res.data.pow}\n&fCollection&f: &a${res.data.col}\n&fMiscellaneous&f: &a${res.data.bes + res.data.nuc}`)
- ChatLib.chat(coleweightMessage)
- })
- .catch(err => {
- ChatLib.chat(`${PREFIX}&eError. (api may be down)`)
- })
+ findColeweight(arg)
}
}).setTabCompletions((args) => {
let output = [],
- commands = ["setkey", "help", "gui", "toggle", "throne", "spiral", "reload", "leaderboard", "settings"]
+ commands = ["setkey", "help", "move", "toggle", "throne", "spiral", "reload", "leaderboard", "settings"]
if(args[0].length == 0 || args[0] == undefined)
output = commands
@@ -86,23 +71,7 @@ register("command", (arg, arg2, arg3) => {
}).setName("cw").setAliases(["coleweight"])
register("command", (arg) => {
- if(arg == undefined) { ChatLib.chat(`${PREFIX}&eRequires a username!`); return; }
- axios.get(`https://api.ashcon.app/mojang/v2/user/${arg}`)
- .then(res => {
- let uuid = res.data.uuid;
- axios.get(`https://api.hypixel.net/player?key=${constants.data.api_key}&uuid=${uuid}`)
- .then(res2 => {
- let discordMessage = new TextComponent(`${PREFIX}&a${res.data.username}'s Discord: `)
- ChatLib.chat(discordMessage);
- ChatLib.chat(`&b${res2.data.player.socialMedia.links.DISCORD}`)
- })
- .catch(err => {
- ChatLib.chat(`${PREFIX}&eNo discord linked :( (or no key linked)`)
- })
- })
- .catch(err => {
- ChatLib.chat(`${PREFIX}&eInvalid name! `)
- });
+ fetchDiscord(arg)
}).setTabCompletions((args) => {
let players = World.getAllPlayers().map((p) => p.getName())
.filter((n) =>
diff --git a/commands/fetchDiscord.js b/commands/fetchDiscord.js
new file mode 100644
index 0000000..f44c385
--- /dev/null
+++ b/commands/fetchDiscord.js
@@ -0,0 +1,26 @@
+import axios from "../../axios"
+import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+export function fetchDiscord(arg)
+{
+ if(arg == undefined) { ChatLib.chat(`${PREFIX}&eRequires a username!`); return }
+
+ axios.get(`https://api.ashcon.app/mojang/v2/user/${arg}`)
+ .then(res => {
+ let uuid = res.data.uuid
+ axios.get(`https://api.hypixel.net/player?key=${constants.data.api_key}&uuid=${uuid}`)
+ .then(res2 => {
+ let discordMessage = new TextComponent(`${PREFIX}&a${res.data.username}'s Discord: `)
+ ChatLib.chat(discordMessage);
+ ChatLib.chat(`&b${res2.data.player.socialMedia.links.DISCORD}`)
+ })
+ .catch(err => {
+ ChatLib.chat(`${PREFIX}&eNo discord linked :( (or no key linked)`)
+ })
+ })
+ .catch(err => {
+ ChatLib.chat(`${PREFIX}&eInvalid name! `)
+ })
+}
+
diff --git a/commands/findColeweight.js b/commands/findColeweight.js
new file mode 100644
index 0000000..d3fa38a
--- /dev/null
+++ b/commands/findColeweight.js
@@ -0,0 +1,22 @@
+import axios from "../../axios"
+import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+export function findColeweight(arg)
+{
+ ChatLib.chat(`${PREFIX}Finding Coleweight!`)
+ let username = ""
+ if(arg == undefined)
+ username = Player.getUUID()
+ else
+ username = arg
+ axios.get(`https://ninjune.dev/api/coleweight?username=${username}`)
+ .then(res => {
+ let coleweightMessage = new TextComponent(`${PREFIX}&b${res.data.rank}. ${res.data.name}&b's Coleweight: ${res.data.coleweight} (Top &l${res.data.percentile}&b%)`)
+ .setHoverValue(`&fExperience&f: &a${res.data.exp}\n&fPowder&f: &a${res.data.pow}\n&fCollection&f: &a${res.data.col}\n&fMiscellaneous&f: &a${res.data.bes + res.data.nuc}`)
+ ChatLib.chat(coleweightMessage)
+ })
+ .catch(err => {
+ ChatLib.chat(`${PREFIX}&eError. (api may be down)`)
+ })
+} \ No newline at end of file
diff --git a/config.toml b/config.toml
new file mode 100644
index 0000000..7b57afa
--- /dev/null
+++ b/config.toml
@@ -0,0 +1,4 @@
+
+[general]
+ tba = ""
+
diff --git a/gui/collectionGui.js b/gui/collectionGui.js
new file mode 100644
index 0000000..8197b11
--- /dev/null
+++ b/gui/collectionGui.js
@@ -0,0 +1,43 @@
+/*import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+let collectionGui = new Gui(),
+ collection = ""
+
+export function trackCollection(arg)
+{
+ switch(arg)
+ {
+ case "obby":
+ case "obsidian":
+ collection = "OBSIDIAN"
+ break
+ default:
+ ChatLib.chat(`${PREFIX}&eThat is not a valid collection! (or is not supported)`)
+ }
+}
+
+export function moveCollection()
+{
+ collectionGui.open()
+}
+
+register("dragged", (dx, dy, x, y) => {
+ if (!collectionGui.isOpen()) return
+ constants.data.collectionX = x
+ constants.data.collectionY = y
+ constants.data.save()
+})
+
+register("renderOverlay", () => {
+ if (cwGui.isOpen())
+ {
+ let txt = "Please set your api key with /cw setkey (key)!"
+ if (constants.data.api_key != undefined)
+ txt = "Click anywhere to move!"
+ Renderer.drawStringWithShadow(txt, Renderer.screen.getWidth()/2 - Renderer.getStringWidth(txt)/2, Renderer.screen.getHeight()/2)
+ Renderer.drawStringWithShadow(`&aCollection: &b0\n&aCW/hr: &b0\n&aUptime: &b0m\n&aColeweight Gained: &b0`, constants.data.collectionX, constants.data.collectionY)
+ }
+ if(collection == "") return
+ coleweight > 1000 ?collectionMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`: coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
+})*/ \ No newline at end of file
diff --git a/index.js b/index.js
index 2414c4f..63de9a4 100644
--- a/index.js
+++ b/index.js
@@ -1,8 +1,10 @@
-import axios from '../axios'
+import './util/apiNew'
import './commandManager'
+import './util/updater'
+import axios from '../axios'
import constants from './util/constants';
-import "./util/updater"
-import Settings from "./gui/settingsGui.js"
+import Settings from './gui/settingsGui.js'
+
const PREFIX = constants.PREFIX
@@ -39,7 +41,7 @@ register("step", () => {
new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bView commands: /cw help`)).chat()
ChatLib.chat("")
}
- if (constants.data.api_key == undefined) return
+ if (constants.data.api_key == undefined || constants.data.api_key == "") return
// updates coleweight for gui
let date_ob = new Date(),
@@ -52,8 +54,7 @@ register("step", () => {
try
{
let tempUuid = Player.getUUID(),
- cwRows = (FileLib.read("Coleweight", "coleweight.csv")).split("\r\n"),
- cwData = "",
+ profileData = "",
coleweight = 0,
uuid = ""
@@ -64,92 +65,102 @@ register("step", () => {
uuid = uuid + tempUuid[i]
}
}
-
- axios.get(`https://api.hypixel.net/skyblock/profiles?key=${constants.data.api_key}&uuid=${uuid}`)
- .then(res => {
- for(let i=0; i < res.data.profiles.length; i+=1)
- {
- if(profileToSearch = 'none' && res.data.profiles[i].selected == true)
- cwData = res.data.profiles[i]
- else if(res.data.profiles[i].cute_name == profileToSearch)
- cwData = res.data.profiles[i]
- }
- for(let i = 0; i < cwRows.length; i++)
- {
- let row = cwRows[i].split(","),
- sourceToSearch = row[0];
-
- if(row[2] == undefined)
+ axios.get(`https://ninjune.dev/api/cwinfo`)
+ .then(cwInfoRes => {
+ axios.get(`https://api.hypixel.net/skyblock/profiles?key=${constants.data.api_key}&uuid=${uuid}`)
+ .then(res => {
+ let eq = 0,
+ cwInfo = cwInfoRes.data
+
+ for(let i=0; i < res.data.profiles.length; i+=1)
{
- let source = cwData.members[uuid][sourceToSearch],
- eq = Math.ceil(source/row[1]*100) / 100
- if(eq != undefined)
- coleweight += eq
+ if(res.data.profiles[i].selected == true)
+ profileData = res.data.profiles[i]
}
- else if(row[3] == undefined)
+
+ coleweight += Math.ceil((profileData.members[uuid][cwInfo.experience.name]/cwInfo.experience.req)*100) / 100
+
+ for(let i = 0; i < cwInfo.powder.length; i++)
{
- let source = cwData.members[uuid][row[2]][sourceToSearch]
- if (sourceToSearch == "powder_mithril_total")
+ let sourceToSearch = cwInfo.powder[i].name,
+ source = profileData.members[uuid].mining_core[sourceToSearch]
+
+ if(source != undefined)
{
- var eq = Math.ceil(source/row[1]*100) / 100
- let powder2 = cwData.members[uuid]['mining_core']['powder_spent_mithril']
+ eq = Math.ceil(source/cwInfo.powder[i].req*100) / 100
- if(powder2 != undefined)
+ if(i == 0)
{
- eq = Math.ceil((source+powder2)/row[1]*100) / 100
- }
- }
- else if (sourceToSearch == "powder_gemstone_total")
- {
- var eq = Math.ceil(source/row[1]*100) / 100
- let powder2 = cwData.members[uuid]['mining_core']['powder_spent_gemstone']
+ let powder2 = profileData.members[uuid].mining_core['powder_spent_mithril']
- if(powder2 != undefined)
+ if(powder2 != undefined)
+ eq = Math.ceil((source+powder2)/cwInfo.powder[i].req*100) / 100
+ }
+ else
{
- eq = Math.ceil((source+powder2)/row[1]*100) / 100
+ let powder2 = profileData.members[uuid].mining_core['powder_spent_gemstone']
+
+ if(powder2 != undefined)
+ eq = Math.ceil((source+powder2)/cwInfo.powder[i].req*100) / 100
}
+ coleweight += eq
}
- else
- var eq = Math.ceil(source/row[1]*100) / 100
+ }
+
+ for(let i = 0; i < cwInfo.collection.length; i++)
+ {
+ let sourceToSearch = cwInfo.collection[i].name,
+ source = profileData.members[uuid].collection[sourceToSearch]
- if(eq != undefined)
+ if(source != undefined)
+ {
+ eq = Math.ceil(source/cwInfo.collection[i].req*100) / 100
coleweight += eq
+ }
}
- else if(row[5] == undefined)
+
+ for(let i = 0; i < cwInfo.miscellaneous.length; i++)
{
- let source = cwData.members[uuid][row[2]][row[3]][row[4]][sourceToSearch]
- eq = Math.ceil(source/row[1]*100) / 100
- if(source != undefined)
+ let sourceToSearch = cwInfo.miscellaneous[i].name
+ if(i == 0 || i == 1)
+ source = profileData.members[uuid].bestiary[sourceToSearch]
+ else
+ source = profileData.members[uuid].mining_core.crystals.jade_crystal[sourceToSearch]
+ if (source != undefined)
+ {
+ eq = Math.ceil(source/cwInfo.miscellaneous[i].req*100) / 100
coleweight += eq
+ }
}
- }
- if(constants.baseColeweight == 0)
- {
- constants.baseColeweight = coleweight
- }
- else if((coleweight - constants.baseColeweight) > 0)
- {
- constants.cwValues.push(coleweight - constants.baseColeweight)
- constants.calcCwPerHr = true
- constants.upTimeTrack = true
- constants.stepsSinceLast = 0
- constants.baseColeweight = coleweight
- }
- else if(constants.stepsSinceLast > 20)
- {
- constants.upTimeTrack = false
- constants.stepsSinceLast = 0
- constants.cwValues = []
- }
- else
- {
- constants.stepsSinceLast += 1
- }
-
- constants.data.coleweight = Math.ceil(coleweight*100)/100
- constants.data.save()
- })
- .catch(err => {})
+
+ if(constants.baseColeweight == 0)
+ {
+ constants.baseColeweight = coleweight
+ }
+ else if((coleweight - constants.baseColeweight) > 0)
+ {
+ constants.cwValues.push(coleweight - constants.baseColeweight)
+ constants.calcCwPerHr = true
+ constants.upTimeTrack = true
+ constants.stepsSinceLast = 0
+ constants.baseColeweight = coleweight
+ }
+ else if(constants.stepsSinceLast > 20)
+ {
+ constants.upTimeTrack = false
+ constants.stepsSinceLast = 0
+ constants.cwValues = []
+ }
+ else
+ {
+ constants.stepsSinceLast += 1
+ }
+
+ constants.data.coleweight = Math.ceil(coleweight*100)/100
+ constants.data.save()
+ })
+ .catch(err => {ChatLib.chat(e)})
+ })
}
catch(e)
{
diff --git a/metadata.json b/metadata.json
index f5969bc..6974f2e 100644
--- a/metadata.json
+++ b/metadata.json
@@ -3,6 +3,6 @@
"creator": "Ninjune",
"entry": "index.js",
"description": "Simple Coleweight module to measure mining progression.",
- "version": "1.5.1",
+ "version": "1.5.4",
"requires": ["axios", "PogData", "Vigilance"]
} \ No newline at end of file
diff --git a/util/apiNew.js b/util/apiNew.js
new file mode 100644
index 0000000..dd03c5f
--- /dev/null
+++ b/util/apiNew.js
@@ -0,0 +1,23 @@
+import constants from "../util/constants"
+import axios from "../../axios"
+const PREFIX = constants.PREFIX
+
+register("chat", (key) => {
+ axios.get(`https://api.hypixel.net/key?key=${key}`)
+ .then(res => {
+ if(res.data.success == true)
+ {
+ constants.data.api_key = key
+ constants.data.save()
+ ChatLib.chat(`${PREFIX}&aSuccsessfully set api key!`)
+ }
+ else
+ ChatLib.chat(`${PREFIX}&eKey is not valid!`)
+ })
+ .catch(err => {
+ ChatLib.chat(`${PREFIX}&eKey is not valid!`)
+ })
+ ChatLib.chat(ChatLib.getCenteredText(`${PREFIX}&aApi Key Successfully Set!`))
+}).setCriteria(/Your new API key is (.+)/)
+
+export default "" \ No newline at end of file
diff --git a/util/constants.js b/util/constants.js
index d7377fd..c421304 100644
--- a/util/constants.js
+++ b/util/constants.js
@@ -1,16 +1,15 @@
import PogObject from "PogData"
let PogData = new PogObject("Coleweight", {
- "api_key": undefined,
+ "api_key": "",
"x": 0.5,
"y": 141,
"coleweight": 0,
"cwToggle": true,
- "first_time": true,
- "api_key": undefined
+ "first_time": true
}, ".cw_data.json");
-export default
+export default
{
PREFIX: "&2[CW] ",
VERSION: (JSON.parse(FileLib.read("Coleweight", "metadata.json"))).version,
@@ -24,5 +23,6 @@ export default
throneValues: [],
spiralValues: [],
coleweightHr: 0,
- cwValuesSum: 0
+ cwValuesSum: 0,
+ beta: false
} \ No newline at end of file
diff --git a/util/updater.js b/util/updater.js
index edc20f8..64fbe1b 100644
--- a/util/updater.js
+++ b/util/updater.js
@@ -4,19 +4,36 @@ PREFIX = constants.PREFIX
VERSION = constants.VERSION
register("worldLoad", () => {
- axios.get(`https://raw.githubusercontent.com/Ninjune/coleweight/main/metadata.json`)
+ axios.get(`https://chattriggers.com/api/modules/1367`)
.then(res => {
- if(res.data.version == VERSION) return
- ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`)
- new TextComponent(`${PREFIX}&eClick &3here&e to open the github releases!`)
- .setClickAction("open_url")
- .setClickValue(`https://github.com/Ninjune/coleweight/releases`)
- .chat()
- ChatLib.chat("")
- })
- .catch(err => {
- ChatLib.chat(err)
+ if(res.data.releases[0].releaseVersion != VERSION && constants.beta == false)
+ {
+ ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`)
+ new TextComponent(`${PREFIX}&eClick &3here&e to update!`)
+ .setClickAction("run_command")
+ .setClickValue(`/ct load`)
+ .chat()
+ ChatLib.chat("")
+ }
+ else
+ {
+ axios.get(`https://raw.githubusercontent.com/Ninjune/coleweight/main/metadata.json`)
+ .then(res => {
+ if(res.data.version == VERSION || constants.beta == true) return
+ ChatLib.chat(`${PREFIX}&eYou are using an unsupported version of Coleweight!`)
+ new TextComponent(`${PREFIX}&eClick &3here&e to open the github releases!`)
+ .setClickAction("open_url")
+ .setClickValue(`https://github.com/Ninjune/coleweight/releases`)
+ .chat()
+ ChatLib.chat("")
+ return
+ })
+ .catch(err => {
+ ChatLib.chat(err)
+ })
+ }
})
+
})
export default "" \ No newline at end of file