我有一个问题,我无法解决它。
好吧,我得到了反序列化列表的代码,但是在这个列表中,我得到了我的对象“团队”
Object team
public Team(String name, String itemName, ChatColor color, String worldName, int spawnX,
int spawnY, int spawnZ, Material material,
List<UUID> playerList, OneBlock oneBlock, int maxPlayerAllowed, int buildX, int buildY, int buildZ) {
this.name = name;
this.itemName = itemName;
this.color = color;
this.spawnWorld = worldName;
this.spawnX = spawnX;
this.spawnY = spawnY;
this.spawnZ = spawnZ;
this.material = material;
this.playerList = playerList;
this.oneBlock = oneBlock;
this.maxPlayerAllowed = maxPlayerAllowed;
this.buildX = buildX;
this.buildY = buildY;
this.buildZ = buildZ;
}
Deserialize method
public <T> List<T> deserializeList(String json, Class<T> type) {
TypeToken<Collection<Class<T>>> collectionType = new TypeToken<>() {
};
return this.gson.fromJson(json, collectionType.getType());
}
当我尝试反序列化时出现此错误:
java.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap cannot be cast to class fr.wailroth.buildbattle.team.Team (com.google.gson.internal.LinkedTreeMap is in unnamed module of loader 'app'; fr.wailroth.buil
dbattle.team.Team is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @773c2bb4)
有人可以帮助我吗?