Scoreboard help

Discussion in 'Spigot Plugin Development' started by flyvendetorsk, Jun 21, 2015.

  1. How do i get away weird p.getActivePotionEffect() to be normal ?
    This is what shows up on scoreboard:
    [FAST_DIGGING:9999209t-x1)]



    Code (Text):
                if(p.hasPermission("datavesen.haste")) {
                        o.getScore(p.getActivePotionEffects() + "").setScore(-3);
               
                }else {
                    o.getScore("§7No effect §6/buy").setScore(-3);
                }
                    p.setScoreboard(s);
                 
                }
     
  2. You are just calling toString (). Take the data and build up a string to what you think is suitable.
     
  3. I made this out of it:
    Code (Text):
    o.getScore(p.getActivePotionEffects().toString().replace("FAST_DIGGING", "Haste").replace("[", "").replace("]", "").replace(":", " ").replace("(", "").replace(")", "").replace("x", "§aNivå: ").replace("-", "").replace("t", "§aTid ")).setScore(-3);
    I dont know how to get away the numbers
     
  4. Get active potion effects returns a collection of potion effects. Calling toString () on a collection puts everything is a comma seperated list with [ ] on each end. Each value in this created list is found by calling toString () on each PotionEffect.

    Instead of just leaving it all iterate through the collection and format the potion effect how you want.
    PotionEffect#getAmplifier ()
    PotionEffect#getDuration ()
    PotionEffect#getType ()
    All the information you need is available.