Hey I've already implemented a timer but when I right click the sign it doesn't seem to broadcast the seconds/time? Here's the code Code:java if (sign.getLine(0).contains("[teleport]")); { isCancelled = false; getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { public void run() { if (isCancelled == false) { time = time -1; Bukkit.broadcastMessage("Message prefix"+time); plugin.getServer().broadcastMessage("Message prefix"+time); if (time == 0) { plugin.getServer().getScheduler().cancelTask(taskID); time=5; } } } }, 0, 40);
ShredNyx You have a semicolon before the bracket in line 1. Code: if (sign.getLine(0).contains("[teleport]")); {
What will that change though? Assist Doesn't change anything Assist EDIT by Moderator: merged posts, please use the edit button instead of double posting.
ShredNyx Debug your code. Make sure you have the @EventHandler annotation, and that you have registered your events.
Code:java import org.bukkit.Bukkit;import org.bukkit.ChatColor;import org.bukkit.Location;import org.bukkit.Material;import org.bukkit.block.Block;import org.bukkit.block.Sign;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.block.Action;import org.bukkit.event.block.SignChangeEvent;import org.bukkit.event.player.PlayerInteractEvent;import org.bukkit.plugin.Plugin;import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener{public static int time = 5; //time in secondspublic static Boolean isCancelled;public static int taskID;Plugin plugin; @Overridepublic void onEnable() {getServer().getPluginManager().registerEvents(this, this);//getServer().getPluginManager().registerEvents(new ClickSignListener(), this);}@EventHandlerpublic void signPlace(SignChangeEvent e) {if(e.getLine(0).contains("[teleport]")) {e.setLine(0, ChatColor.GREEN +"[teleport]");}} @EventHandlerpublic void signInteract(PlayerInteractEvent e) {if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {Block block = e.getClickedBlock();if(block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {Sign sign = (Sign) e.getClickedBlock().getState();if(sign.getLine(0).contains("[teleport]")) {e.getPlayer().teleport(new Location(e.getPlayer().getWorld(), 100, 100, 100));isCancelled = true;}else {if (sign.getLine(0).contains("[teleport]")) {isCancelled = false;getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {public void run() {if (isCancelled == false) {time = time -1;Bukkit.broadcastMessage("Message prefix"+time);plugin.getServer().broadcastMessage("Message prefix"+time);if (time == 0) {plugin.getServer().getScheduler().cancelTask(taskID);time=5;}}}}, 0, 40);}} }}}} I've tried everything but could find the solution to why it isn't working Please advise chasechocolate EDIT by Moderator: merged posts, please use the edit button instead of double posting.
ShredNyx Try changing this line: Code:java getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { to this: Code:java getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {