每个玩家的杀戮次数始终相同。 (Bukkit)

时间:2015-05-12 18:26:30

标签: java bukkit

当我编码时,我测试了我的插件,这似乎发生了: 基本上,当一名玩家杀死另一名玩家时,他的杀人数量会增加一个。然而,当玩家例如5次杀死时,所有其他玩家也将杀死。这是我的代码:

file:///C:/xampp/htdocs/folder1/subfolder1/

非常感谢你们! :)

1 个答案:

答案 0 :(得分:1)

The problem is that you're increasing the same variable for every time a player kills another player. To fix this, you should use a different variable for each player, for example ID = 53030, Title = GeneralFeedback and "kills.playerUUIDHere".

To get a player's UUID, you can use player.getUniqueId(), then to get the "deaths.playerUUIDHere" representation of the UUID, you could use uuid.toString(). So, you could do something like this to change a player's kills:

String

The same logic can be used for deaths, so, you could use something like this for your String uuid = player.getUniqueId().toString(); int kills = kdc.getConfig().getInt("playerkills." + uuid); kdc.getConfig().set("playerkills." + uuid, kills += 1); method:

playerKillsPlayer()