@pma-network/shared-server 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ type CooldownTrackerCallback = (src: number, details: string) => void;
2
+ export declare class CooldownTracker {
3
+ #private;
4
+ constructor(cooldown: number, cb: CooldownTrackerCallback);
5
+ player_dropped(): void;
6
+ try_add_cooldown(src: number, additional_details: string): boolean;
7
+ }
8
+ export {};
@@ -0,0 +1,35 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import { Event } from "@nativewrappers/server";
4
+ class CooldownTracker {
5
+ static {
6
+ __name(this, "CooldownTracker");
7
+ }
8
+ #cooldown_map = /* @__PURE__ */ new Map();
9
+ #cooldown;
10
+ #cb;
11
+ constructor(cooldown, cb) {
12
+ this.#cooldown = cooldown;
13
+ this.#cb = cb;
14
+ }
15
+ @Event("playerDropped")
16
+ player_dropped() {
17
+ this.#cooldown_map.delete(source);
18
+ }
19
+ /*
20
+ * @returns This returns `true` if it was successful in adding the player, or `false` the user already existed on the list
21
+ */
22
+ try_add_cooldown(src, additional_details) {
23
+ const gt = GetGameTimer();
24
+ const time = this.#cooldown_map.get(src);
25
+ if (!time || time < gt) {
26
+ this.#cooldown_map.set(src, gt + this.#cooldown);
27
+ return true;
28
+ }
29
+ this.#cb(src, additional_details);
30
+ return false;
31
+ }
32
+ }
33
+ export {
34
+ CooldownTracker
35
+ };
File without changes
File without changes
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./CooldownTracker";
2
+ export * from "./InfractionsWrapper";
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./CooldownTracker";
2
+ export * from "./InfractionsWrapper";
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@pma-network/shared-server",
3
+ "description": "Native wrappers and utilities for use with Shared utilities to be used on the server.",
4
+ "contributors": [
5
+ "Dillon Skaggs <AvarianKnight>"
6
+ ],
7
+ "type": "module",
8
+ "version": "0.0.7",
9
+ "files": [
10
+ "./**/*.js",
11
+ "./**/*.d.ts"
12
+ ],
13
+ "sideEffects": false,
14
+ "exports": {
15
+ ".": "./index.js",
16
+ "./*": "./*"
17
+ }
18
+ }