Skip to content

Commit 1d72373

Browse files
authored
🎨 Use getters instead of functions
1 parent 5b6b45b commit 1d72373

File tree

1 file changed

+69
-46
lines changed

1 file changed

+69
-46
lines changed

src/model/FiveServer.js

+69-46
Original file line numberDiff line numberDiff line change
@@ -29,185 +29,208 @@ class FiveServer {
2929

3030
/***
3131
* Get the number of connected players
32-
* @return {number} Number of players
32+
* @type {number} Number of players
33+
* @readonly
3334
*/
34-
getPlayersCount() {
35+
get playersCount() {
3536
return this.data["clients"];
3637
}
3738

3839
/***
3940
* Get the players list
40-
* @return {Array<FivePlayer>} List of players
41+
* @type {Array<FivePlayer>} List of players
42+
* @readonly
4143
*/
42-
getPlayers() {
44+
get players() {
4345
return this.data["players"];
4446
}
4547

4648
/***
4749
* Get game type
48-
* @return {string} Game type
50+
* @type {string} Game type
51+
* @readonly
4952
*/
50-
getGameType() {
53+
get gameType() {
5154
return this.data["gametype"];
5255
}
5356

5457
/***
5558
* Get the server's hostname
56-
* @return {string} Server's hostname
59+
* @type {string} Server's hostname
60+
* @readonly
5761
*/
58-
getHostName() {
62+
get hostname() {
5963
return this.data["hostname"];
6064
}
6165

6266
/***
6367
* Get the server's current map
64-
* @return {string} Server's current map
68+
* @type {string} Server's current map
69+
* @readonly
6570
*/
66-
getMapName() {
71+
get mapName() {
6772
return this.data["mapname"];
6873
}
6974

7075
/***
7176
* Get the server's max players
72-
* @return {number} Server's max players
77+
* @type {number} Server's max players
78+
* @readonly
7379
*/
74-
getMaxPlayers() {
80+
get maxPlayers() {
7581
return this.data["sv_maxclients"];
7682
}
7783

7884
/***
7985
* Is the server enhanced host support
80-
* @return {boolean} True if server has enhanced host support
86+
* @type {boolean} True if server has enhanced host support
87+
* @readonly
8188
*/
82-
isEnhancedHostSupport() {
89+
get enhancedHostSupport() {
8390
return this.data["enhancedHostSupport"];
8491
}
8592

8693
/***
8794
* Get the server's list of active resources
88-
* @return {Array<String>} List of active resources
95+
* @type {Array<String>} List of active resources
96+
* @readonly
8997
*/
90-
getResources() {
98+
get resources() {
9199
return this.data["resources"]
92100
}
93101

94102
/***
95103
* Get the server's FXServer version
96-
* @return {String} FXServer version
104+
* @type {String} FXServer version
105+
* @readonly
97106
*/
98-
getServerVersion() {
107+
get serverVersion() {
99108
return this.data["server"]
100109
}
101110

102111
/***
103112
* Get the server's public variables
104-
* @return {Object} Public variables
113+
* @type {Object} Public variables
114+
* @readonly
105115
*/
106-
getPublicVariables() {
116+
get publicVariables() {
107117
return this.data["vars"]
108118
}
109119

110120
/***
111121
* Get the server's players count from the last server report
112-
* @return {number} Server's players count
122+
* @type {number} Server's players count
123+
* @readonly
113124
*/
114-
getPlayersCountFromServerReport() {
125+
get playersCountFromServerReport() {
115126
return this.data["selfReportedClients"];
116127
}
117128

118129
/***
119130
* Get the server's owner id
120-
* @return {number} Server's owner id
131+
* @type {number} Server's owner id
132+
* @readonly
121133
*/
122-
getOwnerId() {
134+
get ownerId() {
123135
return this.data["ownerID"];
124136
}
125137

126138
/***
127139
* Get is the server is password protected
128-
* @return {boolean} True if server is password protected
140+
* @type {boolean} True if server is password protected
141+
* @readonly
129142
*/
130-
isPrivate() {
143+
get private() {
131144
return this.data["private"];
132145
}
133146

134147
/***
135148
* Get is the server fallbabk
136-
* @return {boolean} True if server is fallback
149+
* @type {boolean} True if server is fallback
150+
* @readonly
137151
*/
138-
isFallback() {
152+
get fallback() {
139153
return this.data["fallback"]
140154
}
141155

142156
/***
143157
* Get the server's connect endpoints
144-
* @return {Array<String>} Server's connect endpoints
158+
* @type {Array<String>} Server's connect endpoints
159+
* @readonly
145160
*/
146-
getConnectedEndpoints() {
161+
get connectedEndpoints() {
147162
return this.data["connectEndPoints"];
148163
}
149164

150165
/***
151166
* Get the server's upvote power
152-
* @return {number} Server's upvote power
167+
* @type {number} Server's upvote power
168+
* @readonly
153169
*/
154-
getUpvotePower() {
170+
get upvotePower() {
155171
return this.data["upvotePower"];
156172
}
157173

158174
/***
159175
* Get the server's burst power
160-
* @return {number} Server's burst power
176+
* @type {number} Server's burst power
177+
* @readonly
161178
*/
162-
getBurstPower() {
179+
get burstPower() {
163180
return this.data["burstPower"];
164181
}
165182

166183
/***
167184
* Get is the server supported
168-
* @return {string} "supported" if server is supported
185+
* @type {string} "supported" if server is supported
186+
* @readonly
169187
*/
170-
isSupported() {
188+
get supported() {
171189
return this.data["support_status"]
172190
}
173191

174192
/***
175193
* Get the server's owner name
176-
* @returns {string} Server's owner name
194+
* @type {string} Server's owner name
195+
* @readonly
177196
*/
178-
getOwnerName() {
197+
get ownerName() {
179198
return this.data["ownerName"];
180199
}
181200

182201
/***
183202
* Get the server's owner cfx profile url
184-
* @returns {string} Server's owner cfx profile url
203+
* @type {string} Server's owner cfx profile url
204+
* @readonly
185205
*/
186-
getOwnerProfileUrl() {
206+
get ownerProfileUrl() {
187207
return this.data["ownerProfile"];
188208
}
189209

190210
/***
191211
* Get the server's owner avatar url
192-
* @returns {string} Server's owner avatar url
212+
* @type {string} Server's owner avatar url
213+
* @readonly
193214
*/
194-
getOwnerAvatarUrl() {
215+
get ownerAvatarUrl() {
195216
return this.data["ownerAvatar"];
196217
}
197218

198219
/***
199220
* Get the server's last seen date
200-
* @returns {string} Server's last seen date
221+
* @type {string} Server's last seen date
222+
* @readonly
201223
*/
202-
getLastSeenDate() {
224+
get lastSeenDate() {
203225
return this.data["lastSeen"];
204226
}
205227

206228
/***
207229
* Get the server's icon version
208-
* @returns {number} Server's icon version
230+
* @type {number} Server's icon version
231+
* @readonly
209232
*/
210-
getIconVersion() {
233+
get iconVersion() {
211234
return this.data["iconVersion"];
212235
}
213236
}

0 commit comments

Comments
 (0)