Solved Firework on join, problems.

Discussion in 'Plugin Development' started by chikenlitle99, Apr 24, 2014.

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

    chikenlitle99

    I Not speak English and this is what happens:

    *How do I get the "FireworkEffect.type" with the configuration file, I try this but not if it works by the following error
    *The code does not work, I get an error message on the console:
    Show Spoiler
    Code:java
    1. java.lang.IllegalArgumentException: Cannot have null color
    2. at org.apache.commons.lang.Validate.notNull(Validate.java:203) ~[craftbu
    3. kkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    4. at org.bukkit.FireworkEffect$Builder.withColor(FireworkEffect.java:132)
    5. ~[craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    6. at com.choscar.jimdo.Main$2.run(Main.java:112) ~[?:?]
    7. at org.bukkit.craftbukkit.v1_7_R1.scheduler.CraftTask.run(CraftTask.java
    8. :53) ~[craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    9. at org.bukkit.craftbukkit.v1_7_R1.scheduler.CraftScheduler.mainThreadHea
    10. rtbeat(CraftScheduler.java:345) [craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f
    11. 75167-b3005jnks]
    12. at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:5
    13. 87) [craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    14. at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    15. 50) [craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    16. at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    17. 45) [craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    18. at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    19. :457) [craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]
    20. at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    21. 17) [craftbukkit1.7.jar:git-Bukkit-1.7.2-R0.2-36-g9f75167-b3005jnks]



    This is the code full code:
    Code:java
    1. @EventHandler
    2. public void onPlayerLogin(final PlayerLoginEvent pje) {
    3. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    4. Player p = pje.getPlayer();
    5. public void run() {
    6.  
    7. if (getConfig().getBoolean("First_Player_Join.Player_First_Join_Firework.Firework")){
    8. if (pje.getPlayer().hasPlayedBefore()) return;
    9.  
    10. boolean flicker = getConfig().getBoolean("First_Player_Join.Player_First_Join_Firework.Flicker");
    11. boolean trail = getConfig().getBoolean("First_Player_Join.Player_First_Join_Firework.Trail");
    12. //FireworkEffect.Type fwType = FireworkEffect.Type.valueOf(getConfig().getString("First_Player_Join.Player_First_Join_Firework.Type"));
    13. Color Color1 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color1");
    14. Color Color2 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color2");
    15. Color Color3 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color3");
    16. Color Color4 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color4");
    17. Color Fade1 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade1");
    18. Color Fade2 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade2");
    19. Color Fade3 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade3");
    20. Color Fade4 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade4");
    21.  
    22. Firework f = (Firework) pje.getPlayer().getWorld().spawn(pje.getPlayer().getLocation(), Firework.class);
    23. FireworkMeta fm = f.getFireworkMeta();
    24. fm.addEffect(FireworkEffect.builder()
    25. .flicker(flicker)
    26. .trail(trail)
    27. .with(Type.BALL_LARGE)
    28. .withColor(Color1)
    29. .withColor(Color2)
    30. .withColor(Color3)
    31. .withColor(Color4)
    32. .withFade(Fade1)
    33. .withFade(Fade2)
    34. .withFade(Fade3)
    35. .withFade(Fade4)
    36. .build());
    37. fm.setPower((int).8);
    38. f.setFireworkMeta(fm);
    39. }
    40. }
    41. },10);
    42. }


    My ConfigFile:
    PHP:
    First_Player_Join:
        
    Player_First_Join_Firework:
            
    Fireworktrue
            Flicker
    true
            Trail
    true
            Color1
    ORANGE
            Color2
    FUCHSIA
            Color3
    SILVER
            Color4
    BLUE
            Fade1
    BLUE
            Fade2
    PURPLE
            Fade3
    WHITE
            Fade4
    YELLOW
     
  2. Offline

    raGan.

    At least one of your colors is null.
    Code:
    Color Color1 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color1");
    Color Color2 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color2");
    Color Color3 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color3");
    Color Color4 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color4");
    Color Fade1 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade1");
    Color Fade2 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade2");
    Color Fade3 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade3");
    Color Fade4 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Fade4");
     
  3. Offline

    chikenlitle99

    @raGan.
    What do you mean?
     
  4. Offline

    Gecco1234

    In your config at least one of your colours isnt actually there
     
  5. Offline

    chikenlitle99

  6. Offline

    Gecco1234

    is FUCHSIA a supported color?
     
  7. Offline

    chikenlitle99

    @Gecco1234

    In the "FireWork Color" yes, in the "ChatColor." No
     
  8. Offline

    raGan.

    Why don't you just do a null check for each color to make sure?
     
  9. Offline

    BillyGalbreath

    Looks like you are using Strings as Colors. "ORANGE" isnt a Color, but "0xFFA500" is indeed the Color ORANGE.
     
  10. Offline

    qlimax5000

    ORANGE is called GOLD...
     
  11. Offline

    BillyGalbreath

    Change this

    Color color1 = getConfig().getColor("First_Player_Join.Player_First_Join_Firework.Color1");

    To something like this

    Color Color1 = Color.fromRGB(getConfig().getString("First_Player_Join.Player_First_Join_Firework.Color1"));

    These are Colors, not ChatColors. ORANGE is a Color. GOLD is not a Color.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page