18
18
import cn .jsmod2 .core .CommandSender ;
19
19
import cn .jsmod2 .core .Server ;
20
20
import cn .jsmod2 .core .math .Vector ;
21
- import cn .jsmod2 .network .DoGetStream ;
22
- import cn .jsmod2 .network .DoStream ;
23
- import cn .jsmod2 .network .SimpleGetStream ;
24
- import cn .jsmod2 .network .SimpleSetStream ;
21
+ import cn .jsmod2 .network .*;
22
+ import cn .jsmod2 .network .protocol .item .GetItemPacket ;
23
+ import cn .jsmod2 .network .protocol .player .GetCurrentItemPacket ;
24
+ import cn .jsmod2 .network .protocol .player .GetInventoryPacket ;
25
+ import cn .jsmod2 .network .protocol .player .GetUserGroupPacket ;
26
+ import cn .jsmod2 .network .protocol .player .GiveItemPacket ;
25
27
26
28
import java .io .Serializable ;
27
29
import java .util .List ;
@@ -243,43 +245,77 @@ public void ban(int duration,String message){
243
245
}
244
246
245
247
public Item giveItem (ItemType type ){
246
- return null ;
248
+ GiveItemPacket packet = new GiveItemPacket ();
249
+ packet .playerName = playerName ;
250
+ packet .type = type ;
251
+ return (Item )packet .send ();
247
252
}
248
253
254
+ @ SuppressWarnings ("unchecked" )
249
255
public List <Item > getInventory (){
250
- return null ;
256
+ GetInventoryPacket packet = new GetInventoryPacket ();
257
+ packet .playerName = playerName ;
258
+ return packet .send ();
251
259
}
252
260
253
261
public Item getCurrentItem (){
254
- return null ;
262
+ GetCurrentItemPacket packet = new GetCurrentItemPacket ();
263
+ packet .playerName = playerName ;
264
+ return packet .send ();
255
265
}
256
266
257
267
public void setCurrentItem (ItemType type ){
258
-
268
+ DoStream stream = new DoStream ();
269
+ stream .playerName = playerName ;
270
+ stream .method = "SetCurrentItem" ;
271
+ stream .args = new String []{"'" +type +"'" };
272
+ stream .send ();
259
273
}
260
274
261
275
public int getCurrentItemIndex (){
262
- return 0 ;
276
+ DoGetStream stream = new DoGetStream (Integer .class );
277
+ stream .playerName = playerName ;
278
+ stream .method = "GetCurrentItem" ;
279
+ return (Integer ) stream .send ();
263
280
}
264
281
265
282
public void setCurrentItemIndex (int index ){
266
-
283
+ DoStream stream = new DoStream ();
284
+ stream .playerName = playerName ;
285
+ stream .method = "SetCurrentItemIndex" ;
286
+ stream .args = new String []{index +"" };
287
+ stream .send ();
267
288
}
268
289
269
290
public boolean hasItem (ItemType type ){
270
- return false ;
291
+ DoGetStream stream = new DoGetStream (ItemType .class );
292
+ stream .method = "HasItem" ;
293
+ stream .args = new String []{"'" +type +"'" };
294
+ stream .playerName = playerName ;
295
+ return (Boolean )stream .send ();
271
296
}
272
297
273
298
public int getItemIndex (ItemType type ){
274
- return 0 ;
299
+ DoGetStream stream = new DoGetStream (ItemType .class );
300
+ stream .method = "GetItemIndex" ;
301
+ stream .playerName = playerName ;
302
+ stream .args = new String []{"'" +type +"'" };
303
+ return (Integer ) stream .send ();
275
304
}
276
305
277
306
public boolean isHandcuffed (){
278
- return false ;
307
+ DoGetStream stream = new DoGetStream (Boolean .class );
308
+ stream .method = "IsHandcuffed" ;
309
+ stream .playerName = playerName ;
310
+ return (Boolean )stream .send ();
279
311
}
280
312
281
313
public void changeRole (Role role ,boolean full ,boolean spawnTeleport ,boolean spawnProtected ){
282
-
314
+ DoStream stream = new DoStream ();
315
+ stream .playerName = playerName ;
316
+ stream .method = "ChangeRole" ;
317
+ stream .args = new String []{"'" +role +"'" ,full +"" ,spawnTeleport +"" ,spawnProtected +"" };
318
+ stream .send ();
283
319
}
284
320
285
321
//这里未来解决
@@ -288,83 +324,150 @@ public Object getGameObject(){
288
324
}
289
325
290
326
public UserGroup getUserGroup (){
291
- return null ;
327
+ GetUserGroupPacket packet = new GetUserGroupPacket ();
328
+ packet .playerName = playerName ;
329
+ return packet .send ();
292
330
}
293
331
294
332
public boolean runCommand (String command ,String [] args ){
295
333
return Server .getSender ().getServer ().getPluginManager ().executeCommand (command ,args ,this );
296
334
}
297
335
298
336
public boolean getGodmode (){
299
- return true ;
337
+ DoGetStream stream = new DoGetStream (Boolean .class );
338
+ stream .playerName = playerName ;
339
+ stream .method = "GetGodmode" ;
340
+ return (Boolean ) stream .send ();
300
341
}
301
342
302
343
public void setGodmode (boolean godmode ){
303
-
344
+ DoStream stream = new DoStream ();
345
+ stream .playerName = playerName ;
346
+ stream .method = "SetGodMode" ;
347
+ stream .args = new String []{godmode +"" };
348
+ stream .send ();
304
349
}
305
350
306
351
public Vector getRotation (){
307
- return null ;
352
+ DoGetStream stream = new DoGetStream (Vector .class );
353
+ stream .playerName = playerName ;
354
+ stream .method = "GetRotation" ;
355
+ return (Vector ) stream .send ();
308
356
}
309
357
310
358
public void sendConsoleMessage (String message , String color ){
311
-
359
+ DoStream stream = new DoStream ();
360
+ stream .playerName = playerName ;
361
+ stream .method = "SendConsoleMessage" ;
362
+ stream .args = new String []{message ,color };
363
+ stream .send ();
312
364
}
313
365
public void sendConsoleMessage (String message ){
314
366
sendConsoleMessage (message ,"green" );
315
367
}
316
368
317
369
public void infect (float time ){
318
-
370
+ DoStream stream = new DoStream ();
371
+ stream .playerName = playerName ;
372
+ stream .method = "Infect" ;
373
+ stream .args = new String []{time +"" };
374
+ stream .send ();
319
375
}
320
376
public void throwGrenade (GrenadeType grenadeType , boolean isCustomDirection , Vector direction , boolean isEnvironmentallyTriggered , Vector position , boolean isCustomForce , float throwForce , boolean slowThrow ){
321
-
377
+ DoStream stream = new DoStream ();
378
+ stream .playerName = playerName ;
379
+ stream .method = "ThrowGrenade" ;
380
+ stream .args = new String []{"'" +grenadeType +"'" ,isCustomDirection +"" ,direction .toString (),isEnvironmentallyTriggered +"" ,position .toString (),isCustomForce +"" ,throwForce +"" ,slowThrow +"" };
381
+ stream .send ();
322
382
}
323
383
public void throwGrenade (GrenadeType grenadeType , boolean isCustomDirection , Vector direction , boolean isEnvironmentallyTriggered , Vector position , boolean isCustomForce , float throwForce ){
324
384
throwGrenade (grenadeType ,isCustomDirection ,direction ,isEnvironmentallyTriggered ,position ,isCustomForce ,throwForce ,false );
325
385
}
326
386
public boolean getBypassMode (){
327
- return false ;
387
+ DoGetStream stream = new DoGetStream (Boolean .class );
388
+ stream .playerName = playerName ;
389
+ stream .method = "GetBypassMode" ;
390
+ return (Boolean ) stream .send ();
328
391
}
329
392
public String getAuthToken (){
330
- return "" ;
393
+ DoGetStream stream = new DoGetStream (String .class );
394
+ stream .method = "GetAuthToken" ;
395
+ stream .playerName = playerName ;
396
+ return (String ) stream .send ();
331
397
}
332
398
public void hideTag (boolean enable ){
333
-
399
+ DoStream doStream = new DoStream ();
400
+ doStream .method = "HideTag" ;
401
+ doStream .args = new String []{enable +"" };
402
+ doStream .playerName = playerName ;
403
+ doStream .send ();
334
404
}
335
405
336
406
public void personalBroadcast (int duration , String message , boolean isMonoSpaced ){
337
-
407
+ DoStream doStream = new DoStream ();
408
+ doStream .method = "PersonalBroadcast" ;
409
+ doStream .args = new String []{duration +"" ,message ,isMonoSpaced +"" };
410
+ doStream .playerName = playerName ;
411
+ doStream .send ();
338
412
}
339
413
340
414
public void personalClearBroadcasts (){
341
-
415
+ DoStream doStream = new DoStream ();
416
+ doStream .method = "PersonalClearBroadcasts" ;
417
+ doStream .playerName = playerName ;
418
+ doStream .send ();
342
419
}
343
420
344
421
//hasPermission未来搞
345
422
346
423
public boolean hasPermission (String permissionName ){
347
- return false ;
424
+ DoGetStream stream = new DoGetStream (Boolean .class );
425
+ stream .method = "HasPermission" ;
426
+ stream .args = new String []{permissionName };
427
+ stream .playerName = playerName ;
428
+ return (Boolean )stream .send ();
348
429
}
349
430
350
431
public Vector get106Portal (){
351
- return null ;
432
+ DoGetStream stream = new DoGetStream (Vector .class );
433
+ stream .method = "Get106Portal" ;
434
+ stream .playerName = playerName ;
435
+ return (Vector )stream .send ();
352
436
}
353
437
354
438
public void setRadioBattery (int battery ){
355
-
439
+ DoStream stream = new DoStream ();
440
+ stream .method = "SetRadioBattery" ;
441
+ stream .playerName = playerName ;
442
+ stream .args = new String []{battery +"" };
443
+ stream .send ();
356
444
}
357
445
public void handcuffPlayer (IPlayer playerToHandcuff ){
358
-
446
+ DoApiStream stream = new DoApiStream ();
447
+ stream .playerName = playerName ;
448
+ stream .value = playerToHandcuff ;
449
+ stream .method = "HandcuffPlayer" ;
450
+ stream .send ();
359
451
}
360
452
public void removeHandcuffs (){
453
+ DoStream stream = new DoStream ();
454
+ stream .playerName = playerName ;
455
+ stream .method = "RemoveHandcuffs" ;
456
+ stream .send ();
361
457
362
458
}
363
459
public boolean getGhostMode (){
364
- return false ;
460
+ DoGetStream stream = new DoGetStream (Boolean .class );
461
+ stream .method = "GetGhostMode" ;
462
+ stream .playerName = playerName ;
463
+ return (Boolean ) stream .send ();
365
464
}
366
465
public void setGhostMode (boolean ghostMode , boolean visibleToSpec , boolean visibleWhenTalking ){
367
-
466
+ DoStream stream = new DoStream ();
467
+ stream .method = "SetGhostMode" ;
468
+ stream .playerName = playerName ;
469
+ stream .args = new String []{ghostMode +"" ,visibleToSpec +"" ,visibleWhenTalking +"" };
470
+ stream .send ();
368
471
}
369
472
370
473
}
0 commit comments