aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/claim.js59
-rw-r--r--commands/fetchDiscord.js26
-rw-r--r--commands/findColeweight.js22
-rw-r--r--commands/help.js9
-rw-r--r--commands/info.js23
-rw-r--r--commands/tick.js64
-rw-r--r--commands/time.js13
-rw-r--r--commands/toggle.js9
8 files changed, 213 insertions, 12 deletions
diff --git a/commands/claim.js b/commands/claim.js
new file mode 100644
index 0000000..fc0bc57
--- /dev/null
+++ b/commands/claim.js
@@ -0,0 +1,59 @@
+import axios from "../../axios"
+import settings from "../settings"
+import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+
+export function claim(structure)
+{
+ if(!settings.claiming)
+ {
+ ChatLib.chat(`${PREFIX}&cPlease turn on the &3Claiming&c setting in /cw settings!`)
+ return
+ }
+
+ if (constants.serverData.map != "Crystal Hollows")
+ {
+ ChatLib.chat(`${PREFIX}&cThis command is only available in the crystal hollows!`)
+ return
+ }
+
+ if (structure == undefined || !(structure.toLowerCase() == "throne" || structure.toLowerCase() == "spiral"))
+ {
+ ChatLib.chat(`${PREFIX}&cPlease enter the structure you wish to claim! (&3throne&c or &3spiral&c)`)
+ return
+ }
+
+ axios.get(`https://ninjune.dev/api/claim?type=${structure}&id=${constants.serverData.server}&key=${constants.data.api_key}`)
+ .then(res => {
+ if(res.data.success)
+ ChatLib.chat(`${PREFIX}&aSuccessfully claimed ${constants.serverData.server} as your server!`)
+ else
+ ChatLib.chat(`${PREFIX}&cError: ${res.data.reason}`)
+ })
+ .catch(err => {
+ ChatLib.chat(`${PREFIX}&cError: ${err}`)
+ })
+ // key is used above to verify that the player trying to claim the lobby is the intended player, don't know a better way of doing this.
+}
+
+
+register('worldLoad', () => {
+ if(!settings.claiming) return
+ setTimeout(() => {
+ console.log(constants.serverData.server)
+ axios.get(`https://ninjune.dev/api/claim?claimedlobby=${constants.serverData.server}`)
+ .then(res => {
+ if(res.data.claimed)
+ {
+ World.getAllPlayers().forEach((player) => {
+ if (player.getName() == res.data.player)
+ ChatLib.chat(`${PREFIX}&cThe ${res.data.structure} in this lobby is claimed by ${res.data.player}.`)
+ })
+ }
+ })
+ .catch(err => {
+ ChatLib.chat(`${PREFIX}Error: ${err}`)
+ })
+ }, 2000)
+}) \ No newline at end of file
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/commands/help.js b/commands/help.js
index bc22fda..3c20b01 100644
--- a/commands/help.js
+++ b/commands/help.js
@@ -6,9 +6,12 @@ export function help()
ChatLib.chat("")
ChatLib.chat(`${PREFIX}&b/cw [username] => Gets coleweight`)
ChatLib.chat(`${PREFIX}&b/cw help => This menu.`)
- ChatLib.chat(`${PREFIX}&b/cw move => Change gui location`)
- ChatLib.chat(`${PREFIX}&b/cw toggle => Toggle gui (gui is only active when mining)`)
- ChatLib.chat(`${PREFIX}&b/cw setkey (key) => Sets API key (can also use /api new)`)
+ ChatLib.chat(`${PREFIX}&b/cw settings => Open settings.`)
+ ChatLib.chat(`${PREFIX}&b/cw time => Prints time on timer (timer gui doesn't have to be visible).`)
+ ChatLib.chat(`${PREFIX}&b/cw tick <mining speed> <('r','jade', etc) || breaking power of block> => Shows tick data.`)
+ ChatLib.chat(`${PREFIX}&b/cw info => Prints coleweight info.`)
+ ChatLib.chat(`${PREFIX}&b/cw claim <throne || spiral> => Claims a chollows sapphire structure in a lobby.`)
+ ChatLib.chat(`${PREFIX}&b/cw setkey <key> => Sets API key (can also use /api new)`)
ChatLib.chat(`${PREFIX}&b/cw reload => Reloads the gui.`)
ChatLib.chat(`${PREFIX}&b/cw throne => Guide for setting up waypoints for throne.`)
ChatLib.chat(`${PREFIX}&b/cw spiral => Guide for setting up waypoints for spiral.`)
diff --git a/commands/info.js b/commands/info.js
new file mode 100644
index 0000000..3967863
--- /dev/null
+++ b/commands/info.js
@@ -0,0 +1,23 @@
+import axios from "../../axios"
+import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+export function info()
+{
+ axios.get(`https://ninjune.dev/api/cwinfo`)
+ .then((res) => {
+ let values = res.data,
+ powder = values.powder,
+ collection = values.collection,
+ miscellaneous = values.miscellaneous
+
+ ChatLib.chat(`${PREFIX}&bEach of the following are equivalent to one unit of ColeWeight` +
+ `\n\n&4&lExperience \n&b${values.experience.req} mining exp` +
+ `\n\n&4&lPowder \n&b${powder[0].req} &bmithril powder\n&b${powder[1].req} gemstone powder` + // in theory I should have just added formatted names to the api
+ `\n\n&4&lCollections \n&b${collection[0].req} &bmithril\n&b${collection[1].req} gemstone\n&b${collection[2].req} gold\n&b${collection[3].req}netherrack\n&b${collection[4].req} diamond\n&b${collection[5].req} ice\n&b${collection[6].req} redstone\n&b${collection[7].req} lapis\n&b${collection[8].req} sulphur\n&b${collection[9].req} coal\n&b${collection[10].req} emerald\n&b${collection[11].req} endstone\n&b${collection[12].req} glowstone\n&b${collection[13].req} gravel\n&b${collection[14].req} iron\n&b${collection[15].req} mycelium\n&b${collection[16].req} quartz\n&b${collection[17].req} obsidian\n&b${collection[18].req} red sand\n&b${collection[19].req} sand\n&b${collection[20].req} cobblestone\n&b${collection[21].req} hardstone` +
+ `\n\n&4&lMiscellaneous \n&b${miscellaneous[0].req} scatha kills\n&b${miscellaneous[1].req} worm kills\n&b${miscellaneous[2].req} nucleus runs`)
+ })
+ .catch((e) => {
+ return `${PREFIX}&cThere was an error. (api may be down)`
+ })
+} \ No newline at end of file
diff --git a/commands/tick.js b/commands/tick.js
new file mode 100644
index 0000000..7af81e2
--- /dev/null
+++ b/commands/tick.js
@@ -0,0 +1,64 @@
+import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+export function tick(speed, block)
+{
+ if(speed == undefined || parseInt(speed) != speed)
+ return `${PREFIX}&cMining speed must be an integer!`
+ let strength = findStrength(block)
+ if(strength < 1) return `${PREFIX}&cBlock must be a gemstone or positive breaking power! (or starting letter of gemstone)`
+ let currentBlockTick = strength*30/speed,
+ currentShardTick = (strength-200)*30/speed,
+ nextBlockSpeed, nextShardSpeed
+
+ if(currentBlockTick < Math.floor(currentBlockTick) + 0.5)
+ nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)-0.5)
+ else
+ nextBlockSpeed = strength*30/(Math.floor(currentBlockTick)+0.5)
+
+ if(currentShardTick < Math.floor(currentShardTick) + 0.5)
+ nextShardSpeed = strength*30/(Math.floor(currentShardTick)-0.5)
+ else
+ nextShardSpeed = strength*30/(Math.floor(currentShardTick)+0.5)
+
+ ChatLib.chat(`\n&bCurrently mining blocks in &6&l${Math.round(currentBlockTick)} ticks` +
+ `\n&bCurrently mining shards in &6&l${Math.round(currentShardTick)} ticks` +
+ `\n&bNext block tick will be at: &6&l${Math.round(nextBlockSpeed)} mining speed` +
+ `\n&bNext shard tick will be at: &6&l${Math.round(nextShardSpeed)} mining speed` +
+ `\n&bYou need &6&l${Math.round(nextBlockSpeed - speed)} mining speed&b to get the next block tick.` +
+ `\n&bYou need &6&l${Math.round(nextShardSpeed - speed)} mining speed&b to get the next shard tick.\n`)
+}
+
+function findStrength(block)
+{
+ let strength = -1
+
+ if(block == parseInt(block))
+ strength = block
+ else
+ {
+ switch(block.toLowerCase())
+ {
+ case "ruby":
+ case "r":
+ strength = 2500
+ break
+ case "j":
+ case "jade":
+ case "a":
+ case "amber":
+ case "amethyst":
+ case "s":
+ case "sapphire":
+ strength = 3200
+ break
+ case "t":
+ case "topaz":
+ case "o":
+ case "opal":
+ strength = 4000
+ }
+ }
+
+ return strength
+}
diff --git a/commands/time.js b/commands/time.js
new file mode 100644
index 0000000..115964e
--- /dev/null
+++ b/commands/time.js
@@ -0,0 +1,13 @@
+import constants from "../util/constants"
+const PREFIX = constants.PREFIX
+
+
+export function time()
+{
+ let timerHr = Math.floor(constants.timerdata.timer/60/60)
+
+ if(timerHr >= 1)
+ ChatLib.chat(`${PREFIX}&aTimer (${constants.serverData.server}): &b${timerHr}h ${Math.floor(constants.timerdata.timer/60) - timerHr*60}m`)
+ else
+ ChatLib.chat(`${PREFIX}&aTimer (${constants.serverData.server}): &b${Math.floor(constants.timerdata.timer/60)}m ${Math.floor(constants.timerdata.timer%60)}s`)
+} \ No newline at end of file
diff --git a/commands/toggle.js b/commands/toggle.js
deleted file mode 100644
index a5e0ec2..0000000
--- a/commands/toggle.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import constants from "../util/constants"
-const PREFIX = constants.PREFIX
-
-export function toggle()
-{
- constants.data.cwToggle = !constants.data.cwToggle
- constants.data.save()
- ChatLib.chat(`${PREFIX}&bSet gui to: &3${constants.data.cwToggle}`)
-} \ No newline at end of file