我編寫了一個沒有錯誤的Bukkit插件,但是在遊戲中它有一個問題。Bukkit命令重複嗎?
無論什麼時候使用該命令,它都不會做它應該做的事情。相反,它向我發送了一條大膽的消息,說明我輸入的內容是/leaving
。
這裏是我的代碼:
public class SeeYouSoon extends JavaPlugin{
// Start
@Override
public void onEnable(){
}
@Override
public void onDisable() {
}
//Commands
public boolean onCommand(CommandSender sender, Command cmd, String[] args){
if(cmd.getName().equalsIgnoreCase("leaving")){
Player player = (Player) sender;
Bukkit.broadcastMessage(ChatColor.RED + player.getName() + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + " is about to leave the server. Please say your goodbyes!");
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
public void run() {
//Run your function or change stuff here.
player.kickPlayer(ChatColor.RED + "Kicked:" + ChatColor.WHITE + " You requested to leave.");
}
}, 20 * 30);// There are 20 ticks in one second so we can just multiply seconds by 20.
}
return false;
}
}
的plugin.yml是我所期望的問題是。這裏是plugin.yml:
name: SeeYouSoon
main: me.mark.SeeYouSoon
version: 1.0
commands:
leaving:
description: Announce your leave
請包括一個更好的問題說明,並實際負責代碼 – Felk
@jojodmo現在命令不會做任何事 –