Solved Two Player Arguments

Discussion in 'Plugin Development' started by FreeMotion45, Oct 30, 2015.

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

    FreeMotion45

    Hello,

    I recently started making another code and I have enecountered an error. Maybe its only me, and maybe its again a question that a newbie may ask.
    I created a command, and i want the command to teleport args[0] and args[1] to a specific location.
    But for some reason it wont do anything when I run the command.

    The code :

    Code:
                    if(args.length == 2){
                        if(p.hasPermission("tournament.control")){
                            for(String intour : tr){
                                final Player ptour = Bukkit.getServer().getPlayer(intour);
                                final Player p1 = Bukkit.getServer().getPlayer(args[0]);
                                final Player p2 = Bukkit.getServer().getPlayer(args[1]);
                                ptour.sendMessage(ChatColor.STRIKETHROUGH + "" + ChatColor.RED + "-=-=-[=-=-=-=-=-=-=-=]-=-=-");
                                ptour.sendMessage(ChatColor.GREEN + "This round's players are ....");
                                ptour.getLocation().getWorld().playSound(ptour.getLocation(), Sound.ITEM_PICKUP, 1, 1);
                                ptour.getLocation().getWorld().playSound(ptour.getLocation(), Sound.ITEM_PICKUP, 1, 1);
                                ptour.getLocation().getWorld().playSound(ptour.getLocation(), Sound.ITEM_PICKUP, 1, 1);
                                ptour.sendMessage(ChatColor.STRIKETHROUGH + "" + ChatColor.RED + "-=-=-[=-=-=-=-=-=-=-=]-=-=-");
                                double x1 = 9.2;
                                double y1 = 84.5;
                                double z1 = 0.4;
                                World world = Bukkit.getServer().getWorld("tournament");
                                final Location ploc1 = new Location(world, x1, y1, z1);
                                double x2 = -8.5;
                                double y2 = 84.5;
                                double z2 = 0.4;
                                final Location ploc2 = new Location(world, x2, y2, z2);
                                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    
                                    @Override
                                    public void run() {
                                        ptour.sendMessage(ChatColor.STRIKETHROUGH + "" + ChatColor.RED + "-=-=-[=-=-=-=-=-=-=-=]-=-=-");
                                        ptour.sendMessage(ChatColor.GREEN + p1.getName() + " and " + p2.getName() + " good luck and have fun !");
                                        p2.teleport(ploc2);
                                        p1.teleport(ploc1);
                                        ptour.getLocation().getWorld().playSound(ptour.getLocation(), Sound.ITEM_PICKUP, 1, 1);
                                        ptour.getLocation().getWorld().playSound(ptour.getLocation(), Sound.ITEM_PICKUP, 1, 1);
                                        ptour.getLocation().getWorld().playSound(ptour.getLocation(), Sound.ITEM_PICKUP, 1, 1);
                                        ptour.sendMessage(ChatColor.STRIKETHROUGH + "" + ChatColor.RED + "-=-=-[=-=-=-=-=-=-=-=]-=-=-");
                                    }
                                }, 2*20L);
                            }
                        }
                    }
    Best Regards,

    FreeMotion !
     
  2. Offline

    teej107

    Nothing? No errors either? If that is the case, put in simple println statements to make sure parts of your code is running.
     
  3. Offline

    Assist

  4. Offline

    FreeMotion45

    I tried to do everything. Commands after it work normal though, and before.
    I tried looking for tutorials but I know what was explained in there.
     
  5. Offline

    adam753

    You're doing the teleport code inside this for loop
    Code:
    for(String intour : tr){
    My guess is tr is empty, meaning the players are getting teleported 0 times. If tr had 3 things in it, the players would be teleported to the same place 3 times... Rethink your code.
     
  6. Offline

    FreeMotion45

    I have fixed this,

    There was one bracket not in the place it had to be.
     
Thread Status:
Not open for further replies.

Share This Page