这是代码。不确定什么是错的。发生在说
的那一行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;
}
答案 0 :(得分:0)
确保World.getPlayers()返回实现java.lang.Iterable
答案 1 :(得分:0)
问题出在for循环中。将其更改为
for (Object player : World.getPlayers()) {
if (((Player)player).getRights() > 0)
players.getPackets().sendGameMessage(Misc.formatPlayerNameForDisplay(player.getUsername())+" has issued a assistance request.", true);
}
}
这应该有效。