Exemplo n.º 1
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;
  }
Exemplo n.º 2
0
  @EventHandler
  public void onAreaWalk(AreaWalkEvent e) {
    if (GameState.getState() != GameState.ENDING) {
      Player p = e.getPlayer();
      Area a = e.getArea();

      if (p.getGameMode() == GameMode.SURVIVAL) {
        if (a != null) {
          if (e.isBlockSpawn()) {
            int block = nexusManager.getColor(a);
            if (GameManager.getCarrying(p) == nexusManager.getCurrentNexusColor()) {
              if (block != nexusManager.getCurrentNexusColor()) {
                if (!blockManager.isTaken(a)) {
                  Bukkit.broadcastMessage(
                      Color.np(
                          "&6The "
                              + teamManager.getTeam(p).getTeamName()
                              + " &6team has dropped the needed block. It has been brought back to it's original location."));
                  nexusManager
                      .getNeededBlockArea()
                      .getBlockSpawnBlock()
                      .getBlock()
                      .setTypeIdAndData(159, (byte) nexusManager.getCurrentNexusColor(), false);
                  blockManager.forcePickUpBlock(p, a);
                  isPickedUp = false;
                }
              }
            } else if (!blockManager.isTaken(a)) {
              blockManager.forcePickUpBlock(p, a);
            }

            if (nexusManager.getColor(e.getArea()) == nexusManager.getCurrentNexusColor()) {
              if (!isPickedUp) {
                Bukkit.broadcastMessage(
                    Color.np(
                        "&6The "
                            + teamManager.getTeam(p).getTeamName()
                            + " &6team has picked up the needed block!"));
                a.getBlockSpawnBlock().getBlock().setType(Material.AIR);
                if (GameManager.getCarrying(p) != 0
                    && GameManager.getCarrying(p) != nexusManager.getCurrentNexusColor()) {
                  blockManager.resetBlock(a.getBlockSpawnBlock(), a);
                }
                GameManager.setCarrying(p, nexusManager.getCurrentNexusColor());
                isPickedUp = true;
              }
            }
          } else {
            Team spawn = getTeam(a);
            int carrying = gameManager.getCarrying(p);
            if (spawn == teamManager.getTeam(p)) {
              if (carrying == nexusManager.getCurrentNexusColor()) {
                Bukkit.broadcastMessage(
                    Color.np(
                        "&6The "
                            + spawn.getTeamName()
                            + " &6team has brought the block to their base first!"));
                GameManager.addPoint(spawn);
                gameManager.setCarrying(p, 0);
                nexusManager.generateNewNexus();
              } else {
                if (carrying != 0) {
                  GameManager.addPoint(teamManager.getTeam(p).getOpposite());
                  GameManager.setCarrying(p, 0);
                  Bukkit.broadcastMessage(
                      Color.np(
                          "&cThe "
                              + spawn.getTeamName()
                              + " &cteam has brought the wrong block to their base!"));
                }
              }
            } else {
              if (GameManager.getCarrying(p) == nexusManager.getCurrentNexusColor()) {
                Bukkit.broadcastMessage(
                    Color.np(
                        "&cThe "
                            + spawn.getOpposite().getTeamName()
                            + " &cteam has brought the block to the wrong base!"));
                GameManager.addPoint(spawn);
                gameManager.setCarrying(p, 0);
                nexusManager.generateNewNexus();
              }
            }
          }
        }
      }
    }
  }