1+ const minecraftCommand = require ( "../../contracts/minecraftCommand.js" ) ;
2+
3+
4+ /*
5+ Derpy = 368 mod 24 = 8
6+ Jerry = 376 mod 24 = 16
7+ Scorpius = 384 mod 24 = 0
8+ https://hypixel-skyblock.fandom.com/wiki/Mayor_Election#Special_Candidates_Election_Cycle
9+ */
10+
11+ const hourMs = 50000 ;
12+ const dayMs = 24 * hourMs ;
13+ const monthLength = 31 ;
14+ const yearLength = 12 ;
15+
16+ const monthMs = monthLength * dayMs ;
17+ const yearMs = yearLength * monthMs ;
18+
19+ const yearZero = 1560275700000 ;
20+
21+ const currentSkyblockYear = timeToSkyblockYear ( Date . now ( ) ) ;
22+
23+ var yearsUntilSpecial = 0 ;
24+ var diffSkyblockYear = currentSkyblockYear ;
25+ var specialMayor = "" ;
26+
27+
28+ function timeToSkyblockYear ( time ) {
29+ return Math . floor ( ( time - yearZero ) / yearMs ) + 1 ;
30+ }
31+
32+ function getSpecialMayor ( skyblockYear ) {
33+ if ( diffSkyblockYear % 24 == 8 ) {
34+ specialMayor = "Derpy" ;
35+ } else if ( diffSkyblockYear % 24 == 16 ) {
36+ specialMayor = "Jerry" ;
37+ } else if ( diffSkyblockYear % 24 == 0 ) {
38+ specialMayor = "Scorpius" ;
39+ } else {
40+ specialMayor = "Error!" ;
41+ }
42+ return specialMayor ;
43+ }
44+
45+ class SpecialMayorCommand extends minecraftCommand {
46+ constructor ( minecraft ) {
47+ super ( minecraft ) ;
48+
49+ this . name = "specialmayor" ;
50+ this . aliases = [ "specmayor" ] ;
51+ this . description = "How many years until next special mayor, along with speculated special mayor." ;
52+ this . options = [ ] ;
53+ }
54+
55+ async onCommand ( ) {
56+ try {
57+
58+ if ( currentSkyblockYear % 8 == 0 ) {
59+ specialMayor = getSpecialMayor ( currentSkyblockYear ) ;
60+ this . send ( `/gc Special Mayor this year! It is speculated to be ${ specialMayor } .` ) ;
61+ } else {
62+ while ( diffSkyblockYear % 8 != 0 ) {
63+ yearsUntilSpecial += 1 ;
64+ diffSkyblockYear += 1 ;
65+ specialMayor = getSpecialMayor ( diffSkyblockYear ) ;
66+ }
67+ this . send ( `/gc Not Special Mayor, ${ yearsUntilSpecial } years until the next one! It is speculated to be ${ specialMayor } .` ) ;
68+ }
69+
70+ } catch ( error ) {
71+ console . log ( error )
72+ this . send ( `/gc [ERROR] ${ error } ` ) ;
73+ }
74+ }
75+ }
76+
77+ module . exports = SpecialMayorCommand ;
78+
0 commit comments