2015-06-23 46 views

回答

1

要收聽此活動,作爲迴應,請更改motd,您需要一個Listener。定義實現Listener類(比方說FooListener)用下面的方法聲明:

@EventHandler 
public void onServerListPingEvent(ServerListPingEvent event) { 
    event.setMotd("Some MOTD"); 
} 

然後,您需要在您的插件類的onLoad()onEnable()方法之一來註冊這個監聽器。這樣做是這樣的:

@Override 
public void onLoad() { // or onEnable() 
    // other stuff 
    getServer().getPluginManager().registerEvents(new FooListener(), this); 
} 

如果你想給你的MOTD上色,查找它。您必須使用節符號(§)。

+0

感謝它的工作原理:D但'@EventHandler',而不是'@EventListener' – 10anat10

+1

@ 10anat10是的,對不起。我從記憶中寫下了這個答案。 – bcsb1001