我正在研究一个bukkit插件,当玩家退出时我需要保存数据。我写了一个可以正常工作的系统,但是它基于玩家的名字,如果玩家改变他们的名字就会丢失数据。所以我的问题是:每次玩家登录时是否有任何财产(例如:身份证)女巫是否一样?存储玩家特定数据
存储玩家特定数据
回答
你可以使用播放器的UUID
,或ü niversal ü SER ID entification。要获得玩家的UUID
,您可以使用player.getUniqueId()
。您也可以使用OfflinePlayers
。
用于存储当玩家通过自己的UUID
将退出的实例方法:
@EventHandler
public void playerQuit(PlayerQuitEvent e){
String uuid = e.getPlayer().getUniqueId().toString(); // get the user's UUID
long time = System.currentTimeMillis()/1000; // get the current number of seconds
plugin.getConfig().set(uuid, time); // set the UUID in the config to the current # of seconds
}
然后,让他们最后出场的日子:
public Date getLastPlayedDate(String p){
String uuid = Bukkit.getOfflinePlayer(p).getUniqueId().toString(); // get the uuid from the OfflinePlayer
long time = plugin.getConfig().getLong(uuid); // get the time associated with the uuid
Date date = new Date(time * 1000); // convert the time to the date
return date; // return the date
}
注意:'UUID'代表__Universally Unique Identifier__。 – Unihedron
@Unihedron它可以代表许多事情。大多数情况下,使用Minecraft玩家时,它是* Universal User Identifier *,因为它只与用户打交道。如果我们正在做一些类似Minecraft的小怪,它将是一个*通用唯一标识符*,因为我们没有对用户做任何事情。 – Jojodmo
__Universally唯一标识符___是由OSF创建和设置的术语。如果你能指出我的资源,清楚说明你刚刚说的话,那将是惊人的。否则,[这里是维基百科条目](http://en.wikipedia.org/wiki/Universally_unique_identifier)。 – Unihedron
- 1. 在RLua储存玩家数据
- 2. Android保存玩家数据
- 3. Android储蓄玩家分数
- 4. Windows Phone存储国家特定集合
- 5. 保存玩家库存
- 6. 如何将玩家存储在数组中?
- 7. SQL数据库是否适合存储许多玩家及其游戏?
- 8. 基于浏览器的RPG:使用会话来存储玩家数据
- 9. Android - 储蓄玩家数据 - 3个不同选项的比较
- 10. 使用HTML本地存储器存储用户特定数据
- 11. RPG任务 - 查询玩家数据
- 12. websocket游戏 - 坚持玩家数据
- 13. Android:随机数决定玩家轮到
- 14. 的Yahtzee,需要指定玩家分数
- 15. 玩家类中需要玩家对象
- 16. Bukkit:如何存储玩家和课程信息?
- 17. 我应该使用哪个列表来存储玩家信息?
- 18. 表中的玩家数量?
- 19. 免费的方式来存储谷歌玩家帐户的自定义数据。 (Android,GPGS)
- 20. 寻找与其他玩家出场两次玩过的玩家
- 21. 如何设计存储用户特定数据的数据库
- 22. 在oracle数据库中将数据存储为特定时间
- 23. 存储来自SPListItem数据的特定数据?
- 24. 存储特定结构化数据的最佳数据结构
- 25. 如何在MySQL数据库中存储特定(polls eg。)数据?
- 26. 玩家配置
- 27. PostgreSQL在玩家
- 28. 周围玩家
- 29. 计算玩家
- 30. 在玩家
[第一款谷歌的结果(HTTPS: //www.google.com/search?q=java%20minecraft%20get%20player%20id):[从玩家名称移至UUID。](https://forums.bukkit.org/threads/tut-moving-from -player-names-to-uuid.241626 /) – BackSlash