1818import cn .jsmod2 .core .CommandSender ;
1919import cn .jsmod2 .core .Server ;
2020import 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 ;
2527
2628import java .io .Serializable ;
2729import java .util .List ;
@@ -243,43 +245,77 @@ public void ban(int duration,String message){
243245 }
244246
245247 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 ();
247252 }
248253
254+ @ SuppressWarnings ("unchecked" )
249255 public List <Item > getInventory (){
250- return null ;
256+ GetInventoryPacket packet = new GetInventoryPacket ();
257+ packet .playerName = playerName ;
258+ return packet .send ();
251259 }
252260
253261 public Item getCurrentItem (){
254- return null ;
262+ GetCurrentItemPacket packet = new GetCurrentItemPacket ();
263+ packet .playerName = playerName ;
264+ return packet .send ();
255265 }
256266
257267 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 ();
259273 }
260274
261275 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 ();
263280 }
264281
265282 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 ();
267288 }
268289
269290 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 ();
271296 }
272297
273298 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 ();
275304 }
276305
277306 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 ();
279311 }
280312
281313 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 ();
283319 }
284320
285321 //这里未来解决
@@ -288,83 +324,150 @@ public Object getGameObject(){
288324 }
289325
290326 public UserGroup getUserGroup (){
291- return null ;
327+ GetUserGroupPacket packet = new GetUserGroupPacket ();
328+ packet .playerName = playerName ;
329+ return packet .send ();
292330 }
293331
294332 public boolean runCommand (String command ,String [] args ){
295333 return Server .getSender ().getServer ().getPluginManager ().executeCommand (command ,args ,this );
296334 }
297335
298336 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 ();
300341 }
301342
302343 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 ();
304349 }
305350
306351 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 ();
308356 }
309357
310358 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 ();
312364 }
313365 public void sendConsoleMessage (String message ){
314366 sendConsoleMessage (message ,"green" );
315367 }
316368
317369 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 ();
319375 }
320376 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 ();
322382 }
323383 public void throwGrenade (GrenadeType grenadeType , boolean isCustomDirection , Vector direction , boolean isEnvironmentallyTriggered , Vector position , boolean isCustomForce , float throwForce ){
324384 throwGrenade (grenadeType ,isCustomDirection ,direction ,isEnvironmentallyTriggered ,position ,isCustomForce ,throwForce ,false );
325385 }
326386 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 ();
328391 }
329392 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 ();
331397 }
332398 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 ();
334404 }
335405
336406 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 ();
338412 }
339413
340414 public void personalClearBroadcasts (){
341-
415+ DoStream doStream = new DoStream ();
416+ doStream .method = "PersonalClearBroadcasts" ;
417+ doStream .playerName = playerName ;
418+ doStream .send ();
342419 }
343420
344421 //hasPermission未来搞
345422
346423 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 ();
348429 }
349430
350431 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 ();
352436 }
353437
354438 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 ();
356444 }
357445 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 ();
359451 }
360452 public void removeHandcuffs (){
453+ DoStream stream = new DoStream ();
454+ stream .playerName = playerName ;
455+ stream .method = "RemoveHandcuffs" ;
456+ stream .send ();
361457
362458 }
363459 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 ();
365464 }
366465 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 ();
368471 }
369472
370473}
0 commit comments