예제 #1
0
  static {
    try {
      Plugin wgp = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
      hasWG = wgp != null; // Short and sweet
      if (hasWG) wg = (WorldGuardPlugin) wgp;
      hasResidence = Bukkit.getServer().getPluginManager().getPlugin("Residence") != null;
      log = Storm.instance.getLogger();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
  /**
   * Gets player within range.
   *
   * @param location the centre of the range
   * @param radius the radius of the range
   * @return a set of Bukkit player objects
   */
  public static Set<Player> getNearbyPlayers(Location location, double radius) {
    Set<Player> playerList = new HashSet<Player>();
    World locWorld = location.getWorld();
    radius *= radius;

    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
      if (p.getWorld().equals(locWorld)) {
        if (p.getLocation().distanceSquared(location) <= radius) {
          playerList.add(p);
        }
      }
    }

    return playerList;
  }
예제 #3
0
 public FakeServer() {
   if (Bukkit.getServer() == null) {
     Bukkit.setServer(this);
   }
 }
예제 #4
0
 /**
  * Broadcasts a message to all players.
  *
  * @param message message to send
  */
 public static void broadcast(String message) {
   if (!message.isEmpty()) {
     Bukkit.getServer().broadcastMessage(parseColors(message));
   }
 }