1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Torralbodavid\DuckFunkCore\Http\Traits; |
4
|
|
|
|
5
|
|
|
use Illuminate\Http\JsonResponse; |
6
|
|
|
use Torralbodavid\DuckFunkCore\Http\RCON\RCONSocket; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Trait RCONConnection. |
10
|
|
|
*/ |
11
|
|
|
trait RCONConnection |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Send a alert to a online user. |
15
|
|
|
* @param string $message The message to send. |
16
|
|
|
* @param int $user_id The id of the user to alert. |
17
|
|
|
* @return JsonResponse |
18
|
|
|
*/ |
19
|
|
|
public static function alertUser(string $message, int $user_id) |
20
|
|
|
{ |
21
|
|
|
return (new RCONSocket([ |
22
|
|
|
'key' => 'AlertUser', |
23
|
|
|
'data' => [ |
24
|
|
|
'message' => $message, |
25
|
|
|
'user_id' => $user_id, |
26
|
|
|
], |
27
|
|
|
]))->run(); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Change room owner. |
32
|
|
|
* @param int $room_id The id of the room to change. |
33
|
|
|
* @param int $user_id The new user id of the room. |
34
|
|
|
* @param string $username The new owner name of the room. |
35
|
|
|
* @return JsonResponse |
36
|
|
|
*/ |
37
|
|
|
public static function changeRoomOwner(int $room_id, int $user_id, string $username) |
38
|
|
|
{ |
39
|
|
|
return (new RCONSocket([ |
40
|
|
|
'key' => 'ChangeRoomOwner', |
41
|
|
|
'data' => [ |
42
|
|
|
'room_id' => $room_id, |
43
|
|
|
'user_id' => $user_id, |
44
|
|
|
'username' => $username, |
45
|
|
|
], |
46
|
|
|
]))->run(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Create mod ticket. |
51
|
|
|
* @param string $message The message that was included in the report. |
52
|
|
|
* @param int $reported_id User id of the reported player. |
53
|
|
|
* @param int $reported_room_id The room that was reported. |
54
|
|
|
* @param string $reported_username Username of the reported player. |
55
|
|
|
* @param int $sender_id User id who created the ticket. |
56
|
|
|
* @param string $sender_username Username who created the ticket. |
57
|
|
|
* @return JsonResponse |
58
|
|
|
*/ |
59
|
|
|
public static function createModToolTicket( |
60
|
|
|
string $message, |
61
|
|
|
int $reported_id, |
62
|
|
|
int $reported_room_id, |
63
|
|
|
string $reported_username, |
64
|
|
|
int $sender_id, |
65
|
|
|
string $sender_username) |
66
|
|
|
{ |
67
|
|
|
return (new RCONSocket([ |
68
|
|
|
'key' => 'ModTicket', |
69
|
|
|
'data' => [ |
70
|
|
|
'message' => $message, |
71
|
|
|
'reported_id' => $reported_id, |
72
|
|
|
'reported_room_id' => $reported_room_id, |
73
|
|
|
'reported_username' => $reported_username, |
74
|
|
|
'sender_id' => $sender_id, |
75
|
|
|
'sender_username' => $sender_username, |
76
|
|
|
], |
77
|
|
|
]))->run(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Disconnect a user. |
82
|
|
|
* @param string $username Optional user id of the player to disconnect. |
83
|
|
|
* @param int|null $user_id Optional username of the player to disconnect. |
84
|
|
|
* @return JsonResponse |
85
|
|
|
*/ |
86
|
|
View Code Duplication |
public static function disconnect(string $username = null, int $user_id = null) |
|
|
|
|
87
|
|
|
{ |
88
|
|
|
$response = [ |
89
|
|
|
'key' => 'disconnect', |
90
|
|
|
'data' => [], |
91
|
|
|
]; |
92
|
|
|
|
93
|
|
|
($username != null ? $response['data']['username'] = $username : $response['data']['user_id'] = $user_id); |
|
|
|
|
94
|
|
|
|
95
|
|
|
return (new RCONSocket($response))->run(); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Execute a command through user id. |
100
|
|
|
* @param string $command Complete string including the semicolon at the start for the command to execute. |
101
|
|
|
* @param int $user_id User id of the player to execute the command for. |
102
|
|
|
* @return JsonResponse |
103
|
|
|
*/ |
104
|
|
|
public static function executeCommand(string $command, int $user_id) |
105
|
|
|
{ |
106
|
|
|
return (new RCONSocket([ |
107
|
|
|
'key' => 'executeCommand', |
108
|
|
|
'data' => [ |
109
|
|
|
'command' => $command, |
110
|
|
|
'user_id' => $user_id, |
111
|
|
|
], |
112
|
|
|
]))->run(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Forward an user into a selected room. |
117
|
|
|
* @param int $room_id Room id of the room to forward the player to. |
118
|
|
|
* @param int $user_id User id of the player to forward. |
119
|
|
|
* @return JsonResponse |
120
|
|
|
*/ |
121
|
|
|
public static function forwardUser(int $room_id, int $user_id) |
|
|
|
|
122
|
|
|
{ |
123
|
|
|
return (new RCONSocket([ |
124
|
|
|
'key' => 'forwardUser', |
125
|
|
|
'data' => [ |
126
|
|
|
'room_id' => 42, |
127
|
|
|
'user_id' => 2, |
128
|
|
|
], |
129
|
|
|
]))->run(); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Send a friend request. |
134
|
|
|
* @param int $target_id User id of the player that receives a friend request. |
135
|
|
|
* @param int $user_id User id of the player that creates a friend request. |
136
|
|
|
* @return JsonResponse |
137
|
|
|
*/ |
138
|
|
|
public static function sendFriendRequest(int $target_id, int $user_id) |
139
|
|
|
{ |
140
|
|
|
return (new RCONSocket([ |
141
|
|
|
'key' => 'friendRequest', |
142
|
|
|
'data' => [ |
143
|
|
|
'target_id' => $target_id, |
144
|
|
|
'user_id' => $user_id, |
145
|
|
|
], |
146
|
|
|
]))->run(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Give a badge to an user. |
151
|
|
|
* @param string $badge Badge code of the badge that the player will receive. |
152
|
|
|
* @param int $user_id User id of the player that receives a badge. |
153
|
|
|
* @return JsonResponse |
154
|
|
|
*/ |
155
|
|
|
public static function giveBadge(string $badge, int $user_id) |
156
|
|
|
{ |
157
|
|
|
return (new RCONSocket([ |
158
|
|
|
'key' => 'giveBadge', |
159
|
|
|
'data' => [ |
160
|
|
|
'badge' => $badge, |
161
|
|
|
'user_id' => $user_id, |
162
|
|
|
], |
163
|
|
|
]))->run(); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Give clothes to an user. |
168
|
|
|
* @param int $clothing_id The clothing ID |
169
|
|
|
* @param int $user_id The id of the user to alert. |
170
|
|
|
* @return JsonResponse |
171
|
|
|
*/ |
172
|
|
|
public static function giveClothing(int $clothing_id, int $user_id) |
173
|
|
|
{ |
174
|
|
|
return (new RCONSocket([ |
175
|
|
|
'key' => 'giveClothing', |
176
|
|
|
'data' => [ |
177
|
|
|
'clothing_id' => $clothing_id, |
178
|
|
|
'user_id' => $user_id, |
179
|
|
|
], |
180
|
|
|
]))->run(); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Give credits to an user. |
185
|
|
|
* @param int $credits Amount of credits that the player will be awarded. |
186
|
|
|
* @param int $user_id User id of the player that will receive credits. |
187
|
|
|
* @return JsonResponse |
188
|
|
|
*/ |
189
|
|
|
public static function giveCredits(int $credits, int $user_id) |
190
|
|
|
{ |
191
|
|
|
return (new RCONSocket([ |
192
|
|
|
'key' => 'giveCredits', |
193
|
|
|
'data' => [ |
194
|
|
|
'credits' => $credits, |
195
|
|
|
'user_id' => $user_id, |
196
|
|
|
], |
197
|
|
|
]))->run(); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Give pixels to an user. |
202
|
|
|
* @param int $pixels Amount of pixels that the player will be awarded. |
203
|
|
|
* @param int $user_id User id of the player that will receive the pixels. |
204
|
|
|
* @return JsonResponse |
205
|
|
|
*/ |
206
|
|
|
public static function givePixels(int $pixels, int $user_id) |
207
|
|
|
{ |
208
|
|
|
return (new RCONSocket([ |
209
|
|
|
'key' => 'givePixels', |
210
|
|
|
'data' => [ |
211
|
|
|
'pixels' => $pixels, |
212
|
|
|
'user_id' => $user_id, |
213
|
|
|
], |
214
|
|
|
]))->run(); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @param int $points Amount of points that the player will be awarded. |
219
|
|
|
* @param int $type The type of points that the player will be awarded. |
220
|
|
|
* @param int $user_id User id of the player that will be awarded. |
221
|
|
|
* @return JsonResponse |
222
|
|
|
*/ |
223
|
|
|
public static function givePoints(int $points, int $type, int $user_id) |
224
|
|
|
{ |
225
|
|
|
return (new RCONSocket([ |
226
|
|
|
'key' => 'givePoints', |
227
|
|
|
'data' => [ |
228
|
|
|
'points' => $points, |
229
|
|
|
'type' => $type, |
230
|
|
|
'user_id' => $user_id, |
231
|
|
|
], |
232
|
|
|
]))->run(); |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Give respects to someone. |
237
|
|
|
* @param int $daily_respects Amount that will be added to the current daily respect points. |
238
|
|
|
* @param int $respect_given Amount that will be counted towards given respect statistic. |
239
|
|
|
* @param int $respect_received Amount that will be counted towards received respect statistic. |
240
|
|
|
* @param int $user_id User id of the player that will receive the respect. |
241
|
|
|
* @return JsonResponse |
242
|
|
|
*/ |
243
|
|
|
public static function giveRespect(int $daily_respects, int $respect_given, int $respect_received, int $user_id) |
244
|
|
|
{ |
245
|
|
|
return (new RCONSocket([ |
246
|
|
|
'key' => 'GiveRespect', |
247
|
|
|
'data' => [ |
248
|
|
|
'daily_respects' => $daily_respects, |
249
|
|
|
'respect_given' => $respect_given, |
250
|
|
|
'respect_received' => $respect_received, |
251
|
|
|
'user_id' => $user_id, |
252
|
|
|
], |
253
|
|
|
]))->run(); |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* Send an alert to everyone online. |
258
|
|
|
* @param string $message The message to display to all users online. |
259
|
|
|
* @param string $url The link to include. |
260
|
|
|
* @return JsonResponse |
261
|
|
|
*/ |
262
|
|
View Code Duplication |
public static function hotelAlert(string $message, string $url = null) |
|
|
|
|
263
|
|
|
{ |
264
|
|
|
$response = [ |
265
|
|
|
'key' => 'hotelAlert', |
266
|
|
|
'data' => [ |
267
|
|
|
'message' => $message, |
268
|
|
|
], |
269
|
|
|
]; |
270
|
|
|
|
271
|
|
|
($url != null ? $response['data']['url'] = $url : $response); |
|
|
|
|
272
|
|
|
|
273
|
|
|
return (new RCONSocket($response))->run(); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* Ignore an user. |
278
|
|
|
* @param int $target_id User id of the player that will be ignored |
279
|
|
|
* @param int $user_id User id of the player that will ignore target_id. |
280
|
|
|
* @return JsonResponse |
281
|
|
|
*/ |
282
|
|
|
public static function ignoreUser(int $target_id, int $user_id) |
283
|
|
|
{ |
284
|
|
|
return (new RCONSocket([ |
285
|
|
|
'key' => 'ignoreUser', |
286
|
|
|
'data' => [ |
287
|
|
|
'target_id' => $target_id, |
288
|
|
|
'user_id' => $user_id, |
289
|
|
|
], |
290
|
|
|
]))->run(); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
/** |
294
|
|
|
* Send an image alert to an user. |
295
|
|
|
* @param string $bubble_key Key of the bubble alert to define extra parameters in the external_flash_texts. |
296
|
|
|
* @param string $display_type Display type |
297
|
|
|
* @param string $image Image to display. |
298
|
|
|
* @param string $message The message parameter that needs to be set. |
299
|
|
|
* @param string $title Title of the popup window. |
300
|
|
|
* @param string $url The url parameter that needs to be set. |
301
|
|
|
* @param string $url_message The message of the url parameter that needs to be set. |
302
|
|
|
* @param int $user_id The user id of the user that will receive the alert |
303
|
|
|
* @return JsonResponse |
304
|
|
|
*/ |
305
|
|
View Code Duplication |
public static function imageAlertUser(string $bubble_key, string $display_type, string $image, string $message, string $title, string $url, string $url_message, int $user_id) |
|
|
|
|
306
|
|
|
{ |
307
|
|
|
return (new RCONSocket([ |
308
|
|
|
'key' => 'imageAlertUser', |
309
|
|
|
'data' => [ |
310
|
|
|
'bubble_key' => $bubble_key, |
311
|
|
|
'display_type' => $display_type, |
312
|
|
|
'image' => $image, |
313
|
|
|
'message' => $message, |
314
|
|
|
'title' => $title, |
315
|
|
|
'url' => $url, |
316
|
|
|
'url_message' => $url_message, |
317
|
|
|
'user_id' => $user_id, |
318
|
|
|
], |
319
|
|
|
]))->run(); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Send an alert to all online users. |
324
|
|
|
* @param string $bubble_key Key of the bubble alert to define extra parameters in the external_flash_texts. |
325
|
|
|
* @param string $display_type Display type |
326
|
|
|
* @param string $image Image to display. |
327
|
|
|
* @param string $message The message parameter that needs to be set. |
328
|
|
|
* @param string $title Title of the popup window. |
329
|
|
|
* @param string $url The url parameter that needs to be set. |
330
|
|
|
* @param string $url_message The message of the url parameter that needs to be set. |
331
|
|
|
* @return JsonResponse |
332
|
|
|
*/ |
333
|
|
View Code Duplication |
public static function imageHotelAlert(string $bubble_key, string $display_type, string $image, string $message, string $title, string $url, string $url_message) |
|
|
|
|
334
|
|
|
{ |
335
|
|
|
return (new RCONSocket([ |
336
|
|
|
'key' => 'imageAlertUser', |
337
|
|
|
'data' => [ |
338
|
|
|
'bubble_key' => $bubble_key, |
339
|
|
|
'display_type' => $display_type, |
340
|
|
|
'image' => $image, |
341
|
|
|
'message' => $message, |
342
|
|
|
'title' => $title, |
343
|
|
|
'url' => $url, |
344
|
|
|
'url_message' => $url_message, |
345
|
|
|
], |
346
|
|
|
]))->run(); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Add progress to an user achievement. |
351
|
|
|
* @param int $achievement_id ID of the achievement. |
352
|
|
|
* @param int $progress Amount to progress. |
353
|
|
|
* @param int $user_id User id of the player that needs an achievement progress. |
354
|
|
|
* @return JsonResponse |
355
|
|
|
*/ |
356
|
|
|
public static function progressAchievement(int $achievement_id, int $progress, int $user_id) |
357
|
|
|
{ |
358
|
|
|
return (new RCONSocket([ |
359
|
|
|
'key' => 'progressAchievement', |
360
|
|
|
'data' => [ |
361
|
|
|
'achievement_id' => $achievement_id, |
362
|
|
|
'progress' => $progress, |
363
|
|
|
'user_id' => $user_id, |
364
|
|
|
], |
365
|
|
|
]))->run(); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* Add a room event into a room. |
370
|
|
|
* @param string $message Message that will have the room event |
371
|
|
|
* @param int $room_id Room id of the room that will have the event |
372
|
|
|
* @param int $user_id |
373
|
|
|
* @return JsonResponse |
374
|
|
|
*/ |
375
|
|
|
public static function createRoomEvent(string $message, int $room_id, int $user_id) |
376
|
|
|
{ |
377
|
|
|
return (new RCONSocket([ |
378
|
|
|
'key' => 'roomEvent', |
379
|
|
|
'data' => [ |
380
|
|
|
'message' => $message, |
381
|
|
|
'room_id' => $room_id, |
382
|
|
|
'user_id' => $user_id, |
383
|
|
|
], |
384
|
|
|
]))->run(); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* Send a gift to an user. |
389
|
|
|
* @param int $itemid Item id to gift. |
390
|
|
|
* @param string $message Message to include in the gift. |
391
|
|
|
* @param int $user_id User id of the player that receives a gift. |
392
|
|
|
* @return JsonResponse |
393
|
|
|
*/ |
394
|
|
|
public static function sendGift(int $itemid, string $message, int $user_id) |
395
|
|
|
{ |
396
|
|
|
return (new RCONSocket([ |
397
|
|
|
'key' => 'sendGift', |
398
|
|
|
'data' => [ |
399
|
|
|
'itemid' => $itemid, |
400
|
|
|
'message' => $message, |
401
|
|
|
'user_id' => $user_id, |
402
|
|
|
], |
403
|
|
|
]))->run(); |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
/** |
407
|
|
|
* Send room bundle to an user. |
408
|
|
|
* @param int $catalog_page Id of the catalog page to buy. |
409
|
|
|
* @param int $user_id User id of the player that will receive a room bundle. |
410
|
|
|
* @return JsonResponse |
411
|
|
|
*/ |
412
|
|
|
public static function sendRoomBundle(int $catalog_page, int $user_id) |
413
|
|
|
{ |
414
|
|
|
return (new RCONSocket([ |
415
|
|
|
'key' => 'sendRoomBundle', |
416
|
|
|
'data' => [ |
417
|
|
|
'catalog_page' => $catalog_page, |
418
|
|
|
'user_id' => $user_id, |
419
|
|
|
], |
420
|
|
|
]))->run(); |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* Change the motto of an user. |
425
|
|
|
* @param string $motto The motto to set. |
426
|
|
|
* @param int $user_id The user id to change the motto for. |
427
|
|
|
* @return JsonResponse |
428
|
|
|
*/ |
429
|
|
|
public static function setMotto(string $motto, int $user_id) |
430
|
|
|
{ |
431
|
|
|
return (new RCONSocket([ |
432
|
|
|
'key' => 'setMotto', |
433
|
|
|
'data' => [ |
434
|
|
|
'motto' => $motto, |
435
|
|
|
'user_id' => $user_id, |
436
|
|
|
], |
437
|
|
|
]))->run(); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Update an user rank. |
442
|
|
|
* @param int $rank ID of the rank to set. |
443
|
|
|
* @param int $user_id User id of the player to set the rank for. |
444
|
|
|
* @return JsonResponse |
445
|
|
|
*/ |
446
|
|
|
public static function setRank(int $rank, int $user_id) |
447
|
|
|
{ |
448
|
|
|
return (new RCONSocket([ |
449
|
|
|
'key' => 'setRank', |
450
|
|
|
'data' => [ |
451
|
|
|
'rank' => $rank, |
452
|
|
|
'user_id' => $user_id, |
453
|
|
|
], |
454
|
|
|
]))->run(); |
455
|
|
|
} |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* @param string $message The message to send to all staff online. |
459
|
|
|
* @return JsonResponse |
460
|
|
|
*/ |
461
|
|
|
public static function sendStaffAlert(string $message) |
462
|
|
|
{ |
463
|
|
|
return (new RCONSocket([ |
464
|
|
|
'key' => 'staffAlert', |
465
|
|
|
'data' => [ |
466
|
|
|
'message' => $message, |
467
|
|
|
], |
468
|
|
|
]))->run(); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Follow an user to another room. |
473
|
|
|
* @param int $follow_id The user to stalk to. |
474
|
|
|
* @param int $user_id User id of the player to stalk to another user. |
475
|
|
|
* @return JsonResponse |
476
|
|
|
*/ |
477
|
|
|
public static function stalkUser(int $follow_id, int $user_id) |
478
|
|
|
{ |
479
|
|
|
return (new RCONSocket([ |
480
|
|
|
'key' => 'stalkUser', |
481
|
|
|
'data' => [ |
482
|
|
|
'follow_id' => $follow_id, |
483
|
|
|
'user_id' => $user_id, |
484
|
|
|
], |
485
|
|
|
]))->run(); |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* @param int $bubble_id Bubble type. -1 defaults to the user type. |
490
|
|
|
* @param string $message The message to say. |
491
|
|
|
* @param string $type Talk type to use: - talk - whisper - shout |
492
|
|
|
* @param int $user_id User id of the player to talk. |
493
|
|
|
* @return JsonResponse |
494
|
|
|
*/ |
495
|
|
|
public static function talkUser(int $bubble_id, string $message, string $type, int $user_id) |
496
|
|
|
{ |
497
|
|
|
return (new RCONSocket([ |
498
|
|
|
'key' => 'talkUser', |
499
|
|
|
'data' => [ |
500
|
|
|
'bubble_id' => $bubble_id, |
501
|
|
|
'message' => $message, |
502
|
|
|
'type' => $type, |
503
|
|
|
'user_id' => $user_id, |
504
|
|
|
], |
505
|
|
|
]))->run(); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
/** |
509
|
|
|
* @param string $message Intern message |
510
|
|
|
* @return JsonResponse |
511
|
|
|
*/ |
512
|
|
|
public static function updateCatalog(string $message) |
513
|
|
|
{ |
514
|
|
|
return (new RCONSocket([ |
515
|
|
|
'key' => 'updatecatalog', |
516
|
|
|
'data' => [ |
517
|
|
|
'message' => $message, |
518
|
|
|
], |
519
|
|
|
]))->run(); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* @param int $achievement_score Add achievement score. |
524
|
|
|
* @param int $block_camera_follow Optional: Block camera following. |
525
|
|
|
* @param int $block_following Optional: Block following in the hotel. |
526
|
|
|
* @param int $block_friendrequests Optional: Block friendrequests in the hotel. |
527
|
|
|
* @param int $block_roominvites Optional: Block receiving room invites in the hotel. |
528
|
|
|
* @param string $look Optional: Look of the player. |
529
|
|
|
* @param int $old_chat Optional: Use new chat. |
530
|
|
|
* @param int $user_id User id of the player to update. |
531
|
|
|
* @return JsonResponse |
532
|
|
|
*/ |
533
|
|
|
public static function updateUser(int $achievement_score, int $block_camera_follow, int $block_following, int $block_friendrequests, int $block_roominvites, string $look, int $old_chat, int $user_id) |
534
|
|
|
{ |
535
|
|
|
$response = [ |
536
|
|
|
'key' => 'updateUser', |
537
|
|
|
'data' => [ |
538
|
|
|
'achievement_score' => $achievement_score, |
539
|
|
|
'user_id' => $user_id, |
540
|
|
|
], |
541
|
|
|
]; |
542
|
|
|
|
543
|
|
|
($block_camera_follow != null ? $response['data']['block_camera_follow'] = $block_camera_follow : $response); |
544
|
|
|
($block_following != null ? $response['data']['block_following'] = $block_following : $response); |
545
|
|
|
($block_friendrequests != null ? $response['data']['block_friendrequests'] = $block_friendrequests : $response); |
546
|
|
|
($block_roominvites != null ? $response['data']['block_roominvites '] = $block_roominvites : $response); |
547
|
|
|
($look != null ? $response['data']['look'] = $look : $response); |
548
|
|
|
($old_chat != null ? $response['data']['old_chat'] = $old_chat : $response); |
549
|
|
|
|
550
|
|
|
return (new RCONSocket($response))->run(); |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
/** |
554
|
|
|
* @param string $message Intern message |
555
|
|
|
* @return JsonResponse |
556
|
|
|
*/ |
557
|
|
|
public static function updateWordFilter(string $message) |
558
|
|
|
{ |
559
|
|
|
return (new RCONSocket([ |
560
|
|
|
'key' => 'updateWordFilter', |
561
|
|
|
'data' => [ |
562
|
|
|
'message' => $message, |
563
|
|
|
], |
564
|
|
|
]))->run(); |
565
|
|
|
} |
566
|
|
|
} |
567
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.