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+
22+ function timeToSkyblockYear ( time ) {
23+ return Math . floor ( ( time - yearZero ) / yearMs ) + 1 ;
24+ }
25+
26+ class SpecialMayorCommand extends minecraftCommand {
27+ constructor ( minecraft ) {
28+ super ( minecraft ) ;
29+
30+ this . name = "specialmayor" ;
31+ this . aliases = [ "specmayor" ] ;
32+ this . description = "How many years until next special mayor, along with speculated special mayor." ;
33+ this . options = [ ] ;
34+ }
35+
36+ async onCommand ( ) {
37+ try {
38+ const currentSkyblockYear = timeToSkyblockYear ( Date . now ( ) ) ;
39+ var yearsUntilSpecial = 0 ;
40+ var diffSkyblockYear = currentSkyblockYear ;
41+ var specialMayor = "" ;
42+ function getSpecialMayor ( skyblockYear ) {
43+ if ( diffSkyblockYear % 24 == 8 ) {
44+ specialMayor = "Derpy" ;
45+ } else if ( diffSkyblockYear % 24 == 16 ) {
46+ specialMayor = "Jerry" ;
47+ } else if ( diffSkyblockYear % 24 == 0 ) {
48+ specialMayor = "Scorpius" ;
49+ } else {
50+ specialMayor = "Error!" ;
51+ }
52+ return specialMayor ;
53+ }
54+
55+ if ( currentSkyblockYear % 8 == 0 ) {
56+ specialMayor = getSpecialMayor ( currentSkyblockYear ) ;
57+ this . send ( `/gc Special Mayor this year! It is speculated to be ${ specialMayor } .` ) ;
58+ } else {
59+ while ( diffSkyblockYear % 8 != 0 ) {
60+ yearsUntilSpecial += 1 ;
61+ diffSkyblockYear += 1 ;
62+ specialMayor = getSpecialMayor ( diffSkyblockYear ) ;
63+ }
64+ this . send ( `/gc Not Special Mayor, ${ yearsUntilSpecial } years until the next one! It is speculated to be ${ specialMayor } .` ) ;
65+ }
66+
67+ } catch ( error ) {
68+ console . log ( error )
69+ this . send ( `/gc [ERROR] ${ error } ` ) ;
70+ }
71+ }
72+ }
73+
74+ module . exports = SpecialMayorCommand ;
75+
0 commit comments