diff options
Diffstat (limited to 'features')
-rw-r--r-- | features/lockedFeatures/index.js | 129 | ||||
-rw-r--r-- | features/lockedFeatures/metadata.json | 8 | ||||
-rw-r--r-- | features/slayers/index.js | 10 |
3 files changed, 138 insertions, 9 deletions
diff --git a/features/lockedFeatures/index.js b/features/lockedFeatures/index.js new file mode 100644 index 0000000..551922b --- /dev/null +++ b/features/lockedFeatures/index.js @@ -0,0 +1,129 @@ +/// <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, timeNumber, timeSince } from "../../utils/numberUtils"; + +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.registerStep(true, 1, this.step) + this.registerEvent("renderOverlay", this.renderOverlay) + } + + step(){ + if(!SoopyV2Server.lbdatathing){ + this.guildEventLbPossible.set(false) + return; + } + + this.guildEventLbPossible.set(true) + + 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){ + 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)" + text += "\n" + } + }) + + text += "&dLast updated " + timeSince(SoopyV2Server.lbdatathingupdated) + " ago" + + let timeTillIncrease = Infinity + let timeTillDecrease = Infinity + if(nextProgress[1]-playerProgress[1] < 0){ + timeTillIncrease = Math.abs((nextProgress[0]-playerProgress[0])/(nextProgress[1]-playerProgress[1])*60*60*1000) + } + if(prevProgress[1]-playerProgress[1] < 0){ + timeTillDecrease = Math.abs((prevProgress[0]-playerProgress[0])/(prevProgress[1]-playerProgress[1])*60*60*1000) + } + + if(timeTillIncrease < timeTillDecrease && timeTillIncrease < 10000000000){ + text = "&dRank increasing in ~" + timeNumber(timeTillIncrease) + "\n"+text + } + if(timeTillIncrease > timeTillDecrease && timeTillDecrease < 10000000000){ + text = "&dRank decreasing in ~" + timeNumber(timeTillDecrease) + "\n"+text + } + + this.guildLbElement.setText(text) + } + + renderOverlay(){ + this.hudElements.forEach(a=>a.render()) + } + + initVariables(){ + + } + + onDisable(){ + this.initVariables() + } +} + +module.exports = { + class: new LockedFeatures() +} + +class FakeRequireToggle{ + constructor(val){ + this.val = val + + this.thisToggleEvents = [] + + this.toggleObject = { + addEvent: (event)=>{ + this.thisToggleEvents.push(event) + } + } + } + + set(newVal){ + if(this.val === newVal) return + this.val = newVal + + this.thisToggleEvents.forEach(e=>e._trigger(this, [this.val])) + } + + getValue(){ + return this.val + } +}
\ No newline at end of file diff --git a/features/lockedFeatures/metadata.json b/features/lockedFeatures/metadata.json new file mode 100644 index 0000000..7506cc2 --- /dev/null +++ b/features/lockedFeatures/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Locked Features", + "description": "A bunch of random features that are only accessable to some people\n§0(eg only people in specific guild)", + "isHidden": false, + "isTogglable": true, + "defaultEnabled": true, + "sortA": 1 +}
\ No newline at end of file diff --git a/features/slayers/index.js b/features/slayers/index.js index 347cfaa..5b6e5ac 100644 --- a/features/slayers/index.js +++ b/features/slayers/index.js @@ -2,7 +2,7 @@ /// <reference lib="es2015" /> import Feature from "../../featureClass/class"; import { f, m } from "../../../mappings/mappings"; -import { numberWithCommas } from "../../utils/numberUtils"; +import { numberWithCommas, timeNumber } from "../../utils/numberUtils"; import { drawBoxAtBlock, drawBoxAtEntity, drawFilledBox, drawLine } from "../../utils/renderUtils"; import HudTextElement from "../hud/HudTextElement"; import LocationSetting from "../settings/settingThings/location"; @@ -380,11 +380,3 @@ class Slayers extends Feature { module.exports = { class: new Slayers() } - -function timeNumber(time){ - let mins = Math.floor(time/1000/60) - let secs = Math.floor(time/1000)%60 - - if(mins === 0) return secs + "s" - return `${mins}m ${secs}s` -}
\ No newline at end of file |