2014-11-03 37 views
-3

我正在製作一個插件,你可以使用一個帶有咒語的物品,但我有一個問題,我不知道如何製作一個計劃程序以及如何使用該方法獲取玩家。此外,我將爲更多的1名球員。Bukkit物品LIVE倒計時

我也想讓它,我可以調用像方法:

public void playertimer (Player player, Integer time) { 
    // Do things 
} 

public void stoptimer(Player player) { 
    // Do things 
} 

我也希望能夠看到在項目欄中的倒計時。

+0

有人想幫我嗎? – CaptainStony 2014-11-04 17:59:50

回答

0

我在這裏得到的是我使用的代碼: MainClass mainclass;

public commands(MainClass plugin) { 
    mainclass = plugin; 
} 
int cooldown; 
int i = 10; 
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { 
    final Player player = (Player) sender; 

    if(cmd.getName().equalsIgnoreCase("timer")) { 
     cooldown = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(mainclass, new Runnable(){ 

      public void run(){ 
       if(i != -1){ 
        if(i != 0){ 
         Bukkit.broadcastMessage(ChatColor.AQUA + "" + i); 
         ItemStack test = Manager.getManager().setNameAndLore(Material.APPLE, i, "lolz", "lolzz"); 
         ItemStack testremove = Manager.getManager().setNameAndLore(Material.APPLE, 64, "lolz", "lolzz"); 
         player.sendMessage(mainclass.getConfig().getBoolean("wom.players." + player + ".rogue") + ""); 
         player.getInventory().removeItem(testremove); 
         player.getInventory().addItem(test); 
         i--; 
        }else{ 
         Bukkit.broadcastMessage(ChatColor.GREEN + "begin"); 
         i--; 
         Bukkit.getServer().getScheduler().cancelTask(cooldown); 

        } 
       } 
      } 

     },0L ,20L); 
     i = 10; 
    }