[Solved] help with my code :(

Discussion in 'Spigot Plugin Development' started by RuloGamer, May 15, 2015.

Thread Status:
Not open for further replies.
  1. Hello, I have a problem with my plugin, what happens is that when I put the command "open tournament" when I put the number of participants "1" an error message that is in the config.yml ("No you can open a single player tournament 1 "), when I run the plugin all goes well, when I put the command:
    / t open 1 Tank
    (1 = top players, Tank = kit)

    there goes the message I want to leave this in the config.yml

    but when I put the "/ t open 2 tank" I get in chat "An internal error ocurred while attempting to perform this command" and after the tournament opens.

    all right, I just want you to try to open the tournament did not appear that error message


    This part of the code here:

    Code (Text):
        @SuppressWarnings("deprecation")
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player p = (Player) sender;
                if (cmd.getName().equalsIgnoreCase("tournament") && p.hasPermission("tournament.command")) {
                    if (args.length == 3) {
                        if (args[0].equalsIgnoreCase("set")) {
                            int nombre = Integer.parseInt(args[1]);
                            String kit = args[2];
                            if (plugin.open) {
                                if (!plugin.start) {
                                    if (plugin.getConfig().contains("location1") || plugin.getConfig().contains("location2")) {
                                        if (plugin.getConfig().contains("kits." + kit)) {
                                            plugin.place = nombre;
                                            plugin.kit = kit;
                                            if (nombre < plugin.participants.size()) {
                                                for (int i = 0;i < (plugin.participants.size() - nombre);i++) {
                                                    Player player = plugin.participants.get(plugin.participants.size() - (i + 1));
                                                    player.sendMessage(plugin.getConfig().getString("messages.reducedplaces").replaceAll("&", "§"));
                                                    plugin.participants.remove(player);
                                                }
                                            }
                                            Bukkit.getServer().broadcastMessage(plugin.getConfig().getString("messages.modification").replace("<playerleft>", String.valueOf(plugin.participants.size())).replace("<playermax>", String.valueOf(nombre)).replace("<kit>", kit).replaceAll("&", "§"));
                                        } else {
                                            p.sendMessage(plugin.getConfig().getString("messages.nonexistentkit").replace("<kit>", kit).replaceAll("&", "§"));
                                        }
                                    } else {
                                        p.sendMessage(plugin.getConfig().getString("messages.nonexistentspawn").replaceAll("&", "§"));
                                    }
                                } else {
                                    p.sendMessage(plugin.getConfig().getString("messages.start").replaceAll("&", "§"));
                                }
                            } else {
                                p.sendMessage(plugin.getConfig().getString("messages.notopen").replaceAll("&", "§"));
                            }
                            return true;
                        }
                     
                        if (args[0].equalsIgnoreCase("open")) {
                            int nombre = Integer.parseInt(args[1]);
                                if (nombre < 2) {
                                    p.sendMessage(plugin.getConfig().getString("messages.erroropen").replaceAll("&", "§"));
                                    plugin.open = false;
                                    return true;
                                } else {
                         
                                String kit = args[2];
                                if (!plugin.start && !plugin.open) {
                                    if (plugin.getConfig().contains("loc1") || plugin.getConfig().contains("loc2")) {
                                        if (plugin.getConfig().contains("kits." + kit)) {
                                            plugin.open = true;
                                            plugin.kit = kit;
                                            plugin.place = nombre;
                                            String msgmsg = plugin.getConfig().getString("messages.msg").replace("<playerleft>", String.valueOf(0)).replace("<playermax>", String.valueOf(nombre)).replace("<kit>", kit).replaceAll("&", "§");
                                            Bukkit.getServer().broadcastMessage(msgmsg);
                                        } else {
                                            p.sendMessage(plugin.getConfig().getString("messages.nonexistentkit").replace("<kit>", kit).replaceAll("&", "§"));
                                        }
                                    } else {
                                        p.sendMessage(plugin.getConfig().getString("messages.nonexistentspawn").replaceAll("&", "§"));
                                    }
                                } else {
                                    if (plugin.open) {
                                        p.sendMessage(plugin.getConfig().getString("messages.alreadyopen").replaceAll("&", "§"));
                                        return true;
                                    }
                                    if (plugin.start) {
                                        p.sendMessage(plugin.getConfig().getString("messages.start").replaceAll("&", "§"));
                                    }
                                }
                            return true;
                            }
                        }
                    }
                }
                return true;
            }

    thanks
     
    #1 RuloGamer, May 15, 2015
    Last edited: May 15, 2015
  2. Not quite sure what your saying and you explain it a bit more clearly?
     
  3. ok, I'll try to explain better, it is that use Google translator xD

    the command: / t open <participants Maximum> <kit>
    is what opens the tournament, but I want that when someone put 1 (/ t open 1 Tank) show an error message: "Unable to open the tournament with only one participant."

    I use this command when all goes well and shows me the message.

    with the command: / t open 2 Tank
    the tournament should open perfectly, but when I use shows me a message in chat "An internal error ocurred while attempting to perform this command" and after the tournament opens "and then opens.

    as I can make the tournament opens without leave that mistake?
     
  4. Why dont you have players wait in a lobby or waiting list until there are atleast 2 players. start a timer then start the match?
     
  5. When the internal error message is seen, please check the console for the printed error. It makes it considerably easier to track down the problem.
     
  6. Is there an error on the console?
     
  7. hi, I have already solved, thanks for your help :D

    hello, if I will do :)
     
  8. jflory7

    jflory7 Retired Moderator
    Retired Benefactor

    Thread locked per request
     
Thread Status:
Not open for further replies.