Beispiel #1
0
  @EventHandler
  public void onPlayerJoin(PlayerJoinEvent e) {
    FileConfiguration locationsFile =
        YamlConfiguration.loadConfiguration(Main.getInstance().locations);

    Player p = e.getPlayer();
    SPlayer player = new SPlayer(p);

    int blue = Team.BLUE.getPlayers().size();
    int red = Team.RED.getPlayers().size();

    p.teleport(locationUtil.deserializeLoc(locationsFile.getString("arena.lobby")));
    gameManager.setCarrying(p, 0);

    Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
    org.bukkit.scoreboard.Team r = sb.registerNewTeam("red");
    r.setPrefix(Color.np("&c"));
    org.bukkit.scoreboard.Team b = sb.registerNewTeam("blue");
    b.setPrefix(Color.np("&b"));
    for (Player online : Bukkit.getOnlinePlayers()) {
      Team team = teamManager.getTeam(online);
      if (team == Team.BLUE) {
        b.addEntry(online.getName());
      } else {
        r.addEntry(online.getName());
      }
    }

    p.setScoreboard(sb);

    e.setJoinMessage(null);

    if (blue <= red) {
      player.setTeam(Team.BLUE);
    } else {
      player.setTeam(Team.RED);
    }
  }
Beispiel #2
0
  public Area getArea(Location loc) {
    FileConfiguration locationsFile =
        YamlConfiguration.loadConfiguration(Main.getInstance().locations);
    List<Area> areas = Area.getBlockSpawns();
    int i = 0;
    for (int t = 1; t < 9; t++) {
      String[] data = locationsFile.getString("arena.blockspawnareas." + t).split(" ");

      Location minimum = locationUtil.deserializeLoc(data[0]);
      Location maximum = locationUtil.deserializeLoc(data[1]);
      for (double x = minimum.getX(); x <= maximum.getX(); x++) {
        for (double y = minimum.getY(); y <= maximum.getY(); y++) {
          for (double z = minimum.getZ(); z <= maximum.getZ(); z++) {
            Location location = new Location(minimum.getWorld(), x, y, z);
            if (location.equals(loc)) {
              return areas.get(i);
            }
          }
        }
      }
      i++;
    }
    return null;
  }