Trying to create a timer

Discussion in 'Spigot Plugin Development' started by ryu, Jun 12, 2016.

Thread Status:
Not open for further replies.
  1. ryu


    Hello I am trying to create a command where when you do /timer it sends the player a message with the time remaining. But for some reason I am getting an error when I start up the server and I don't know why.


    Code (Text):
    [03:30:18] [Server thread/INFO]: [0;32;1mWithdraw Advanced [0;33;1mhas been enabled![m
    [03:30:18] [Server thread/ERROR]: Error occurred while enabling WithdrawAdvanced v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: Illegal pattern character 'r'
        at java.text.SimpleDateFormat.compile(Unknown Source) ~[?:1.8.0_91]
        at java.text.SimpleDateFormat.initialize(Unknown Source) ~[?:1.8.0_91]
        at java.text.SimpleDateFormat.<init>(Unknown Source) ~[?:1.8.0_91]
        at java.text.SimpleDateFormat.<init>(Unknown Source) ~[?:1.8.0_91]
        at dev.ryujix.withdraw.Commands.Timer.<init>( ~[?:?]
        at dev.ryujix.withdraw.WithdrawAdvanced.registerCommands( ~[?:?]
        at dev.ryujix.withdraw.WithdrawAdvanced.onEnable( ~[?:?]
        at ~[1.8.jar:git-Spigot-550ebac-7019900]
        at [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.reload( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.Bukkit.reload( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.command.defaults.ReloadCommand.execute( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.command.SimpleCommandMap.dispatch( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand( [1.8.jar:git-Spigot-550ebac-7019900]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchServerCommand( [1.8.jar:git-Spigot-550ebac-7019900]
        at net.minecraft.server.v1_8_R1.DedicatedServer.aM( [1.8.jar:git-Spigot-550ebac-7019900]
        at net.minecraft.server.v1_8_R1.DedicatedServer.z( [1.8.jar:git-Spigot-550ebac-7019900]
        at net.minecraft.server.v1_8_R1.MinecraftServer.y( [1.8.jar:git-Spigot-550ebac-7019900]
        at [1.8.jar:git-Spigot-550ebac-7019900]
        at Source) [?:1.8.0_91]
  2. Code (Text):
    private SimpleDateFormat format = new SimpleDateFormat("hh hr mm min ss sec");
    That hR is giving the error. ;)
  3. ryu


    Would you know how I would be able to label everything so like hours mins seconds?
    bc this is what I'm getting atm:
  4. Bruh.. Just use a for statement in a repeating task..

    Code (Text):
    //(You can use a int outside of the method for cancellation, so public static int a; then a = (code))
    //String is countdown
    final String string = "";
    Bukkit.getScheduler().scheduleSyncRepeatinTask(plugin, new Runnable(){
        public void run(){
            for(int i = 10; i <= 0;i--) {//By putting 10, it has a delay of 10 seconds
                string = ""+i;
                if(i == 0){
                    i = 10;
    }, 0L, 20L); //20 ticks = 1 second
    • Useful Useful x 1
    • Optimistic Optimistic x 1
  5. final String string = "";
    string = ""+i;

    Good luck with that ;)
    • Funny Funny x 1
Thread Status:
Not open for further replies.