Помогите Откидывание

sasha2003

Активный участник
Пользователь
Баллы
76
Мне нужно, чтобы при вводе команды у меня включилось <<Силовое поле>> и игроки начали откидываться от меня.
Мне нужно только само откидывание?
 
player.setVelcotity(new Vector(x, y, z));
 
Проверяй игроков рядом, getNearbyEntities

Код:
public static boolean isInRadius(Player player, Player target, double radius) {
        if(!target.getLocation().getWorld().equals(player.getLocation().getWorld())) {
            return false;
        }
        return player.getLocation().distanceSquared(target.getLocation()) <= (radius * radius);
    }

Код:
Collection<? extends Player> online = Bukkit.getOnlinePlayers();
               
                if (isInRadius(p, (Player) online, 7)) {
                   
                }

Правильно?
 
Код:
public static boolean isInRadius(Player player, Player target, double radius) {
        if(!target.getLocation().getWorld().equals(player.getLocation().getWorld())) {
            return false;
        }
        return player.getLocation().distanceSquared(target.getLocation()) <= (radius * radius);
    }

Код:
Collection<? extends Player> online = Bukkit.getOnlinePlayers();
              
                if (isInRadius(p, (Player) online, 7)) {
                  
                }

Правильно?
Нет
 

Я уже понял
Код:
  public void run()
  {
    for (Player player : Bukkit.getServer().getOnlinePlayers()) {
      if (this.m.contains(player)) {
        for (Player player2 : Bukkit.getServer().getOnlinePlayers()) {
          if (!player.equals(player2)) {
            if (a(player2, player) <= this.e)
            {
              if (player2.getGameMode() == GameMode.SPECTATOR) {
                return;
              }
              if (player2.hasPermission(this.a)) {
                return;
              }
              for (Object vehicle = player2; ((Entity)vehicle).getVehicle() != null; vehicle = ((Entity)vehicle).getVehicle()) {}
              a((Entity)vehicle, b(player, (Entity)vehicle), 1.6D, true, 0.8D, 0.0D, 10.0D);
              if (!this.i) {
                return;
              }
              player2.getWorld().playSound(player2.getLocation(), Sound.valueOf(this.j), (float)this.k, (float)this.l);
            }
          }
        }
      }
    }
  }

  public double a(Entity entity, Entity entity2)
  {
    return entity.getLocation().toVector().subtract(entity2.getLocation().toVector()).length();
  }

  public Vector b(Entity entity, Entity entity2)
  {
    return entity2.getLocation().toVector().subtract(entity.getLocation().toVector()).setY(0).normalize();
  }

  public void a(Entity entity, Vector velocity, double n, boolean b, double y, double n2, double y2)
  {
    if ((Double.isNaN(velocity.getX())) || (Double.isNaN(velocity.getY())) || (Double.isNaN(velocity.getZ())) || (velocity.length() == 0.0D)) {
      return;
    }
    if (b) {
      velocity.setY(y);
    }
    velocity.normalize();
    velocity.multiply(n);
    velocity.setY(velocity.getY() + n2);
    if (velocity.getY() > y2) {
      velocity.setY(y2);
    }
    entity.setFallDistance(0.0F);
    entity.setVelocity(velocity);
  }

  public void a()
  {
    this.a = getConfig().getString("IgnorePermisison");
    this.b = getConfig().getString("UsePermission");
    this.c = getConfig().getString("ReloadPermission");
    this.d = getConfig().getString("ConfigReloaded");
    this.e = getConfig().getInt("Range");
    this.f = getConfig().getString("NoPermMessage");
    this.g = getConfig().getString("Enabled");
    this.h = getConfig().getString("Disabled");
    this.i = getConfig().getBoolean("EnableSound");
    this.j = getConfig().getString("Sound");
    this.k = getConfig().getInt("Volume");
    this.l = getConfig().getInt("Pitch");
  }
}

почему ошибка в 16 строке (a((Entity)vehicle, b(player, (Entity)vehicle), 1.6D, true, 0.8D, 0.0D, 10.0D);)
Подчёркивает <<vehicle>>
 
Я уже понял
Код:
  public void run()
  {
    for (Player player : Bukkit.getServer().getOnlinePlayers()) {
      if (this.m.contains(player)) {
        for (Player player2 : Bukkit.getServer().getOnlinePlayers()) {
          if (!player.equals(player2)) {
            if (a(player2, player) <= this.e)
            {
              if (player2.getGameMode() == GameMode.SPECTATOR) {
                return;
              }
              if (player2.hasPermission(this.a)) {
                return;
              }
              for (Object vehicle = player2; ((Entity)vehicle).getVehicle() != null; vehicle = ((Entity)vehicle).getVehicle()) {}
              a((Entity)vehicle, b(player, (Entity)vehicle), 1.6D, true, 0.8D, 0.0D, 10.0D);
              if (!this.i) {
                return;
              }
              player2.getWorld().playSound(player2.getLocation(), Sound.valueOf(this.j), (float)this.k, (float)this.l);
            }
          }
        }
      }
    }
  }

  public double a(Entity entity, Entity entity2)
  {
    return entity.getLocation().toVector().subtract(entity2.getLocation().toVector()).length();
  }

  public Vector b(Entity entity, Entity entity2)
  {
    return entity2.getLocation().toVector().subtract(entity.getLocation().toVector()).setY(0).normalize();
  }

  public void a(Entity entity, Vector velocity, double n, boolean b, double y, double n2, double y2)
  {
    if ((Double.isNaN(velocity.getX())) || (Double.isNaN(velocity.getY())) || (Double.isNaN(velocity.getZ())) || (velocity.length() == 0.0D)) {
      return;
    }
    if (b) {
      velocity.setY(y);
    }
    velocity.normalize();
    velocity.multiply(n);
    velocity.setY(velocity.getY() + n2);
    if (velocity.getY() > y2) {
      velocity.setY(y2);
    }
    entity.setFallDistance(0.0F);
    entity.setVelocity(velocity);
  }

  public void a()
  {
    this.a = getConfig().getString("IgnorePermisison");
    this.b = getConfig().getString("UsePermission");
    this.c = getConfig().getString("ReloadPermission");
    this.d = getConfig().getString("ConfigReloaded");
    this.e = getConfig().getInt("Range");
    this.f = getConfig().getString("NoPermMessage");
    this.g = getConfig().getString("Enabled");
    this.h = getConfig().getString("Disabled");
    this.i = getConfig().getBoolean("EnableSound");
    this.j = getConfig().getString("Sound");
    this.k = getConfig().getInt("Volume");
    this.l = getConfig().getInt("Pitch");
  }
}

почему ошибка в 16 строке (a((Entity)vehicle, b(player, (Entity)vehicle), 1.6D, true, 0.8D, 0.0D, 10.0D);)
Подчёркивает <<vehicle>>
названия переменных збс
 
Java:
    private Set<Player> players = Sets.newConcurrentHashSet();
    public void onEnable() {
        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
            @Override
            public void run() {
                for (Player p : players) {
                    for (Entity e : p.getNearbyEntities(4, 4, 4)) {
                        if (e.getType() == EntityType.PLAYER) {
                            Player p2 = (Player) e;
                            if (p != p2) {
                                p2.setVelocity(p2.getLocation().getDirection().setY(-1.35).multiply(-1.2));
                            }
                        }
                    }
                }
            }
        }, 5, 5);
    }
В players добавляешь игроков от которых должно отталкивать игроков.
 
Назад
Верх