@@ -6,18 +6,18 @@ class Understudies {
66 static understudies = [ ] ;
77
88 static onStartup ( ) {
9- this . #subscribeToEvents( ) ;
10- this . #startProcessingPlayers( ) ;
9+ Understudies . #subscribeToEvents( ) ;
10+ Understudies . #startProcessingPlayers( ) ;
1111 }
1212
1313 static #subscribeToEvents( ) {
14- world . afterEvents . entityDie . subscribe ( Understudies . onEntityDie . bind ( this ) ) ;
15- world . afterEvents . playerGameModeChange . subscribe ( Understudies . onPlayerGameModeChange . bind ( this ) ) ;
14+ world . afterEvents . entityDie . subscribe ( Understudies . onEntityDie . bind ( Understudies ) ) ;
15+ world . afterEvents . playerGameModeChange . subscribe ( Understudies . onPlayerGameModeChange . bind ( Understudies ) ) ;
1616 }
1717
1818 static #startProcessingPlayers( ) {
1919 system . runInterval ( ( ) => {
20- for ( const understudy of this . understudies ) {
20+ for ( const understudy of Understudies . understudies ) {
2121 if ( understudy . isConnected ( ) )
2222 understudy . onConnectedTick ( ) ;
2323 }
@@ -27,24 +27,24 @@ class Understudies {
2727 static onEntityDie ( event ) {
2828 if ( event . deadEntity . typeId !== 'minecraft:player' )
2929 return ;
30- const understudy = this . get ( event . deadEntity ?. name ) ;
30+ const understudy = Understudies . get ( event . deadEntity ?. name ) ;
3131 if ( understudy !== void 0 ) {
3232 understudy . leave ( ) ;
33- this . remove ( understudy ) ;
33+ Understudies . remove ( understudy ) ;
3434 }
3535 }
3636
3737 static onPlayerGameModeChange ( event ) {
38- const understudy = this . get ( event . player ?. name ) ;
38+ const understudy = Understudies . get ( event . player ?. name ) ;
3939 if ( understudy !== void 0 )
4040 understudy . savePlayerInfo ( ) ;
4141 }
4242
4343 static create ( name ) {
44- if ( this . isOnline ( name ) )
44+ if ( Understudies . isOnline ( name ) )
4545 throw new Error ( `[Understudy] Player with name ${ name } already exists.` ) ;
4646 const understudy = new Understudy ( name ) ;
47- this . understudies . push ( understudy ) ;
47+ Understudies . understudies . push ( understudy ) ;
4848 return understudy ;
4949 }
5050
@@ -55,7 +55,7 @@ class Understudies {
5555 }
5656
5757 static get ( name ) {
58- return this . understudies . find ( p => p . name === name ) ;
58+ return Understudies . understudies . find ( p => p . name === name ) ;
5959 }
6060
6161 static remove ( understudy ) {
@@ -68,35 +68,35 @@ class Understudies {
6868 const runner = system . runInterval ( ( ) => {
6969 if ( ! understudy . isConnected ( ) ) {
7070 system . clearRun ( runner ) ;
71- const index = this . understudies . indexOf ( understudy ) ;
72- this . understudies . splice ( index , 1 ) ;
71+ const index = Understudies . understudies . indexOf ( understudy ) ;
72+ Understudies . understudies . splice ( index , 1 ) ;
7373 }
7474 } ) ;
7575 }
7676
7777 static removeAll ( ) {
78- for ( const understudy of [ ...this . understudies ] )
79- this . remove ( understudy ) ;
78+ for ( const understudy of [ ...Understudies . understudies ] )
79+ Understudies . remove ( understudy ) ;
8080 }
8181
8282
8383 static length ( ) {
84- return this . understudies . length ;
84+ return Understudies . understudies . length ;
8585 }
8686
8787 static setNametagPrefix ( prefix ) {
8888 world . setDynamicProperty ( 'nametagPrefix' , prefix ) ;
8989 if ( prefix === '' ) {
90- for ( const understudy of this . understudies )
90+ for ( const understudy of Understudies . understudies )
9191 understudy . simulatedPlayer . nameTag = understudy . name ;
9292 } else {
93- for ( const understudy of this . understudies )
93+ for ( const understudy of Understudies . understudies )
9494 understudy . simulatedPlayer . nameTag = `[${ prefix } §r] ${ understudy . name } ` ;
9595 }
9696 }
9797
9898 static isOnline ( name ) {
99- return this . get ( name ) !== void 0 ;
99+ return Understudies . get ( name ) !== void 0 ;
100100 }
101101
102102 static getNotOnlineMessage ( name ) {
0 commit comments