farming-weight 0.4.13 → 0.4.15
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.
|
@@ -1,19 +1,84 @@
|
|
|
1
1
|
export declare class SkyBlockTime {
|
|
2
2
|
static readonly SkyBlockEpochSeconds = 1560275700;
|
|
3
3
|
static readonly MonthNames: readonly ["Early Spring", "Spring", "Late Spring", "Early Summer", "Summer", "Late Summer", "Early Autumn", "Autumn", "Late Autumn", "Early Winter", "Winter", "Late Winter"];
|
|
4
|
+
/**
|
|
5
|
+
* The year of the SkyBlock time, 1-indexed.
|
|
6
|
+
*/
|
|
4
7
|
readonly year: number;
|
|
8
|
+
/**
|
|
9
|
+
* The month of the SkyBlock time, 1-indexed.
|
|
10
|
+
*/
|
|
5
11
|
readonly month: number;
|
|
12
|
+
/**
|
|
13
|
+
* The day of the SkyBlock time, 1-indexed.
|
|
14
|
+
*/
|
|
6
15
|
readonly day: number;
|
|
16
|
+
/**
|
|
17
|
+
* The Unix timestamp in seconds.
|
|
18
|
+
*/
|
|
7
19
|
readonly unixSeconds: number;
|
|
20
|
+
/**
|
|
21
|
+
* The Unix timestamp in seconds at the start of the day.
|
|
22
|
+
*/
|
|
23
|
+
readonly dayUnixSeconds: number;
|
|
24
|
+
/**
|
|
25
|
+
* The day of the SkyBlock year, 1-indexed.
|
|
26
|
+
*/
|
|
27
|
+
get dayOfYear(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Get the name of the month.
|
|
30
|
+
*/
|
|
31
|
+
get monthName(): "Early Spring" | "Spring" | "Late Spring" | "Early Summer" | "Summer" | "Late Summer" | "Early Autumn" | "Autumn" | "Late Autumn" | "Early Winter" | "Winter" | "Late Winter" | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Get a new SkyBlock time object representing the current time.
|
|
34
|
+
*/
|
|
8
35
|
static get now(): SkyBlockTime;
|
|
36
|
+
/**
|
|
37
|
+
* Create a SkyBlockTime object from a Unix timestamp in milliseconds.
|
|
38
|
+
* @param unixMs Unix timestamp in milliseconds
|
|
39
|
+
*/
|
|
9
40
|
constructor(unixMs: number);
|
|
41
|
+
/**
|
|
42
|
+
* Create a SkyBlockTime object from a skyblock year, month, and day.
|
|
43
|
+
* These dates shouldbe be 1-indexed. For example, Early Spring the 1st of Year 1 is 1, 1, 1.
|
|
44
|
+
* @param {number} sbYear SkyBlock year
|
|
45
|
+
* @param {number} sbMonth SkyBlock month
|
|
46
|
+
* @param {number} sbDay SkyBlock day
|
|
47
|
+
* @returns {SkyBlockTime}
|
|
48
|
+
*/
|
|
10
49
|
static from(sbYear: number, sbMonth?: number, sbDay?: number): SkyBlockTime;
|
|
50
|
+
/**
|
|
51
|
+
* Create a SkyBlockTime object from a zero indexed skyblock year, month, and day.
|
|
52
|
+
* These dates shouldbe be 1-indexed. For example, Early Spring the 1st of Year 1 is 0, 0, 0.
|
|
53
|
+
* @param {number} sbYear SkyBlock year
|
|
54
|
+
* @param {number} sbMonth SkyBlock month
|
|
55
|
+
* @param {number} sbDay SkyBlock day
|
|
56
|
+
* @returns {SkyBlockTime}
|
|
57
|
+
*/
|
|
11
58
|
static fromZeroIndexed(sbYear: number, sbMonth?: number, sbDay?: number): SkyBlockTime;
|
|
59
|
+
/**
|
|
60
|
+
* Convert a contest key from a raw Hypixel API response into a SkyBlockTime object.
|
|
61
|
+
* @param contestKey A contest key in the format '160:6_30:CROP_ID'
|
|
62
|
+
* @returns {SkyBlockTime}
|
|
63
|
+
*/
|
|
12
64
|
static fromContestKey(contestKey: string): SkyBlockTime;
|
|
13
|
-
get monthName(): "Early Spring" | "Spring" | "Late Spring" | "Early Summer" | "Summer" | "Late Summer" | "Early Autumn" | "Autumn" | "Late Autumn" | "Early Winter" | "Winter" | "Late Winter" | undefined;
|
|
14
65
|
isSpring(): boolean;
|
|
15
66
|
isSummer(): boolean;
|
|
16
67
|
isAutumn(): boolean;
|
|
17
68
|
isWinter(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if this SkyBlockTime object has a Jacob Contest event.
|
|
71
|
+
*/
|
|
72
|
+
hasJacobContest(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Get a new Date object representing this SkyBlockTime object.
|
|
75
|
+
*/
|
|
76
|
+
toDate(): Date;
|
|
77
|
+
/**
|
|
78
|
+
* Get the nearest SkyBlockTime date where a Jacob Contest Event happened.
|
|
79
|
+
* Always rounds down.
|
|
80
|
+
* @returns {SkyBlockTime}
|
|
81
|
+
*/
|
|
82
|
+
getLastContest(): SkyBlockTime;
|
|
18
83
|
toString(): string;
|
|
19
84
|
}
|
|
@@ -17,9 +17,28 @@ class SkyBlockTime {
|
|
|
17
17
|
'Winter',
|
|
18
18
|
'Late Winter',
|
|
19
19
|
];
|
|
20
|
+
/**
|
|
21
|
+
* The day of the SkyBlock year, 1-indexed.
|
|
22
|
+
*/
|
|
23
|
+
get dayOfYear() {
|
|
24
|
+
return (this.month - 1) * 31 + this.day;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the name of the month.
|
|
28
|
+
*/
|
|
29
|
+
get monthName() {
|
|
30
|
+
return SkyBlockTime.MonthNames[this.month - 1];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get a new SkyBlock time object representing the current time.
|
|
34
|
+
*/
|
|
20
35
|
static get now() {
|
|
21
36
|
return new SkyBlockTime(Date.now());
|
|
22
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a SkyBlockTime object from a Unix timestamp in milliseconds.
|
|
40
|
+
* @param unixMs Unix timestamp in milliseconds
|
|
41
|
+
*/
|
|
23
42
|
constructor(unixMs) {
|
|
24
43
|
this.unixSeconds = Math.floor(unixMs / 1000);
|
|
25
44
|
const elapsedSeconds = this.unixSeconds - SkyBlockTime.SkyBlockEpochSeconds;
|
|
@@ -27,15 +46,38 @@ class SkyBlockTime {
|
|
|
27
46
|
this.year = Math.floor(elapsedDays / 372) + 1;
|
|
28
47
|
this.month = Math.floor((elapsedDays % 372) / 31) + 1;
|
|
29
48
|
this.day = Math.floor((elapsedDays % 372) % 31) + 1;
|
|
49
|
+
// Round down to the nearest skyblock day
|
|
50
|
+
this.dayUnixSeconds = (elapsedSeconds - (elapsedSeconds % 1200)) + SkyBlockTime.SkyBlockEpochSeconds;
|
|
30
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a SkyBlockTime object from a skyblock year, month, and day.
|
|
54
|
+
* These dates shouldbe be 1-indexed. For example, Early Spring the 1st of Year 1 is 1, 1, 1.
|
|
55
|
+
* @param {number} sbYear SkyBlock year
|
|
56
|
+
* @param {number} sbMonth SkyBlock month
|
|
57
|
+
* @param {number} sbDay SkyBlock day
|
|
58
|
+
* @returns {SkyBlockTime}
|
|
59
|
+
*/
|
|
31
60
|
static from(sbYear, sbMonth = 1, sbDay = 1) {
|
|
32
61
|
return this.fromZeroIndexed(sbYear - 1, sbMonth - 1, sbDay - 1);
|
|
33
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a SkyBlockTime object from a zero indexed skyblock year, month, and day.
|
|
65
|
+
* These dates shouldbe be 1-indexed. For example, Early Spring the 1st of Year 1 is 0, 0, 0.
|
|
66
|
+
* @param {number} sbYear SkyBlock year
|
|
67
|
+
* @param {number} sbMonth SkyBlock month
|
|
68
|
+
* @param {number} sbDay SkyBlock day
|
|
69
|
+
* @returns {SkyBlockTime}
|
|
70
|
+
*/
|
|
34
71
|
static fromZeroIndexed(sbYear, sbMonth = 0, sbDay = 0) {
|
|
35
72
|
const elapsedDays = sbYear * 372 + sbMonth * 31 + sbDay;
|
|
36
73
|
const elapsedSeconds = elapsedDays * 1200;
|
|
37
74
|
return new SkyBlockTime((elapsedSeconds + SkyBlockTime.SkyBlockEpochSeconds) * 1000);
|
|
38
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Convert a contest key from a raw Hypixel API response into a SkyBlockTime object.
|
|
78
|
+
* @param contestKey A contest key in the format '160:6_30:CROP_ID'
|
|
79
|
+
* @returns {SkyBlockTime}
|
|
80
|
+
*/
|
|
39
81
|
static fromContestKey(contestKey) {
|
|
40
82
|
// Contest keys are in this format: '160:6_30:CROP_ID'
|
|
41
83
|
// Year counts from zero, month and day start at 1 (for some reason)
|
|
@@ -43,9 +85,6 @@ class SkyBlockTime {
|
|
|
43
85
|
const [month, day] = monthDay?.split('_').map(Number) ?? [];
|
|
44
86
|
return this.fromZeroIndexed(+(year ?? 0), (month ?? 0) - 1, (day ?? 0) - 1);
|
|
45
87
|
}
|
|
46
|
-
get monthName() {
|
|
47
|
-
return SkyBlockTime.MonthNames[this.month - 1];
|
|
48
|
-
}
|
|
49
88
|
isSpring() {
|
|
50
89
|
return this.month > 0 && this.month < 4;
|
|
51
90
|
}
|
|
@@ -58,6 +97,34 @@ class SkyBlockTime {
|
|
|
58
97
|
isWinter() {
|
|
59
98
|
return this.month > 9 && this.month < 13;
|
|
60
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if this SkyBlockTime object has a Jacob Contest event.
|
|
102
|
+
*/
|
|
103
|
+
hasJacobContest() {
|
|
104
|
+
// Contest happens every 3 days, starting on Early Spring 2nd
|
|
105
|
+
return (this.dayOfYear + 1) % 3 === 0;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get a new Date object representing this SkyBlockTime object.
|
|
109
|
+
*/
|
|
110
|
+
toDate() {
|
|
111
|
+
return new Date(this.unixSeconds * 1000);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get the nearest SkyBlockTime date where a Jacob Contest Event happened.
|
|
115
|
+
* Always rounds down.
|
|
116
|
+
* @returns {SkyBlockTime}
|
|
117
|
+
*/
|
|
118
|
+
getLastContest() {
|
|
119
|
+
if (this.hasJacobContest()) {
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
let time = SkyBlockTime.from(this.year, this.month, this.day);
|
|
123
|
+
while (!time.hasJacobContest()) {
|
|
124
|
+
time = SkyBlockTime.from(time.year, time.month, time.day - 1);
|
|
125
|
+
}
|
|
126
|
+
return time;
|
|
127
|
+
}
|
|
61
128
|
toString() {
|
|
62
129
|
return `${this.monthName} ${appendOrdinalSuffix(this.day)}, Year ${this.year}`;
|
|
63
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skyblocktime.js","sourceRoot":"","sources":["../../src/util/skyblocktime.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IACxB,MAAM,CAAU,oBAAoB,GAAG,UAAU,CAAC;IAClD,MAAM,CAAU,UAAU,GAAG;QAC5B,cAAc;QACd,QAAQ;QACR,aAAa;QACb,cAAc;QACd,QAAQ;QACR,aAAa;QACb,cAAc;QACd,QAAQ;QACR,aAAa;QACb,cAAc;QACd,QAAQ;QACR,aAAa;KACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"skyblocktime.js","sourceRoot":"","sources":["../../src/util/skyblocktime.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IACxB,MAAM,CAAU,oBAAoB,GAAG,UAAU,CAAC;IAClD,MAAM,CAAU,UAAU,GAAG;QAC5B,cAAc;QACd,QAAQ;QACR,aAAa;QACb,cAAc;QACd,QAAQ;QACR,aAAa;QACb,cAAc;QACd,QAAQ;QACR,aAAa;QACb,cAAc;QACd,QAAQ;QACR,aAAa;KACJ,CAAC;IAuBX;;OAEG;IACH,IAAI,SAAS;QACZ,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACZ,OAAO,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,MAAM,KAAK,GAAG;QACb,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,YAAY,MAAc;QACzB,IAAI,CAAC,W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