怎么把别人网站模板下载出来,wordpress渗透经验,论企业网站建设的必要性,网站用户反馈上一节内容结束后确实可以写入文件了#xff0c;但还有两个问题#xff1a;
1.一个是players.txt中#xff0c;每次重启服务器#xff0c;当注册新账号创建角色时#xff0c;players.txt之前内容都会清空。
2.players.txt之前已经注册3次的账号#xff0c;新注册的角色…上一节内容结束后确实可以写入文件了但还有两个问题
1.一个是players.txt中每次重启服务器当注册新账号创建角色时players.txt之前内容都会清空。
2.players.txt之前已经注册3次的账号新注册的角色信息不会写入players.txt猜测与userPlayerIds.txt中的残留内容有关。但userPlayerIds.txt中的内容感觉不全
先解决第一个问题上边 userPlayerIds.txt的内容是可以成功读出来并且转化的players.txt中的内容转化失败所以此时就是空的 就是json转换结构体上出现了问题账号那可以的换到这就出问题了
对比来看AccountModel和PlayerModel基本上大同小异
Newtonsoft.Json.JsonSerializationException:“Unable to find a constructor to use for type GameServer.model.PlayerModel. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 431b0501-457f-46ba-91dd-353c8a3c8c0c.id, line 3, position 9.”
Newtonsoft。Json。JsonSerializationException“找不到用于类型GameServer.model.PlayerModel的构造函数。类应该有一个默认构造函数、一个带参数的构造函数或一个用JsonConstructor属性标记的构造函数。路径431b0501-457f-46ba-91dd-353c8a3c8c8c.id第3行位置9。”
就是PlayerModel类没有构造函数
namespace GameServer.model
{internal class PlayerModel{public string id { get; set; }public string name { get; set; }public int job { get; set; }public int level { get; set; }public int exp { get; set; }public int atk { get; set; }public int def { get; set; }public int hp { get; set; }public int maxHp { get; set; }public Vector3 point { get; set; }public Vector4 rotation { get; set; }public int map { get; set; }public PlayerModel(PlayerModel model){this.job model.job;this.level model.level;this.exp model.exp;this.atk model.atk;this.def model.def;this.hp model.hp;this.maxHp model.maxHp;}public PlayerModel(int job,int level,int exp,int atk,int def,int map,int hp,int maxHp){this.job job;this.level level;this.exp exp;this.atk atk;this.def def;this.map map;this.hp hp;this.maxHp maxHp;}}
}很明显是有构造函数的还有2个没想到再加一个
public PlayerModel() { } 的确是解决了