1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
|
import axios from '../axios'
import PogObject from "PogData"
const PREFIX = "&2[CW] "
let data = new PogObject("Coleweight", {
"api_key": undefined,
"x": 0.5,
"y": 141,
"coleweight": 0,
"cwToggle": true,
"first_time": true
}, ".cw_data.json");
let cwValues = [],
upTimeTrack = false,
uptime = 0,
baseColeweight = 0,
stepsSinceLast = 0,
cwGui = new Gui(),
throneValues = [],
spiralValues = [],
coleweightHr = 0,
cwValuesSum = 0
//key
register("chat", (key) => {
data.api_key = key
data.save()
axios.get(`https://api.hypixel.net/key?key=${data.api_key}`)
.then(res => {
if(res.data.success == true)
ChatLib.chat(`${PREFIX}&aSuccessfully Set api key!`)
else
ChatLib.chat(`${PREFIX}&eKey is not valid! (Try to set manually with /cw setkey <key>!)`)
})
.catch(err => {
ChatLib.chat(`${PREFIX}&eKey is not valid! (Try to set manually with /cw setkey <key>!)`)
})
}).setCriteria(/Your new API key is (.+)/)
//cw
register("command", (arg, arg2) => {
switch(arg)
{
case "setkey":
if(arg2 == undefined) { ChatLib.chat(`${PREFIX}&eRequires an argument!`); return; }
else key = arg2
data.api_key = key
data.save()
axios.get(`https://api.hypixel.net/key?key=${data.api_key}`)
.then(res => {
if(res.data.success == true)
ChatLib.chat(`${PREFIX}&aSuccsessfully set api key!`)
else
ChatLib.chat(`${PREFIX}&eKey is not valid!`)
})
.catch(err => {
ChatLib.chat(`${PREFIX}&eKey is not valid!`)
})
break
case "help":
ChatLib.chat("")
ChatLib.chat(`${PREFIX}&b/cw [username] => Gets coleweight`)
ChatLib.chat(`${PREFIX}&b/cw help => This menu.`)
ChatLib.chat(`${PREFIX}&b/cw gui => 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 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.`)
ChatLib.chat(`${PREFIX}&b/fetchdiscord (username) => Gets discord of username (if linked)`)
ChatLib.chat("")
break
case "gui":
cwGui.open();
break
case "toggle":
data.cwToggle = !data.cwToggle
data.save()
ChatLib.chat(`${PREFIX}&bSet gui to: &3${data.cwToggle}`)
break
case "throne":
if(arg2 != "toggle")
{
ChatLib.chat(`${PREFIX}&bGo to the throne and sit on the back block then run /cw throne toggle.`)
}
else
{
if(throneValues[0] == undefined)
{
let startPos = [Player.getX()-24, Player.getY()+6, Player.getZ()-59] // calculated below values at a weird start so adjusting them
throneValues.push([startPos[0]+8, startPos[1]+2, startPos[2]-5])
throneValues.push([startPos[0]+11, startPos[1]-35, startPos[2]-3])
throneValues.push([startPos[0]+2, startPos[1]-34, startPos[2]-4])
throneValues.push([startPos[0]+-2, startPos[1]-1, startPos[2]+49])
throneValues.push([startPos[0]+2, startPos[1]-13, startPos[2]+52])
throneValues.push([startPos[0]+27, startPos[1]-9, startPos[2]+51])
throneValues.push([startPos[0]+38, startPos[1]-15, startPos[2]+47])
throneValues.push([startPos[0]+41, startPos[1]-44, startPos[2]+46])
throneValues.push([startPos[0]+50, startPos[1]-28, startPos[2]+38])
throneValues.push([startPos[0]+49, startPos[1]-31, startPos[2]+1])
throneValues.push([startPos[0]+50, startPos[1]-1, startPos[2]+10])
ChatLib.chat(`${PREFIX}&bThrone waypoints turned on!`)
}
else
{
throneValues = []
ChatLib.chat(`${PREFIX}&bThrone waypoints turned off!`)
}
}
break
case "spiral":
if(arg2 != "toggle")
{
new TextComponent(`${PREFIX}&bGo to the place in &3this&b picture and do /cw spiral toggle`)
.setClickAction("open_url")
.setClickValue("https://i.imgur.com/dyL30GD.png")
.chat()
}
else
{
if(spiralValues[0] == undefined)
{
let startPos = [Player.getX(), Player.getY(), Player.getZ()]
spiralValues.push([startPos[0]+2, startPos[1]-3, startPos[2]+14])
spiralValues.push([startPos[0]+3, startPos[1]-21, startPos[2]+6])
spiralValues.push([startPos[0]+6, startPos[1]-23, startPos[2]-1])
spiralValues.push([startPos[0]+19, startPos[1]+4, startPos[2]-5])
spiralValues.push([startPos[0]+21, startPos[1]-7, startPos[2]])
spiralValues.push([startPos[0]+25, startPos[1]-35, startPos[2]-8])
spiralValues.push([startPos[0]+39, startPos[1]-36, startPos[2]])
spiralValues.push([startPos[0]+52, startPos[1]-24, startPos[2]+1])
spiralValues.push([startPos[0]+48, startPos[1]+3, startPos[2]+3])
spiralValues.push([startPos[0]+47, startPos[1]+4, startPos[2]+22])
spiralValues.push([startPos[0]+55, startPos[1]-8, startPos[2]+42])
spiralValues.push([startPos[0]+46, startPos[1]-11, startPos[2]+49])
spiralValues.push([startPos[0]+26, startPos[1]+5, startPos[2]+39])
spiralValues.push([startPos[0]+20, startPos[1]+3, startPos[2]+41])
spiralValues.push([startPos[0]+8, startPos[1]-23, startPos[2]+32])
spiralValues.push([startPos[0]+4, startPos[1]-23, startPos[2]+28])
ChatLib.chat(`${PREFIX}&bSpiral waypoints turned on!`)
}
else
{
spiralValues = []
ChatLib.chat(`${PREFIX}&bSpiral waypoints turned off!`)
}
}
break
case "reload":
upTimeTrack = false
stepsSinceLast = 0
cwValues = []
break
default:
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)`)
});
}
}).setTabCompletions((args) => {
let output = [],
commands = ["help", "setkey", "gui", "toggle", "throne", "spiral", "reload"]
if(args[0].length == 0 || args[0] == undefined)
output = commands
else
{
for(let i = 0; i < commands.length; i++)
{
for(let j = 0; j < args[0].length; j++)
{
if(commands[i][j] != args[0][j])
break
else if(j == args[0].length - 1)
output.push(commands[i])
}
}
}
return output
}).setName("cw").setAliases(["coleweight"])
//fetchdiscord
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=${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! `)
});
}).setName("fetchdiscord").setAliases(["fdiscord"]);
//gui
register("dragged", (dx, dy, x, y) => {
if (!cwGui.isOpen()) return
data.x = x
data.y = y
data.save()
});
register("renderOverlay", () => {
if (cwGui.isOpen()) {
let txt = "Please set your api key with /cw setkey (key)!"
if (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(`&aCW: &b0\n&aCW/hr: &b0\n&aUptime: &b0m\n&aColeweight Gained: &b0`, data.x, data.y)
}
if(!data.cwToggle || data.api_key == undefined) return
let coleweight = data.coleweight || 0,
coleweightMessage = ""
coleweight > 1000 ?coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`: coleweightMessage = `&b${coleweight.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`
if(cwValues[0] != undefined && upTimeTrack && calcCwPerHr)
{
cwValuesSum = 0
for(let i = 0; i < cwValues.length; i++)
{
cwValuesSum += cwValues[i]
}
coleweightHr = Math.ceil((cwValuesSum*(3600/uptime)) * 100) / 100
calcCwPerHr = false
}
if (cwGui.isOpen() || !upTimeTrack) return
let uptimeHr = Math.floor(uptime/60/60)
if(uptimeHr >= 1)
Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${coleweightHr}\n&aUptime: &b${uptimeHr}h ${Math.floor(uptime/60) - uptimeHr}m\n&aColeweight Gained: &b${Math.ceil(cwValuesSum*100) / 100}`, data.x, data.y)
else
Renderer.drawStringWithShadow(`&aCW: &b${coleweightMessage}\n&aCW/hr: &b${coleweightHr}\n&aUptime: &b${Math.floor(uptime/60)}m\n&aColeweight Gained: &b${Math.ceil(cwValuesSum*100) / 100}`, data.x, data.y)
})
//world update (coords)
register("renderWorld", () => {
if(throneValues[0] != undefined)
{
for(let i = 0; i < throneValues.length; i++)
{
Tessellator.drawString(i+1, throneValues[i][0], throneValues[i][1], throneValues[i][2])
}
}
if(spiralValues[0] != undefined)
{
for(let i = 0; i < spiralValues.length; i++)
{
Tessellator.drawString(i+1, spiralValues[i][0], spiralValues[i][1], spiralValues[i][2])
}
}
})
//update every second (dogshit code)
register("step", () => {
// first time check
if (data.first_time)
{
data.first_time = false;
data.save();
ChatLib.chat("");
new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bPlease Set Your Api Key By Doing /api new`)).chat();
new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bOr By Doing /cw setkey (key)`)).chat();
new TextComponent(ChatLib.getCenteredText(`${PREFIX}&bView commands: /cw help`)).chat();
ChatLib.chat("");
}
if (data.api_key == undefined) return
// updates coleweight for gui
let date_ob = new Date(),
seconds = date_ob.getSeconds()
if(upTimeTrack == true)
uptime += 1
if(seconds == 0 || seconds == 15 || seconds == 30 || seconds == 45)
{
try
{
let tempUuid = Player.getUUID(),
cwRows = (FileLib.read("Coleweight", "coleweight.csv")).split("\r\n"),
cwData = "",
coleweight = 0,
uuid = ""
for(let i = 0; i < tempUuid.length; i++)
{
if(tempUuid[i] != "-")
{
uuid = uuid + tempUuid[i]
}
}
axios.get(`https://api.hypixel.net/skyblock/profiles?key=${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)
{
let source = cwData.members[uuid][sourceToSearch],
eq = Math.ceil(source/row[1]*100) / 100
if(eq != undefined)
coleweight += eq
}
else if(row[3] == undefined)
{
let source = cwData.members[uuid][row[2]][sourceToSearch]
if (sourceToSearch == "powder_mithril_total")
{
var eq = Math.ceil(source/row[1]*100) / 100
let powder2 = cwData.members[uuid]['mining_core']['powder_spent_mithril']
if(powder2 != undefined)
{
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']
if(powder2 != undefined)
{
eq = Math.ceil((source+powder2)/row[1]*100) / 100
}
}
else
var eq = Math.ceil(source/row[1]*100) / 100
if(eq != undefined)
coleweight += eq
}
else if(row[5] == undefined)
{
let source = cwData.members[uuid][row[2]][row[3]][row[4]][sourceToSearch]
eq = Math.ceil(source/row[1]*100) / 100
if(source != undefined)
coleweight += eq
}
}
if(baseColeweight == 0)
{
baseColeweight = coleweight
}
else if((coleweight - baseColeweight) > 0)
{
cwValues.push(coleweight - baseColeweight)
calcCwPerHr = true
upTimeTrack = true
stepsSinceLast = 0
baseColeweight = coleweight
}
else if(stepsSinceLast > 20)
{
upTimeTrack = false
stepsSinceLast = 0
cwValues = []
}
else
{
stepsSinceLast += 1
}
data.coleweight = Math.ceil(coleweight*100)/100
data.save()
})
.catch(err => {})
}
catch(e)
{
ChatLib.chat(e)
}
}
}).setFps(1);
|