@@ -95,6 +95,7 @@ static NetworkHandler()
9595 handlers . Add ( 194 , new HandleUserGroup ( ) ) ;
9696 handlers . Add ( 195 , new HandleDoApi ( ) ) ;
9797 handlers . Add ( 196 , new HandleMapApi ( ) ) ;
98+ handlers . Add ( 197 , new HandleServerApi ( ) ) ;
9899 }
99100 public static void handleJsmod2 ( int id , String json , Dictionary < string , string > mapper , TcpClient client )
100101 {
@@ -222,35 +223,9 @@ public static bool isCommon(Type returnType)
222223 || returnType == typeof ( int ) || returnType == typeof ( long ) || returnType == typeof ( char )
223224 || returnType == typeof ( byte ) || returnType == typeof ( short ) ;
224225 }
225- }
226226
227- /**
228- * 为map定制的Handler
229- */
230- //value 值 字段 1
231- //args 参数 方法
232- //method 方法名
233- //field 字段名 1
234- //write 读 字段_赋值 方法_无返回值 1 0
235- //read 写 字段_得到值 方法_有返回值 1 0
236- //apiId 说明设置的值是api对象 1
237-
238- //字段的输出包分为以下的要素
239- // field 字段
240- // value 值
241- //read write 可读性
242- // apiId 是否是api类型
243- //方法的输出包分为以下的要素
244- //method 方法
245- //args 参数
246- //write 可读性
247-
248- public class HandleMapApi : Handler
249- {
250- public JsonSetting [ ] handle ( object api , Dictionary < string , string > mapper )
227+ public static JsonSetting [ ] invoke ( object map , Type type , Dictionary < string , string > mapper )
251228 {
252- Map map = ProxyHandler . handler . Server . Map ;
253- Type type = typeof ( Map ) ;
254229 if ( mapper . ContainsKey ( "field" ) ) //field
255230 {
256231 PropertyInfo info = type . GetProperty ( "field" ) ;
@@ -444,9 +419,34 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
444419 return Utils . getOne ( mapper [ "id" ] , null , new IdMapping ( )
445420 . appendId ( Lib . ID , Guid . NewGuid ( ) . ToString ( ) , player ) . appendId ( Lib . PLAYER_SCPDATA_ID , Guid . NewGuid ( ) . ToString ( ) , player . Scp079Data ) . appendId ( Lib . PLAYER_TEAM_ROLE_ID , Guid . NewGuid ( ) . ToString ( ) , player . TeamRole )
446421 ) ;
422+
447423 }
448-
449-
424+
425+ if ( obj is List < Connection > )
426+ {
427+ List < Connection > connections = ( List < Connection > ) obj ;
428+ JsonSetting [ ] settings = new JsonSetting [ connections . Count ] ;
429+ for ( int i = 0 ; i < connections . Count ; i ++ )
430+ {
431+ settings [ i ] = new JsonSetting ( Lib . getInt ( mapper [ "id" ] ) , null , new IdMapping ( )
432+ . appendId ( Lib . ID , connections [ i ] )
433+ ) ;
434+ }
435+
436+ return settings ;
437+
438+ }
439+
440+ if ( obj is List < TeamRole > )
441+ {
442+ List < TeamRole > teamRoles = ( List < TeamRole > ) obj ;
443+ JsonSetting [ ] settings = new JsonSetting [ teamRoles . Count ] ;
444+ for ( int i = 0 ; i < settings . Length ; i ++ ) {
445+ settings [ i ] = new JsonSetting ( Lib . getInt ( mapper [ "id" ] ) , null , new IdMapping ( ) . appendId ( Lib . ID , teamRoles [ i ] ) ) ;
446+ }
447+ return settings ;
448+ }
449+
450450 }
451451 else
452452 {
@@ -462,6 +462,46 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
462462 }
463463}
464464
465+ /**
466+ * 为map定制的Handler
467+ */
468+ //value 值 字段 1
469+ //args 参数 方法
470+ //method 方法名
471+ //field 字段名 1
472+ //write 读 字段_赋值 方法_无返回值 1 0
473+ //read 写 字段_得到值 方法_有返回值 1 0
474+ //apiId 说明设置的值是api对象 1
475+
476+ //字段的输出包分为以下的要素
477+ // field 字段
478+ // value 值
479+ //read write 可读性
480+ // apiId 是否是api类型
481+ //方法的输出包分为以下的要素
482+ //method 方法
483+ //args 参数
484+ //write 可读性
485+
486+ public class HandleMapApi : Handler
487+ {
488+ public JsonSetting [ ] handle ( object api , Dictionary < string , string > mapper )
489+ {
490+ Map map = ProxyHandler . handler . Server . Map ;
491+ Type type = typeof ( Map ) ;
492+ return Utils . invoke ( map , type , mapper ) ;
493+ }
494+ }
495+
496+ public class HandleServerApi : Handler
497+ {
498+ public JsonSetting [ ] handle ( object api , Dictionary < string , string > mapper )
499+ {
500+ Server server = ProxyHandler . handler . Server ;
501+ Type tp = typeof ( Server ) ;
502+ return Utils . invoke ( server , tp , mapper ) ;
503+ }
504+ }
465505
466506/**
467507 * 调用方法,可以设置api的值
0 commit comments