aboutsummaryrefslogtreecommitdiff
path: root/features/dataLoader
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-09 22:09:35 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-09-09 22:09:35 +0800
commit0b7ac15c335ba0978fda41a775a57c5456b64800 (patch)
tree9675287ce0b4c276cd127500ce1c9d96dfe48493 /features/dataLoader
parent95aa76b52db799b72134f2c1b438617484d9cc97 (diff)
downloadSoopyV2-0b7ac15c335ba0978fda41a775a57c5456b64800.tar.gz
SoopyV2-0b7ac15c335ba0978fda41a775a57c5456b64800.tar.bz2
SoopyV2-0b7ac15c335ba0978fda41a775a57c5456b64800.zip
+ burrial guess accuracy improvents
+ nether test of control ping accounting
Diffstat (limited to 'features/dataLoader')
-rw-r--r--features/dataLoader/index.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/features/dataLoader/index.js b/features/dataLoader/index.js
index 6f71f08..23cf744 100644
--- a/features/dataLoader/index.js
+++ b/features/dataLoader/index.js
@@ -30,6 +30,27 @@ class DataLoader extends Feature {
this.api_loaded_event = this.createCustomEvent("apiLoad")
+ this.checkingPing = false;
+ this.lastPingCheck = 0;
+ this.lastPings = [undefined, undefined, undefined];
+ this.ping = 0;
+ this.pingI = 0;
+
+ this.registerChat("&b&bYou are currently connected to server &6${*}&r", (e) => {
+ if (this.checkingPing) {
+ this.lastPings[this.pingI % 3] = Date.now() - this.lastPingCheck;
+ cancel(e);
+ this.checkingPing = false;
+
+ if (this.lastPings.includes(undefined)) {
+ this.ping = this.lastPings[this.pingI % 3];
+ } else {
+ this.ping = [...this.lastPings].sort((a, b) => a - b)[1];
+ }
+ this.pingI++;
+ }
+ });
+
this.lastServer = undefined
this.lastSentServer = 0
@@ -93,6 +114,15 @@ class DataLoader extends Feature {
})
}
+ getPing() {
+ if (Date.now() - this.lastPingCheck > 60000 * 30 || (Date.now() - this.lastPingCheck > 60000 && this.lastPings.includes(undefined) && this.bloodX !== -1)) {
+ this.lastPingCheck = Date.now();
+ ChatLib.command("whereami");
+ this.checkingPing = true;
+ }
+ return this.ping || 0
+ }
+
step_5min() {
fetch("http://soopy.dev/api/v2/mayor").json(data => {
if (!data.success) return