Trying to get players from arena

Discussion in 'Plugin Development' started by Creeoer, Aug 24, 2014.

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

    Creeoer

    My issue is relatively easy (I hope) and here is bascially what I am trying to do: Initialize my game taking both people from both teams ot the arenas using a metohd I've created myself, and having it repeat itself in my onEnable method, I am trying to take the players and the arena they're in:

    InitalizeGame Method:
    Code:
    public void activateGame( final Player p,  final int i){
           
     
                Bukkit.getScheduler().scheduleSyncDelayedTask(  DeathMongol.getInstance(), new Runnable(){
                    public void run(){
                   
                  Bukkit.getServer().broadcastMessage(ChatColor.BLACK + "[DeathCavallo]" + "ChatColor.GREEN" + "The game will start in 3 minutes..");
                  Arena a = getArena(i);
                    if(Hunters.isPlayerHunting(p) &&  !(Runners.getRunners().isEmpty())){
                        ItemStack[] items = {new ItemStack(Material.COOKED_BEEF, 16), new ItemStack(Material.DIAMOND_SWORD), new ItemStack(Material.BOW)};
                        p.getInventory().addItem(items);
                        p.getInventory().setHelmet( new ItemStack (Material.DIAMOND_HELMET));
                        p.getInventory().setChestplate( new ItemStack (Material.DIAMOND_CHESTPLATE));
                        p.getInventory().setLeggings( new ItemStack (Material.DIAMOND_HELMET));
                        p.getInventory().setBoots( new ItemStack (Material.DIAMOND_BOOTS));
                        p.updateInventory();
                        p.teleport(a.spawn);
                        Horse horse = (Horse) p.getWorld().spawnCreature(p.getLocation(), EntityType.HORSE); // Spawns the horse
                        horse.getInventory().setSaddle(new ItemStack(Material.SADDLE, 1)); // Gives horse saddle
                        horse.setTamed(true); // Sets horse to tamed
                        horse.setOwner(p);// Makes the horse the players
                    } else if (Runners.getRunners().isEmpty()){
                        p.sendMessage(ChatColor.RED + "You've been removed from the game since there are no players to begin with");
                        ArenaManager.getManager().removePlayer(p);
                      return;
                     
                }  if (Runners.isPlayerRunning(p) && !(Hunters.getHunters().isEmpty())){
                    ItemStack[] items = {new ItemStack(Material.COOKED_BEEF, 16), new ItemStack(Material.DIAMOND_SWORD), new ItemStack(Material.BOW)};
                    p.getInventory().addItem(items);
                    p.getInventory().setHelmet( new ItemStack (Material.LEATHER_HELMET));
                    p.getInventory().setChestplate( new ItemStack (Material.LEATHER_CHESTPLATE));
                    p.getInventory().setLeggings( new ItemStack (Material.LEATHER_LEGGINGS));
                    p.getInventory().setBoots( new ItemStack (Material.LEATHER_BOOTS));
                    p.updateInventory();
                    p.teleport(a.spawn);
                } else if (Hunters.getHunters().isEmpty()) {
                    p.sendMessage(ChatColor.RED + "You've been removed from the game since there are no players to begin with");
                    ArenaManager.getManager().removePlayer(p);
             
                return;   
             
                }
                    }
                 
                  }, 20 *60);
               
                 
                  Bukkit.getScheduler().scheduleSyncDelayedTask(DeathMongol.getInstance(), new Runnable(){
                      public void run(){
                          if(!(Runners.getRunners().isEmpty())){
                              Bukkit.getServer().broadcastMessage(ChatColor.BLACK + "[DeathCavallo]" + ChatColor.GOLD + "The runners have won due to time!");
                              ArenaManager.getManager().removePlayer(p);
                             
                          }
                     
                      }
                  }, 20 *180);        

    my oneable method gets the arena that goes by ids (using the intergers) and as you can see it is using arena 2, how would I define the player value?
    Code:
    Bukkit.getScheduler().scheduleSyncRepeatingTask(DeathMongol.getInstance(), new Runnable(){
     
                @Override
                public void run() {
                Player p = ArenaManager.
                ArenaManager.getManager().activateGame(p, 2);
                }
               
            }, 20*200, 200);
            
     
  2. Offline

    IkBenHarm

    Creeoer
    if i understand correctly you could do:

    for(Player p : Bukkit.getOnlinePlayers()){
    if(they have joined){
    // remove
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page