diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-12-12 19:12:24 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-12-12 19:12:24 +0800 |
commit | 8522734379fc57d0f22accbbe70ea8d903b4b1df (patch) | |
tree | dc2bbc5d813c1e532ac6be7a88083acc1ff202d0 /features | |
parent | 2789848b1518ff3e4805bc1d32241ebb34a31ddb (diff) | |
parent | 35b89852096c48945e55e9d550a417a963a9ad74 (diff) | |
download | SoopyV2-8522734379fc57d0f22accbbe70ea8d903b4b1df.tar.gz SoopyV2-8522734379fc57d0f22accbbe70ea8d903b4b1df.tar.bz2 SoopyV2-8522734379fc57d0f22accbbe70ea8d903b4b1df.zip |
Merge branch 'master' of https://github.com/Soopyboo32/SoopyV2 into Senither-lb
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..04ac729 --- /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, timeNumber2, 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 = ((nextProgress[0]-playerProgress[0])/(playerProgress[1]-nextProgress[1])*60*60*1000) + } + if(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) + } + + 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 |