Instant warping near other teammates.

Discussion in 'Plugin Development' started by Twisted_Panda, Aug 29, 2013.

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

    Twisted_Panda

    So, i'm kinda having a issue allowing teammates instant warping.

    Code:
        public static boolean AnyoneNear(Player player) {
            List<Entity> entities = player.getNearbyEntities(10,10,10);
            boolean found = false;
           
            synchronized(entities)
            {
                for(Entity entity : entities)
                {
                    if(entity instanceof Player)
                    {
                        return true;
                    }
                    if(this.pvp.getConfig().getString("Players." + player.getName()) != null) {
                        return true;
                    }else{
                        if(this.getConfig().getString("Teams." + this.pvp.getConfig().getString("Players." + player.getName()) + ".Members").contains(player.getName())) {
                            return false;
                        }
     
                    }
                }
            }
            return found;
        }
     
  2. Offline

    The_Doctor_123

    I made this awhile back:

    Code:java
    1. public List<Player> getNearbyPlayers(Location location, int Radius)
    2. {
    3. List<Player> WorldPlayers = location.getWorld().getPlayers();
    4. List<Player> Players = new ArrayList<Player>();
    5.  
    6. for (Player player : WorldPlayers)
    7. {
    8. if (player.getLocation().distance(location) < Radius)
    9. {
    10. Players.add(player);
    11. }
    12. }
    13. return Players;
    14. }
     
  3. Offline

    Twisted_Panda

    Alright, but i'm kinda lost on how to do it.
     
  4. Offline

    The_Doctor_123

    How to do what? I'm kind of lost on what you want.
     
  5. Offline

    Twisted_Panda

    Well, i'm unsure on how to make it where. If you're near a teammate and he is in your team you can warp instantly to team hq and rally. But, if there is a non teammate around you have to wait 10 seconds (I already have the 10 seconds down)
     
  6. Offline

    Drkmaster83

    Firstly, how will you access the warp? Will you check the nearest player? If so, what counts as 'near?' It stretches out until it reaches a player entity, or a set area? Will it check if teammates are preferred over non-teammates if there's a specific radius?
     
  7. Offline

    Twisted_Panda


    Code:
    boolean near = AnyoneNear(player);
                if (!near) {
                    player.teleport(new Location(w, x, y, z));
                }else{
                    player.sendMessage(ChatColor.GRAY + "Someone is nearby! Please wait 10 seconds!");
                    Location tpto = (new Location(w, x, y, z));
                    plugin.waittp(player, tpto);
    The radius is 10 10 10.
     
  8. Offline

    The_Doctor_123

    Code:
    List<Player> Teammates; // Just an example variable to show you the idea, it actually won't work
     
    List<Player> Players = getNearbyPlayers(playerToTeleportTo.getLocation(), 10);
    boolean OpponentsNearby = false;
    for (Player player : Players)
    {
    if (!Teammates.contains(player))
    {
    OpponentsNearby = true;
    break;
    }
    }
     
    if (!OpponentsNearby)
    {
    // If there's no opponents in range
    }
     
    
     
  9. Offline

    Twisted_Panda

    Alright, ill try it out.

    Code:
    List<Player>Teammates = Main.pvp.getConfig().getString("Teams." + Main.pvp.getConfig().getString("Players." + player.getName()) + ".Members");
    Keeps changing "List" to String.

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

Share This Page