gpt4 book ai didi

java - 类型不匹配 : cannot convert from element type Object to Player

转载 作者:行者123 更新时间:2023-12-01 05:29:57 26 4
gpt4 key购买 nike

这是代码。不知道出了什么问题。发生在显示

的行
for (Player players : World.getPlayers()) {
if (cmd[0].equalsIgnoreCase("ticket")) {
if (player.getRights() > 0) {
if (World.getTicketList().size() == 0) {
player.getPackets().sendGameMessage("No one needs help so sit back and relax.");
return true;
}
String username = World.getTicketList().get(0).toString();
Player p2 = World.getPlayer(username);
player.setNextWorldTile(p2);
p2.getPackets().sendGameMessage("Please ask your question to " + Misc.formatPlayerNameForDisplay(player.getUsername()) + ".");
World.remoteTicket(username.toLowerCase());
return true;
}
if (World.getTicketList().contains(player.getUsername().toLowerCase())) {
player.getPackets().sendGameMessage("You already submitted a ticket.", true);
return true;
}
World.addToTicket(player.getUsername());
player.getPackets().sendGameMessage("Your ticket has been submitted. Your ticket number is " + World.getTicketId(player.getUsername()) + 1 + ".");
player.getPackets().sendGameMessage("Make sure that you are not in a PvP area..");
String username = World.getTicketList().get(0).toString();
for (Player players : World.getPlayers()) {
if (player.getRights() > 0) {
players.getPackets().sendGameMessage(Misc.formatPlayerNameForDisplay(player.getUsername()) + " has issued a assistance request.", true);
}
}
return true;
}
}

编辑:

这是 getPlayers 的代码

public static final EntityList getPlayers() {
return players;
}

最佳答案

确保 World.getPlayers() 返回的任何内容都实现 java.lang.Iterable

关于java - 类型不匹配 : cannot convert from element type Object to Player,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9137643/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com