我正在为游戏编写插件。这可能是一个非常简单的答案,我已经盯着它看了大约15分钟,并且无法弄清楚其他声明中的错误是什么。它是在if语句之后,但Eclipse仍然表示存在语法错误。我确信这是一个简单的解决办法,但我一直在躲避我。先感谢您。
@EventHandler (priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent event)
{
Player sender = event.getPlayer();
String sentmessage = event.getMessage();
if (sentmessage.charAt(0) == '@')
{
event.setCancelled(true);
String message = "";
ArrayList<String> recipients = new ArrayList<String>();
recipients.add("");
int nor = 0;
for (int x = 1; true; x++)
{
if (sentmessage.charAt(x) != ' ')
{
recipients.set(nor, recipients.get(nor) + sentmessage.charAt(x));
}
else if (sentmessage.charAt(++x) == '@');
{
nor++;
recipients.ensureCapacity(nor);
recipients.add("");
}
else //Syntax error is on this else statement
{
message = sentmessage.substring(x);
break;
}
}
plugin.privateMessage(recipients, sender, message);
}
}
答案 0 :(得分:4)
else if (sentmessage.charAt(++x) == '@');
在结尾处删除;
应该是:
else if (sentmessage.charAt(++x) == '@'){
.........
}