Solved Retrieve color out of fireworkstar

Discussion in 'Plugin Development' started by UnrealPowerz, Jan 1, 2014.

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

    UnrealPowerz

    Hi everyone,

    I can't seem to get the colors of a fireworkstar.

    Code:java
    1.  
    2. // checks if item is fireworkstar
    3. FireworkEffect effect = ((FireworkEffectMeta) item.getItemMeta()).getEffect();
    4. String output;
    5. output = "Colors: " + Joiner.on(", ").join(colorsToString(effect.getColors());
    6.  
    7. List<String> colorsToString(List<Color> bukkitColors){
    8. List<String> colors = new ArrayList<String>();
    9. for (Color currentColor : bukkitColors) {
    10. if (currentColor == Color.AQUA) colors.add("Aqua");
    11. else if (currentColor == Color.BLACK) colors.add("Black");
    12. else if (currentColor == Color.BLUE) colors.add("Blue");
    13. else if (currentColor == Color.FUCHSIA) colors.add("Fuchsia");
    14. else if (currentColor == Color.GRAY) colors.add("Gray");
    15. else if (currentColor == Color.GREEN) colors.add("Green");
    16. else if (currentColor == Color.LIME) colors.add("Lime");
    17. else if (currentColor == Color.MAROON) colors.add("Maroon");
    18. else if (currentColor == Color.NAVY) colors.add("Navy");
    19. else if (currentColor == Color.OLIVE) colors.add("Olive");
    20. else if (currentColor == Color.ORANGE) colors.add("Orange");
    21. else if (currentColor == Color.PURPLE) colors.add("Purple");
    22. else if (currentColor == Color.RED){ colors.add("Red"); Main.plugin.getLogger().info("red");}
    23. else if (currentColor == Color.SILVER) colors.add("Silver");
    24. else if (currentColor == Color.TEAL) colors.add("Teal");
    25. else if (currentColor == Color.WHITE) colors.add("White");
    26. else if (currentColor == Color.YELLOW) colors.add("Yellow");
    27. else if (currentColor == Color.fromRGB(0xB3312C)) {
    28. // this is the colorcode i get if i check colorcode of an actual red fireworkstar
    29. colors.add("Red"); Main.plugin.getLogger().info("rgb red");}
    30. else Main.plugin.getLogger().info("no match");
    31. }
    32. return colors;
    33. }
    34.  


    I always get "no match", can anyone explain me how this is possible?
     
  2. Offline

    Garris0n

    Try printing out the color every iteration and seeing what happens.
     
  3. try using equals instead, the bukkit firework colors is not an enum
     
    Garris0n likes this.
  4. Offline

    UnrealPowerz

    Ya, that worked, thanks.
    I don't understand why they don't just use the regular colors they use for all other things.
     
Thread Status:
Not open for further replies.

Share This Page