Examples of CellUnderAttack


Examples of com.palmergames.bukkit.townywar.CellUnderAttack

  public Block getFlagBaseBlock() {
    return flagBaseBlock;
  }
 
  public CellUnderAttack getData() {
    return new CellUnderAttack(player.getName(), flagBaseBlock);
  }
View Full Code Here

Examples of com.palmergames.bukkit.townywar.CellUnderAttack

  @Override
  public void onCustomEvent(Event event) {
    if (event.getEventName().equals("CellAttack")) {
      CellAttackEvent cellAttackEvent = (CellAttackEvent)event;
      try {
        CellUnderAttack cell = cellAttackEvent.getData();
        TownyWar.registerAttack(cell);
      } catch (Exception e) {
        cellAttackEvent.setCancelled(true);
        cellAttackEvent.setReason(e.getMessage());
      }
    } else if (event.getEventName().equals("CellDefended")) {
      CellDefendedEvent cellDefendedEvent = (CellDefendedEvent)event;
      Player player = cellDefendedEvent.getPlayer();
      CellUnderAttack cell = cellDefendedEvent.getCell().getAttackData();
     
      TownyUniverse universe = plugin.getTownyUniverse();
      try {
        TownyWorld world = TownyUniverse.getDataSource().getWorld(cell.getWorldName());
        WorldCoord worldCoord = new WorldCoord(world, cell.getX(), cell.getZ());
        universe.removeWarZone(worldCoord);
       
        plugin.updateCache(worldCoord);
      } catch (NotRegisteredException e) {
        e.printStackTrace();
      }
     
      String playerName;
      if (player == null) {
        playerName = "Greater Forces";
      } else {
        playerName = player.getName();
        try {
          playerName = TownyUniverse.getDataSource().getResident(player.getName()).getFormattedName();
        } catch (TownyException e) {
        }
      }
     
      plugin.getServer().broadcastMessage(String.format(TownySettings.getLangString("msg_enemy_war_area_defended"),
          playerName,
          cell.getCellString()));
    } else if (event.getEventName().equals("CellWon")) {
      CellWonEvent cellWonEvent = (CellWonEvent)event;
      CellUnderAttack cell = cellWonEvent.getCellAttackData();
     
      TownyUniverse universe = plugin.getTownyUniverse();
      try {
        Resident resident = TownyUniverse.getDataSource().getResident(cell.getNameOfFlagOwner());
        Town town = resident.getTown();
        Nation nation = town.getNation();
       
        TownyWorld world = TownyUniverse.getDataSource().getWorld(cell.getWorldName());
        WorldCoord worldCoord = new WorldCoord(world, cell.getX(), cell.getZ());
        universe.removeWarZone(worldCoord);
       
        TownBlock townBlock = worldCoord.getTownBlock();
        TownyUniverse.getDataSource().removeTownBlock(townBlock);
       
        try {
          List<WorldCoord> selection = new ArrayList<WorldCoord>();
          selection.add(worldCoord);
          TownCommand.checkIfSelectionIsValid(town, selection, false, 0, false);
          new TownClaim(plugin, null, town, selection, true, false).start();
         
          //TownCommand.townClaim(town, worldCoord);
          //TownyUniverse.getDataSource().saveTown(town);
          //TownyUniverse.getDataSource().saveWorld(world);
         
          //TODO
          //PlotCommand.plotClaim(resident, worldCoord);
          //TownyUniverse.getDataSource().saveResident(resident);
          //TownyUniverse.getDataSource().saveWorld(world);
        } catch (TownyException te) {
          // Couldn't claim it.
        }
       
        plugin.updateCache(worldCoord);
       
        TownyMessaging.sendGlobalMessage(String.format(TownySettings.getLangString("msg_enemy_war_area_won"),
            resident.getFormattedName(),
            (nation.hasTag() ? nation.getTag() : nation.getFormattedName()),
            cell.getCellString()));
      } catch (NotRegisteredException e) {
        e.printStackTrace();
      }
    } else if (event.getEventName().equals("CellAttackCanceled")) {
      System.out.println("CellAttackCanceled");
      CellAttackCanceledEvent cancelCellAttackerEvent = (CellAttackCanceledEvent)event;
      CellUnderAttack cell = cancelCellAttackerEvent.getCell();
     
      TownyUniverse universe = plugin.getTownyUniverse();
      try {
        TownyWorld world = TownyUniverse.getDataSource().getWorld(cell.getWorldName());
        WorldCoord worldCoord = new WorldCoord(world, cell.getX(), cell.getZ());
        universe.removeWarZone(worldCoord);
        plugin.updateCache(worldCoord);
      } catch (NotRegisteredException e) {
        e.printStackTrace();
      }
      System.out.println(cell.getCellString());
    }
  }
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.