Hello, Is it possibel to make timer, but not in mainclass. I need to start timer for 10 seconds if player writes /t Thank you
kevin3220 To awnser your question, absolutey. People use countdowns all the time (Join a server with a minigame). Use the bukkit scheduler. There are plent of tutorials on youtube, I find that the best is from pogostick29dev
Dosent work ;( Code:java public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){ play=(Player) sender; if(label.equalsIgnoreCase("test")){ Location loc=new Location(Bukkit.getWorld("world"), -104, 67, 307); int minuoma=-104+67+307-1; Location pl=play.getLocation(); int summa=pl.getBlockX()+pl.getBlockY()+pl.getBlockZ(); if(minuoma==summa){ juhus=ra.nextInt(10); if(juhus<=6){ Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { @Override public void run() { Bukkit.broadcastMessage("TESTUNG"); } },0L,100L); return true; }else{ play.sendMessage("FAIL"); return true; } }else{ play.sendMessage("You are not @ test location!"); return true; } } return false;}}
Befor you post this code you should look for a tutorial how to format your source code, that i can read it without searching for the if, witch belongs to the else. Example: Code:java if (boolean1) { System.out.println("boolean1 is true");} if (boolean2) { System.out.println("boolean2 is true");} else { System.out.println("boolean2 is false"); if (boolean3) { System.out.println("boolean3 is true"); } else { System.out.println("boolean3 is false"); }} It would be also nice, if you tell us what this should do. Now about your code: Why do you add your locations, and compare the sum? You can also compare your locations, or the single coordinates. I see you use a repeating task. I thought you need a delay. If you only need a delay of 10 seconds, you should use a delayed task. For 10 seconds you have to write 200L instead of 100L, because 1 second = 20 ticks. Your code will write TESTUNG every 5 seconds. I don´t know what you want to do, but in my opinion this code is waste! (Sry for my bad english!)
it was Alpha code xD Yeah, i know Java. I am new with tasks. In Java i use Thread.sleep(). I tried that once in Bukkit... It went wrong;( EDIT by Moderator: merged posts, please use the edit button instead of double posting.