Examples of Warzone


Examples of com.tommytony.war.Warzone

  public Location getLocation() {
    return this.location;
  }

  public Warzone getDestinationWarzoneForLocation(Location playerLocation) {
    Warzone zone = null;
    for (String zoneName : this.zoneGateBlocks.keySet()) {
      Block gate = this.zoneGateBlocks.get(zoneName);
      if (gate.getX() == playerLocation.getBlockX()
          && gate.getY() == playerLocation.getBlockY()
          && gate.getZ() == playerLocation.getBlockZ()) {
View Full Code Here

Examples of com.tommytony.war.Warzone

    Player player = (Player) this.getSender();

    if (this.args.length != 1) {
      return false;
    }
    Warzone zone = Warzone.getZoneByLocation(player);

    if (zone == null) {
      return false;
    } else if (!this.isSenderAuthorOfZone(zone)) {
      return true;
    }

    TeamKind kind = TeamKind.teamKindFromString(this.args[0]);
    Team team = zone.getTeamByKind(kind);
    if (team == null) {
      // no such team yet
      this.msg("Place the team spawn first.");
    } else if (team.getFlagVolume() == null) {
      // new team flag
      team.setTeamFlag(player.getLocation());
      Location playerLoc = player.getLocation();
      player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
      this.msg("Team " + team.getName() + " flag added here.");
      WarzoneYmlMapper.save(zone);
      War.war.log(this.getSender().getName() + " created team " + team.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    } else {
      // relocate flag
      team.getFlagVolume().resetBlocks();
      team.setTeamFlag(player.getLocation());
      Location playerLoc = player.getLocation();
      player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ() + 1));
      this.msg("Team " + team.getName() + " flag moved.");
      WarzoneYmlMapper.save(zone);
      War.war.log(this.getSender().getName() + " moved team " + team.getName() + " flag in warzone " + zone.getName(), Level.INFO);
    }

    return true;
  }
View Full Code Here

Examples of com.tommytony.war.Warzone

    this.player = player;
    this.zoneName = zoneName;
  }

  public void placeNorthwest() {
    Warzone warzone = War.war.findWarzone(this.zoneName);
    Block northwestBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    StringBuilder msgString = new StringBuilder();
    try {
      if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
        // max warzones reached
        War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
        return;
      } else if (warzone == null) {
        // create the warzone
        warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
        warzone.addAuthor(player.getName());
        War.war.getIncompleteZones().add(warzone);
        warzone.getVolume().setNorthwest(northwestBlock.getLocation());
        War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
        War.war.log(player.getName() + " created warzone " + zoneName + " by setting its nw corner", Level.INFO);
      } else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
        return;
      } else {
        // change existing warzone
        this.resetWarzone(warzone, msgString);
        warzone.getVolume().setNorthwest(northwestBlock.getLocation());
        msgString.append("Warzone " + warzone.getName() + " modified. Northwesternmost point set to x:" + warzone.getVolume().getNorthwestX() + " z:" + warzone.getVolume().getNorthwestZ() + ". ");
        War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its nw corner", Level.INFO);
      }
      this.saveIfReady(warzone, msgString);
    } catch (NotNorthwestException e) {
      War.war.badMsg(this.player, "The block you selected is not to the northwest of the existing southeasternmost block.");
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone(); // was reset before changing
      }
    } catch (TooSmallException e) {
      this.handleTooSmall();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    } catch (TooBigException e) {
      this.handleTooBig();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    }
  }
View Full Code Here

Examples of com.tommytony.war.Warzone

    War.war.getWarzones().clear();
    if (this.warzones != null) {
      for (String warzoneName : this.warzones) {
        if (warzoneName != null && !warzoneName.equals("")) {
          War.war.log("Loading zone " + warzoneName + "...", Level.INFO);
          Warzone zone = WarzoneYmlMapper.load(warzoneName);
          if (zone != null) { // could have failed, would've been logged already
            War.war.getWarzones().add(zone);
            try {
              zone.getVolume().loadCorners();
            } catch (SQLException ex) {
              War.war.log("Failed to load warzone " + warzoneName + ": " + ex.getMessage(), Level.WARNING);
              throw new RuntimeException(ex);
            }
            if (zone.getLobby() != null) {
              zone.getLobby().getVolume().resetBlocks();
            }
            if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.RESETONLOAD)) {
              zone.getVolume().resetBlocks();
            }
            zone.initializeZone();
          }
        }
      }
      if (War.war.getWarzones().size() > 0) {
        War.war.log("Warzones ready.", Level.INFO);
View Full Code Here

Examples of com.tommytony.war.Warzone

      }
    }
  }

  public void placeSoutheast() {
    Warzone warzone = War.war.findWarzone(this.zoneName);
    Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    StringBuilder msgString = new StringBuilder();
    try {
      if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
        // max warzones reached
        War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
        return;
      } else if (warzone == null) {
        // create the warzone
        warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
        warzone.addAuthor(player.getName());
        War.war.getIncompleteZones().add(warzone);
        warzone.getVolume().setSoutheast(southeastBlock.getLocation());
        War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
        War.war.log(player.getName() + " created warzone " + zoneName + " by setting its se corner", Level.INFO);
      } else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
        return;
      } else {
        // change existing warzone
        this.resetWarzone(warzone, msgString);
        warzone.getVolume().setSoutheast(southeastBlock.getLocation());
        msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
        War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its se corner", Level.INFO);
      }
      this.saveIfReady(warzone, msgString);
    } catch (NotSoutheastException e) {
      War.war.badMsg(this.player, "The block you selected is not to the southeast of the existing northwestnmost block.");
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone(); // was reset before changing
      }
    } catch (TooSmallException e) {
      this.handleTooSmall();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    } catch (TooBigException e) {
      this.handleTooBig();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    }
  }
View Full Code Here

Examples of com.tommytony.war.Warzone

    Block corner1Block = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    this.placeCorner1(corner1Block);
  }

  public void placeCorner1(Block corner1Block) {
    Warzone warzone = War.war.findWarzone(this.zoneName);
    StringBuilder msgString = new StringBuilder();
    try {
      if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
        // max warzones reached
        War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
        return;
      } else if (warzone == null) {
        // create the warzone
        warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
        warzone.addAuthor(player.getName());
        War.war.getIncompleteZones().add(warzone);
        warzone.getVolume().setZoneCornerOne(corner1Block);
        War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 1 set to x:" + corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
        War.war.log(player.getName() + " created warzone " + zoneName + " by setting its corner 1", Level.INFO);
      } else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
        return;
      } else {
        // change existing warzone
        this.resetWarzone(warzone, msgString);
        warzone.getVolume().setZoneCornerOne(corner1Block);
        msgString.append("Warzone " + warzone.getName() + " modified. Corner 1 set to x:" + corner1Block.getX() + " y:" + corner1Block.getY() + " z:" + corner1Block.getZ() + ". ");
        War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its corner 1", Level.INFO);
      }
      this.saveIfReady(warzone, msgString);
    } catch (TooSmallException e) {
      this.handleTooSmall();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    } catch (TooBigException e) {
      this.handleTooBig();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    }
  }
View Full Code Here

Examples of com.tommytony.war.Warzone

    Block corner2Block = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    this.placeCorner2(corner2Block);
  }

  public void placeCorner2(Block corner2Block) {
    Warzone warzone = War.war.findWarzone(this.zoneName);
    StringBuilder msgString = new StringBuilder();
    try {
      if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
        // max warzones reached
        War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
        return;
      } else if (warzone == null) {
        // create the warzone
        warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
        warzone.addAuthor(player.getName());
        War.war.getIncompleteZones().add(warzone);
        warzone.getVolume().setZoneCornerTwo(corner2Block);
        War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Corner 2 set to x:" + corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
        War.war.log(player.getName() + " created warzone " + zoneName + " by setting its corner 2", Level.INFO);
      } else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
        return;
      } else {
        // change existing warzone
        this.resetWarzone(warzone, msgString);
        warzone.getVolume().setZoneCornerTwo(corner2Block);
        msgString.append("Warzone " + warzone.getName() + " modified. Corner 2 set to x:" + corner2Block.getX() + " y:" + corner2Block.getY() + " z:" + corner2Block.getZ() + ". ");
        War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its corner 2", Level.INFO);
      }
      this.saveIfReady(warzone, msgString);
    } catch (TooSmallException e) {
      this.handleTooSmall();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    } catch (TooBigException e) {
      this.handleTooBig();
      if (warzone.getVolume().isSaved()) {
        warzone.initializeZone();
      }
    }
  }
View Full Code Here

Examples of com.tommytony.war.Warzone

    if (this.args.length != 1) {
      return false;
    }

    Warzone zone = Warzone.getZoneByLocation(player);

    if (zone == null) {
      return false;
    } else if (!this.isSenderAuthorOfZone(zone)) {
      return true;
    }
   
    if (this.args[0].equals(zone.getName())) {
      return false;
    }

    if (zone.hasBomb(this.args[0])) {
      // move the existing bomb
      Bomb bomb = zone.getBomb(this.args[0]);
      bomb.getVolume().resetBlocks();
      bomb.setLocation(player.getLocation());
      this.msg("Bomb " + bomb.getName() + " was moved.");
      War.war.log(this.getSender().getName() + " moved bomb " + bomb.getName() + " in warzone " + zone.getName(), Level.INFO);
    } else {
      // create a new bomb
      Bomb bomb = new Bomb(this.args[0], zone, player.getLocation());
      zone.getBombs().add(bomb);
      this.msg("Bomb " + bomb.getName() + " created.");
      War.war.log(this.getSender().getName() + " created bomb " + bomb.getName() + " in warzone " + zone.getName(), Level.INFO);
    }

    WarzoneYmlMapper.save(zone);

    return true;
View Full Code Here

Examples of com.tommytony.war.Warzone

    Player player = (Player) this.getSender();

    if (this.args.length != 1) {
      return false;
    }
    Warzone zone = Warzone.getZoneByLocation(player);

    if (zone == null) {
      return false;
    } else if (!this.isSenderAuthorOfZone(zone)) {
      return true;
    }

    TeamKind teamKind = TeamKind.teamKindFromString(this.args[0]);
   
    if (teamKind == null) {
      return false;
    } else {
      Team existingTeam = zone.getTeamByKind(teamKind);
      if (existingTeam != null) {
        // add additional spawn
        existingTeam.addTeamSpawn(player.getLocation());
        this.msg("Additional spawn added for team " + existingTeam.getName() + ". Use /deleteteam " + existingTeam.getName() + " to remove all spawns.");
        War.war.log(this.getSender().getName() + " moved team " + existingTeam.getName() + " in warzone " + zone.getName(), Level.INFO);
      } else {
        // new team (use default TeamKind name for now)
        Team newTeam = new Team(teamKind.toString(), teamKind, Collections.<Location>emptyList(), zone);
        newTeam.setRemainingLives(newTeam.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
        zone.getTeams().add(newTeam);
        if (zone.getLobby() != null) {
          zone.getLobby().setLocation(zone.getTeleport());
          zone.getLobby().initialize();
        }
        newTeam.addTeamSpawn(player.getLocation());
        this.msg("Team " + newTeam.getName() + " created with spawn here.");
        War.war.log(this.getSender().getName() + " created team " + newTeam.getName() + " in warzone " + zone.getName(), Level.INFO);
      }
    }

    WarzoneYmlMapper.save(zone);
View Full Code Here

Examples of com.tommytony.war.Warzone

    if (world == null) {
      War.war.log("Failed to restore warzone " + name + ". The specified world (name: " + worldStr + ") does not exist!", Level.WARNING);
    } else {
      // Create the zone
      Warzone warzone = new Warzone(world, name);

      // Create file if needed
      if (!warzoneConfig.containsKey("name")) {
        WarzoneTxtMapper.save(warzone, false);
        War.war.getLogger().info("Warzone " + name + " config file created.");
        try {
          warzoneConfig.load();
        } catch (IOException e) {
          // war.getLogger().info("Failed to reload warzone-" + name + ".txt file after creating it.");
          e.printStackTrace();
        }
      }

      // teleport
      String teleportStr = warzoneConfig.getString("teleport");
      if (teleportStr != null && !teleportStr.equals("")) {
        String[] teleportSplit = teleportStr.split(",");
        int teleX = Integer.parseInt(teleportSplit[0]);
        int teleY = Integer.parseInt(teleportSplit[1]);
        int teleZ = Integer.parseInt(teleportSplit[2]);
        int yaw = Integer.parseInt(teleportSplit[3]);
        warzone.setTeleport(new Location(world, teleX, teleY, teleZ, yaw, 0));
     

      // ff
      if (warzoneConfig.containsKey("friendlyFire")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.FRIENDLYFIRE, warzoneConfig.getBoolean("friendlyFire"));
      }

      // loadout
      warzone.getDefaultInventories().clearLoadouts();
     
      String loadoutStr = warzoneConfig.getString("loadout");
      if (loadoutStr != null && !loadoutStr.equals("")) {
        warzone.getDefaultInventories().setLoadout("default", new HashMap<Integer, ItemStack>());
        LoadoutTxtMapper.fromStringToLoadout(loadoutStr, warzone.getDefaultInventories().getLoadout("default"));
      }
     
      // extraLoadouts
      String extraLoadoutStr = warzoneConfig.getString("extraLoadouts");
      String[] extraLoadoutsSplit = extraLoadoutStr.split(",");
     
      for (String nameStr : extraLoadoutsSplit) {
        if (nameStr != null && !nameStr.equals("")) {
          warzone.getDefaultInventories().setLoadout(nameStr, new HashMap<Integer, ItemStack>());
        }
      }
     
      for (String extraName : extraLoadoutsSplit) {
        if (extraName != null && !extraName.equals("")) {
          String loadoutString = warzoneConfig.getString(extraName + "Loadout");
          HashMap<Integer, ItemStack> loadout = warzone.getDefaultInventories().getLoadout(extraName);
          LoadoutTxtMapper.fromStringToLoadout(loadoutString, loadout);
        }
      }

      // authors
      if (warzoneConfig.containsKey("author") && !warzoneConfig.getString("author").equals("")) {
        for(String authorStr : warzoneConfig.getString("author").split(",")) {
          if (!authorStr.equals("")) {
            warzone.addAuthor(authorStr);
          }
        }
      }

      // life pool (always set after teams, so the teams' remaining lives get initialized properly by this setter)
      if (warzoneConfig.containsKey("lifePool")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.LIFEPOOL, warzoneConfig.getInt("lifePool"));
      }

      // monument heal
      if (warzoneConfig.containsKey("monumentHeal")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MONUMENTHEAL, warzoneConfig.getInt("monumentHeal"));
      }

      // autoAssignOnly
      if (warzoneConfig.containsKey("autoAssignOnly")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.AUTOASSIGN, warzoneConfig.getBoolean("autoAssignOnly"));
      }

      // flagPointsOnly
      if (warzoneConfig.containsKey("flagPointsOnly")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.FLAGPOINTSONLY, warzoneConfig.getBoolean("flagPointsOnly"));
      }
     
      // flagMustBeHome
      if (warzoneConfig.containsKey("flagMustBeHome")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.FLAGMUSTBEHOME, warzoneConfig.getBoolean("flagMustBeHome"));
      }

      // team cap
      if (warzoneConfig.containsKey("teamCap")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.TEAMSIZE, warzoneConfig.getInt("teamCap"));
      }
     
      // score cap
      if (warzoneConfig.containsKey("scoreCap")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.MAXSCORE, warzoneConfig.getInt("scoreCap"));
      }
     
      // respawn timer
      if (warzoneConfig.containsKey("respawnTimer")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.RESPAWNTIMER, warzoneConfig.getInt("respawnTimer"));
      }

      // blockHeads
      if (warzoneConfig.containsKey("blockHeads")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.BLOCKHEADS, warzoneConfig.getBoolean("blockHeads"));
      }

      // spawnStyle
      String spawnStyle = warzoneConfig.getString("spawnStyle");
      if (spawnStyle != null && !spawnStyle.equals("")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.getStyleFromString(spawnStyle));
      }

      // flagReturn
      String flagReturn = warzoneConfig.getString("flagReturn");
      if (flagReturn != null && !flagReturn.equals("")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.FLAGRETURN, FlagReturn.getFromString(flagReturn));
      }

      // reward
      String rewardStr = warzoneConfig.getString("reward");
      if (rewardStr != null && !rewardStr.equals("")) {
        HashMap<Integer, ItemStack> reward = new HashMap<Integer, ItemStack>();
        LoadoutTxtMapper.fromStringToLoadout(rewardStr, reward);
        warzone.getDefaultInventories().setReward(reward);
      }

      // unbreakableZoneBlocks
      if (warzoneConfig.containsKey("unbreakableZoneBlocks")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.UNBREAKABLE, warzoneConfig.getBoolean("unbreakableZoneBlocks"));
      }

      // disabled
      if (warzoneConfig.containsKey("disabled")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.DISABLED, warzoneConfig.getBoolean("disabled"));
      }

      // noCreatures
      if (warzoneConfig.containsKey("noCreatures")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.NOCREATURES, warzoneConfig.getBoolean("noCreatures"));
      }
     
      // glassWalls
      if (warzoneConfig.containsKey("glassWalls")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.GLASSWALLS, warzoneConfig.getBoolean("glassWalls"));
      }
     
      // pvpInZone
      if (warzoneConfig.containsKey("pvpInZone")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.PVPINZONE, warzoneConfig.getBoolean("pvpInZone"));
      }
     
      // instaBreak
      if (warzoneConfig.containsKey("instaBreak")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.INSTABREAK, warzoneConfig.getBoolean("instaBreak"));
      }
     
      // noDrops
      if (warzoneConfig.containsKey("noDrops")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.NODROPS, warzoneConfig.getBoolean("noDrops"));
      }
     
      // noHunger
      if (warzoneConfig.containsKey("noHunger")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.NOHUNGER, warzoneConfig.getBoolean("noHunger"));
      }
     
      // saturation
      if (warzoneConfig.containsKey("saturation")) {
        warzone.getTeamDefaultConfig().put(TeamConfig.SATURATION, warzoneConfig.getInt("saturation"));
      }
     
      // minPlayers
      if (warzoneConfig.containsKey("minPlayers")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MINPLAYERS, warzoneConfig.getInt("minPlayers"));
      }
     
      // minTeams
      if (warzoneConfig.containsKey("minTeams")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.MINTEAMS, warzoneConfig.getInt("minTeams"));
      }

      // resetOnEmpty
      if (warzoneConfig.containsKey("resetOnEmpty")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.RESETONEMPTY, warzoneConfig.getBoolean("resetOnEmpty"));
      }

      // resetOnLoad
      if (warzoneConfig.containsKey("resetOnLoad")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.RESETONLOAD, warzoneConfig.getBoolean("resetOnLoad"));
      }

      // resetOnUnload
      if (warzoneConfig.containsKey("resetOnUnload")) {
        warzone.getWarzoneConfig().put(WarzoneConfig.RESETONUNLOAD, warzoneConfig.getBoolean("resetOnUnload"));
      }

      // rallyPoint
      String rallyPointStr = warzoneConfig.getString("rallyPoint");
      if (rallyPointStr != null && !rallyPointStr.equals("")) {
        String[] rallyPointStrSplit = rallyPointStr.split(",");

        int rpX = Integer.parseInt(rallyPointStrSplit[0]);
        int rpY = Integer.parseInt(rallyPointStrSplit[1]);
        int rpZ = Integer.parseInt(rallyPointStrSplit[2]);
        Location rallyPoint = new Location(world, rpX, rpY, rpZ);
        warzone.setRallyPoint(rallyPoint);
      }

      // monuments
      String monumentsStr = warzoneConfig.getString("monuments");
      if (monumentsStr != null && !monumentsStr.equals("")) {
        String[] monumentsSplit = monumentsStr.split(";");
        warzone.getMonuments().clear();
        for (String monumentStr : monumentsSplit) {
          if (monumentStr != null && !monumentStr.equals("")) {
            String[] monumentStrSplit = monumentStr.split(",");
            int monumentX = Integer.parseInt(monumentStrSplit[1]);
            int monumentY = Integer.parseInt(monumentStrSplit[2]);
            int monumentZ = Integer.parseInt(monumentStrSplit[3]);
            Monument monument = new Monument(monumentStrSplit[0], warzone, new Location(world, monumentX, monumentY, monumentZ));
            warzone.getMonuments().add(monument);
          }
        }
      }
     
      // teams
      String teamsStr = warzoneConfig.getString("teams");
      if (teamsStr != null && !teamsStr.equals("")) {
        String[] teamsSplit = teamsStr.split(";");
        warzone.getTeams().clear();
        for (String teamStr : teamsSplit) {
          if (teamStr != null && !teamStr.equals("")) {
            String[] teamStrSplit = teamStr.split(",");
            int teamX = Integer.parseInt(teamStrSplit[1]);
            int teamY = Integer.parseInt(teamStrSplit[2]);
            int teamZ = Integer.parseInt(teamStrSplit[3]);
            Location teamLocation = new Location(world, teamX, teamY, teamZ);
            if (teamStrSplit.length > 4) {
              int yaw = Integer.parseInt(teamStrSplit[4]);
              teamLocation.setYaw(yaw);
            }
            File original = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamStrSplit[0] + ".dat");
            File modified = new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + name + "/volume-" + teamStrSplit[0] + "0.dat");
            try {
              original.renameTo(modified);
            } catch (Exception ignored) {
            }

            Team team = new Team(teamStrSplit[0], TeamKind.teamKindFromString(teamStrSplit[0]), Arrays.asList(teamLocation), warzone);
            team.setRemainingLives(warzone.getTeamDefaultConfig().resolveInt(TeamConfig.LIFEPOOL));
            warzone.getTeams().add(team);
          }
        }
      }

      // teamFlags
      String teamFlagsStr = warzoneConfig.getString("teamFlags");
      if (teamFlagsStr != null && !teamFlagsStr.equals("")) {
        String[] teamFlagsSplit = teamFlagsStr.split(";");
        for (String teamFlagStr : teamFlagsSplit) {
          if (teamFlagStr != null && !teamFlagStr.equals("")) {
            String[] teamFlagStrSplit = teamFlagStr.split(",");
            Team team = warzone.getTeamByKind(TeamKind.teamKindFromString(teamFlagStrSplit[0]));
            if (team != null) {
              int teamFlagX = Integer.parseInt(teamFlagStrSplit[1]);
              int teamFlagY = Integer.parseInt(teamFlagStrSplit[2]);
              int teamFlagZ = Integer.parseInt(teamFlagStrSplit[3]);
              Location teamFlagLocation = new Location(world, teamFlagX, teamFlagY, teamFlagZ);
              if (teamFlagStrSplit.length > 4) {
                int yaw = Integer.parseInt(teamFlagStrSplit[4]);
                teamFlagLocation.setYaw(yaw);
              }
              team.setTeamFlag(teamFlagLocation); // this may screw things up
            }
          }
        }
      }

      // lobby
      String lobbyStr = warzoneConfig.getString("lobby");

      warzoneConfig.close();

      if (createNewVolume) {
        ZoneVolume zoneVolume = new ZoneVolume(warzone.getName(), world, warzone); // VolumeMapper.loadZoneVolume(warzone.getName(), warzone.getName(), war, warzone.getWorld(), warzone);
        warzone.setVolume(zoneVolume);
      }

      // monument blocks
      for (Monument monument : warzone.getMonuments()) {
        try {
          monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
        } catch (SQLException e) {
          War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e);
        }
      }

      // team spawn blocks
      for (Team team : warzone.getTeams()) {
        for (Location spawnLocation : team.getTeamSpawns()) {
          try {
            team.setSpawnVolume(spawnLocation, VolumeMapper.loadVolume(team.getName() + "0", warzone.getName(), world));
          } catch (SQLException e) {
            War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e);
          }
        }
        if (team.getTeamFlag() != null) {
          try {
            team.setFlagVolume(VolumeMapper.loadVolume(team.getName() + "flag", warzone.getName(), world));
          } catch (SQLException e) {
            War.war.getLogger().log(Level.WARNING, "Failed to load some ambiguous old volume", e);
          }
        }
      }

      // lobby
      BlockFace lobbyFace = null;
      if (lobbyStr != null && !lobbyStr.equals("")) {
        String[] lobbyStrSplit = lobbyStr.split(",");
        if (lobbyStrSplit.length > 0) {
          // lobby orientation
          if (lobbyStrSplit[0].equals("south")) {
            lobbyFace = Direction.SOUTH();
          } else if (lobbyStrSplit[0].equals("east")) {
            lobbyFace = Direction.EAST();
          } else if (lobbyStrSplit[0].equals("north")) {
            lobbyFace = Direction.NORTH();
          } else if (lobbyStrSplit[0].equals("west")) {
            lobbyFace = Direction.WEST();
          }
         
          // lobby world
          World lobbyWorld = world;  // by default, warzone world
          if (lobbyStrSplit.length > 1) {
            World strWorld = War.war.getServer().getWorld(lobbyStrSplit[1]);
            if (strWorld != null) {
              lobbyWorld = strWorld;
            }
          }
         
          // create the lobby
          Volume lobbyVolume = null;
          try {
            lobbyVolume = VolumeMapper.loadVolume("lobby", warzone.getName(), lobbyWorld);
          } catch (SQLException e) {
            // if the zone is this old is there any reason the lobby should be nimitz format
            War.war.getLogger().log(Level.WARNING, "Failed to load lobby for a really old warzone", e);
          }
          ZoneLobby lobby = new ZoneLobby(warzone, lobbyFace, lobbyVolume);
          warzone.setLobby(lobby);
        }
      }

      return warzone;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.