Why it didnt work?

Discussion in 'Plugin Development' started by ElCreeperHD, May 9, 2015.

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

    ElCreeperHD

    Im trying to make a plugin that summon fireworks if u execute /cohete, but in the compiler it says:
    [​IMG]
    Here its the code:
    Code:
    package com.gmail.elkillermc3.VIPS;
    
    import java.util.Random;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Color;
    import org.bukkit.FireworkEffect;
    import org.bukkit.FireworkEffect.Type;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Firework;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.meta.FireworkMeta;
    
    public class EjecutordeCMD implements CommandExecutor
    {
            public final VIPS plugin;
    
            public EjecutordeCMD(VIPS plugin)
            {
                this.plugin = plugin;
            }
           
            @Override
            public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
                Player player = (Player)sender;   
                if (player.hasPermission("elcraftero.vips.ccohete")){
                if (label.equalsIgnoreCase("cohete"));   
                    shootFireworks();
                }else{
                    player.sendMessage(ChatColor.GOLD + "[ElCraftero]" + ChatColor.DARK_RED + " You don't have enough permission!");
            return true;
            }
           }    
               
        private void shootFireworks(){
                    for (Player player : Bukkit.getOnlinePlayers()){
                            Firework fw = (Firework) player.getWorld().spawn(player.getLocation(),Firework.class);
                            FireworkMeta fm = fw.getFireworkMeta();
                            Random r = new Random();
                            int fType = r.nextInt(5) + 1;
                            Type type = Type.BALL;
                            switch (fType) {
                            case 1:
                                    type = Type.BALL;
                                    break;
                            case 2:
                                    type = Type.BALL_LARGE;
                                    break;
                            case 3:
                                    type = Type.BURST;
                                    break;
                            case 4:
                                    type = Type.CREEPER;
                                    break;
                            case 5:
                                    type = Type.STAR;
                            }
                  
                    int c1i = r.nextInt(17) + 1;
                    int c2i = r.nextInt(17) + 1;
                    Color c1 = getColor (c1i);
                    Color c2 = getColor (c2i);
                    FireworkEffect effect = FireworkEffect.builder()
                                    .flicker(r.nextBoolean()).withColor(c1).withFade(c2)
                                    .with(type).trail(r.nextBoolean()).build();
                    fm.addEffect(effect);
                    int power = r.nextInt(2)+1;
                    fm.setPower(power);
                    fw.setFireworkMeta(fm);
                    }
            }
            public Color getColor(int c){
                    switch (c){
                    default:
                    case 1:
                            return Color.AQUA;
                    case 2:
                            return Color.BLACK;
                    case 3:
                            return Color.BLUE;
                    case 4:
                            return Color.FUCHSIA;
                    case 5:
                            return Color.GRAY;
                    case 6:
                            return Color.GREEN;
                    case 7:
                            return Color.LIME;
                    case 8:
                            return Color.MAROON;
                    case 9:
                            return Color.NAVY;
                    case 10:
                            return Color.OLIVE;
                    case 11:
                            return Color.ORANGE;
                    case 12:
                            return Color.PURPLE;
                    case 13:
                            return Color.RED;
                    case 14:
                            return Color.SILVER;
                    case 15:
                            return Color.TEAL;
                    case 16:
                            return Color.WHITE;
                    case 17:
                            return Color.YELLOW;
                    }
            }
    }
     
    

    Whats wrong and how i fix it? Thanks.:)[creeper]
     
  2. Offline

    Gater12

    @ElCreeperHD
    The IDE is telling you exactly what the problem is. Your onCommand method must return a boolean. Put the 'return true;' statement out of the else block.
     
  3. Offline

    ElCreeperHD

    @Gater12 Thanks! U helped me so much!
     
  4. Offline

    Tecno_Wizard

    @ElCreeperHD, if you cannot figure that one out on your own, you really need to learn some more java before you continue here. Not trying to be mean, just telling the truth- you are going to struggle a lot.
     
    Last edited: May 9, 2015
  5. Offline

    ElCreeperHD

    @Tecno_Wizard Im so new in Java, and i speak spanish and have a little confusion when i see the message, but, yeh, i need practice java.
     
Thread Status:
Not open for further replies.

Share This Page