Solved Why doesn't that work?

Discussion in 'Plugin Development' started by monkafynix, Nov 29, 2019.

  1. Offline

    monkafynix

    Code:
    switch(countdowns) {
                                default:
                                if(countdowns >= 9) {
                                    countdowns = -1;
                                    countdowns1++;
                                    if(countdowns >= 9 & countdowns1 >= 5) {
                                        countdowns1 = -1;
                                        countdownm++;
                                        if(countdownm >= 9) {
                                            countdowns = -1;
                                            countdowns1 = -1;
                                            countdownm = -1;
                                            countdownm1++;
                                            if(countdownm >= 9  & countdownm1 >= 5 ) {
                                                countdownm1 = -1;
                                                countdownh++;
                                                if(countdownh >= 9) {
                                                    countdownh = -1;
                                                    countdowns = -1;
                                                    countdowns1 = -1;
                                                    countdownm = -1;
                                                    countdownm1 = -1;
                                                  
                                                    countdownh1++;
                                                  
                                                  
                                                  
                                                }
                                              
                                              
                                            }
                                          
                                          
                                        }
                                      
                                      
                                    }
                                  
                                  
                                  
                                }
                                  
                                  
                                  
                              
                              
                                }countdowns++;
    I want to make a stopwatch look good in the ActionBar, but it keep updating the seconds and not the minutes or hours.

    Code:
    PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.ACTIONBAR,
                                        ChatSerializer.a("{\"text\":\"§6Der Timer läuft:§f "+ countdownh1 +countdownh +":"+ countdownm1 + countdownm +":"+ countdowns1 +countdowns +"\"}"),2147483647,2147483647,2147483647);
                                ((CraftPlayer)player).getHandle().playerConnection.sendPacket(title);
    this is my ActionBar btw.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 29, 2019
  2. Offline

    Strahan

    Holy Christ, what the heck is going on there? That's insane.

    Just log seconds and use that to build the countdown timer display. So like if I have a variable that holds total seconds, to build the display I'd do:
    Code:
    String disp = String.format("%02d", seconds / 3600) + ":";
    disp += String.format("%02d", (seconds % 3600) / 60) + ":";
    disp += String.format("%02d", seconds % 60 / 1);
     
    monkafynix and Zombie_Striker like this.
  3. Offline

    monkafynix

    Yo thx mate
     

Share This Page