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
|
/// <reference types="../../../CTAutocomplete" />
/// <reference lib="es2015" />
import Feature from "../../featureClass/class";
import ToggleSetting from "../settings/settingThings/toggle";
import SoopyV2Server from "../../socketConnection"
import HudTextElement from "../hud/HudTextElement";
import LocationSetting from "../settings/settingThings/location";
import { numberWithCommas, timeNumber2, timeSince } from "../../utils/numberUtils";
import FakeRequireToggle from "../settings/settingThings/FakeRequireToggle";
class LockedFeatures extends Feature {
constructor() {
super()
}
onEnable() {
this.initVariables()
this.guildEventLbPossible = new FakeRequireToggle(false)
this.guildEventLb = new ToggleSetting("Guild event leaderboard", "A gui element for guild leaderboard progress", true, "guild_event_lb", this).requires(this.guildEventLbPossible)
this.hudElements = []
this.guildLbElement = new HudTextElement()
.setToggleSetting(this.guildEventLb)
.setLocationSetting(new LocationSetting("Guild Lb Location", "Allows you to edit the location of the guild leaderboard", "guild_lb_location", this, [50, 40, 1, 1])
.requires(this.guildEventLb))
this.hudElements.push(this.guildLbElement)
this.eventCommand = undefined
this.registerStep(true, 1, this.step)
}
step() {
if (!SoopyV2Server.lbdatathing) {
this.guildEventLbPossible.set(false)
if (this.eventCommand) {
this.eventCommand.unregister()
this.eventCommand = undefined
}
return;
}
this.guildEventLbPossible.set(true)
if (!this.eventCommand) {
this.eventCommand = this.registerCommand("eventlb", () => {
SoopyV2Server.lbdatathing.forEach((u, i) => {
let text = ""
text += "§6#" + (i + 1)
text += "§7 - "
text += "§e" + u.username
text += "&7: §r" + numberWithCommas(Math.round(parseFloat(u.startingAmount)))
if (u.progress) text += " §7(" + (u.progress > 0 ? "+" : "-") + Math.abs(Math.round(u.progress)) + "/h)"
ChatLib.chat(text)
})
})
}
if (!this.guildEventLb.getValue()) return
let text = ""
let playerPos = 0
SoopyV2Server.lbdatathing.forEach((u, i) => {
if (u.uuid === Player.getUUID().toString().replace(/-/g, "")) playerPos = i
})
let prevProgress
let playerProgress
let nextProgress
SoopyV2Server.lbdatathing.forEach((u, i) => {
if (i === playerPos - 1) nextProgress = [parseFloat(u.startingAmount), u.progress]
if (i === playerPos) playerProgress = [parseFloat(u.startingAmount), u.progress]
if (i === playerPos + 1) prevProgress = [parseFloat(u.startingAmount), u.progress]
if (i === playerPos - 1 || i === playerPos || i === playerPos + 1 || (playerPos === 0 && i === playerPos + 2)) {
text += "§6#" + (i + 1)
text += "§7 - "
text += "§e" + u.username
text += "&7: §f" + numberWithCommas(Math.round(parseFloat(u.startingAmount)))
if (u.progress) text += " §7(" + (u.progress > 0 ? "+" : "-") + Math.abs(Math.round(u.progress)) + "/h)"
text += "\n"
}
})
text += "&dLast updated " + timeSince(SoopyV2Server.lbdatathingupdated) + " ago"
let timeTillIncrease = Infinity
let timeTillDecrease = Infinity
if (nextProgress && nextProgress[1] - playerProgress[1] < 0) {
timeTillIncrease = ((nextProgress[0] - playerProgress[0]) / (playerProgress[1] - nextProgress[1]) * 60 * 60 * 1000)
}
if (prevProgress && prevProgress[1] - playerProgress[1] < 0) {
timeTillDecrease = ((playerProgress[0] - prevProgress[0]) / (prevProgress[1] - playerProgress[1]) * 60 * 60 * 1000)
}
if ((timeTillIncrease < timeTillDecrease || (timeTillIncrease > 0)) && timeTillDecrease < 0 && timeTillIncrease < 10000000000) {
text = "&d ^ in " + timeNumber2(timeTillIncrease) + "\n" + text
}
if ((timeTillIncrease > timeTillDecrease || (timeTillDecrease > 0)) && timeTillIncrease < 0 && timeTillDecrease < 10000000000) {
text = "&d v in " + timeNumber2(timeTillDecrease) + "\n" + text
}
this.guildLbElement.setText(text)
}
initVariables() {
}
onDisable() {
this.hudElements.forEach(h => h.delete())
this.initVariables()
}
}
module.exports = {
class: new LockedFeatures()
}
|