Package com.palmergames.bukkit.towny.object

Examples of com.palmergames.bukkit.towny.object.TownyWorld


      for (World world : server.getWorlds()) {
        List<LivingEntity> livingEntitiesToRemove = new ArrayList<LivingEntity>();
       
        for (LivingEntity livingEntity : world.getLivingEntities()) {
          Coord coord = Coord.parseCoord(livingEntity.getLocation());
          TownyWorld townyWorld = null;
          try {
            townyWorld = TownyUniverse.getDataSource().getWorld(world.getName());
          } catch (NotRegisteredException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
            try {
              TownBlock townBlock = townyWorld.getTownBlock(coord);
              if ((!townBlock.getTown().hasMobs() && !townBlock.getPermissions().mobs && isRemovingTownEntity(livingEntity))) {
                //System.out.println("[Towny] Town MobRemovalTimerTask - added: " + livingEntity.toString());
                livingEntitiesToRemove.add(livingEntity);
              }
               
            } catch (TownyException x) {
              // it will fall through here if the mob has no townblock.
              if ((!townyWorld.hasWorldMobs() && isRemovingWorldEntity(livingEntity))) {
                //System.out.println("[Towny] World MobRemovalTimerTask - added: " + livingEntity.toString());
                livingEntitiesToRemove.add(livingEntity);
              }
            }
        }
View Full Code Here


    List<String> out = new ArrayList<String>();

    try {
      TownBlockOwner owner;
      Town town = townBlock.getTown();
      TownyWorld world = townBlock.getWorld();

      if (townBlock.hasResident()) {
        owner = townBlock.getResident();
      } else {
        owner = townBlock.getTown();
      }

      out.add(ChatTools.formatTitle(TownyFormatter.getFormattedName(owner) + ((MinecraftTools.isOnline(owner.getName())) ? Colors.LightGreen + " (Online)" : "")));
      out.add(Colors.Green + " Perm: " + ((owner instanceof Resident) ? townBlock.getPermissions().getColourString() : townBlock.getPermissions().getColourString().replace("f", "r")));
      out.add(Colors.Green + "PvP: " + ((town.isPVP() || world.isForcePVP() || townBlock.getPermissions().pvp) ? Colors.Red + "ON" : Colors.LightGreen + "OFF") + Colors.Green + "  Explosions: " + ((world.isForceExpl() || townBlock.getPermissions().explosion) ? Colors.Red + "ON" : Colors.LightGreen + "OFF") + Colors.Green + "  Firespread: " + ((town.isFire() || world.isForceFire() || townBlock.getPermissions().fire) ? Colors.Red + "ON" : Colors.LightGreen + "OFF") + Colors.Green + "  Mob Spawns: " + ((town.hasMobs() || world.isForceTownMobs() || townBlock.getPermissions().mobs) ? Colors.Red + "ON" : Colors.LightGreen + "OFF"));

    } catch (NotRegisteredException e) {
      out.add("Error: " + e.getMessage());
    }
View Full Code Here

  }

  public static List<String> getStatus(Town town) {
    List<String> out = new ArrayList<String>();

    TownyWorld world = town.getWorld();

    // ___[ Raccoon City (PvP) (Open) ]___
    String title = getFormattedName(town);
    title += ((town.isPVP() || town.getWorld().isForcePVP()) ? Colors.Red + " (PvP)" : "");
    title += (town.isOpen() ? Colors.LightBlue + " (Open)" : "");
    out.add(ChatTools.formatTitle(title));

    // Lord: Mayor Quimby
    // Board: Get your fried chicken
    try {
      out.add(Colors.Green + "Board: " + Colors.LightGreen + town.getTownBoard());
    } catch (NullPointerException e) {
    }

    // Town Size: 0 / 16 [Bought: 0/48] [Bonus: 0] [Home: 33,44]
    try {
      out.add(Colors.Green + "Town Size: " + Colors.LightGreen + town.getTownBlocks().size() + " / " + TownySettings.getMaxTownBlocks(town) + (TownySettings.isSellingBonusBlocks() ? Colors.LightBlue + " [Bought: " + town.getPurchasedBlocks() + "/" + TownySettings.getMaxPurchedBlocks() + "]" : "") + (town.getBonusBlocks() > 0 ? Colors.LightBlue + " [Bonus: " + town.getBonusBlocks() + "]" : "") + (town.isPublic() ? Colors.LightGray + " [Home: " + (town.hasHomeBlock() ? town.getHomeBlock().getCoord().toString() : "None") + "]" : ""));
    } catch (TownyException e) {
    }

    // Permissions: B=rao D=--- S=ra-
    out.add(Colors.Green + "Permissions: " + town.getPermissions().getColourString().replace("f", "r"));
    out.add(Colors.Green + "Explosions: " + ((town.isBANG() || world.isForceExpl()) ? Colors.Red + "ON" : Colors.LightGreen + "OFF") + Colors.Green + "  Firespread: " + ((town.isFire() || world.isForceFire()) ? Colors.Red + "ON" : Colors.LightGreen + "OFF") + Colors.Green + "  Mob Spawns: " + ((town.hasMobs() || world.isForceTownMobs()) ? Colors.Red + "ON" : Colors.LightGreen + "OFF"));

    // | Bank: 534 coins
    String bankString = "";
    if (TownySettings.isUsingEconomy()) {
      try {
View Full Code Here

      if (player.getHealth() <= 0)
        continue;
     
      Coord coord = Coord.parseCoord(player);
      try {
        TownyWorld world = TownyUniverse.getDataSource().getWorld(player.getWorld().getName());
        TownBlock townBlock = world.getTownBlock(coord);
         
        if (universe.isAlly(townBlock.getTown(), TownyUniverse.getDataSource().getResident(player.getName()).getTown()))
          if (!townBlock.getType().equals(TownBlockType.ARENA)) // only regen if not in an arena
            incHealth(player);
      } catch (TownyException x) {
View Full Code Here

      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();
View Full Code Here

    System.out.println("[Towny] [hMod Conversion] Town Blocks");
    String line;
    String[] tokens;
   
    //Default world is the first one loaded
    TownyWorld world = getWorlds().toArray(new TownyWorld[0])[0];
   
    try {
      BufferedReader fin = new BufferedReader(new FileReader(rootFolder + dataFolder + "/townblocks.csv"));
      while ( (line = fin.readLine()) != null) {
        tokens = line.split(",");
        if (tokens.length >= 4)
          try {
            Town town = getTown(tokens[2]);
         
         
            int x = Integer.parseInt(tokens[0]);
            int z = Integer.parseInt(tokens[1]);

            try {
              world.newTownBlock(x, z);
            } catch (AlreadyRegisteredException e) {
            }
            TownBlock townblock = world.getTownBlock(x, z);

            if (town != null)
              townblock.setTown(town);

            try {
View Full Code Here

    return nation;
  }
 
  @Override
  public TownyWorld getWorld(String name) throws NotRegisteredException {
    TownyWorld world = universe.getWorldMap().get(name.toLowerCase());

    if (world == null)
      throw new NotRegisteredException("World not registered!");

    return world;
View Full Code Here

    }
    try {
      town = townBlock.getTown();
    } catch (NotRegisteredException e) {
    }
    TownyWorld world = townBlock.getWorld();
    world.removeTownBlock(townBlock);

    saveWorld(world);
    deleteTownBlock(townBlock);

    if (resident != null)
View Full Code Here

    }
    */
    if (universe.getWorldMap().containsKey(filteredName.toLowerCase()))
      throw new AlreadyRegisteredException("The world " + filteredName + " is already in use.");

    universe.getWorldMap().put(filteredName.toLowerCase(), new TownyWorld(filteredName));

    universe.setChangedNotify(NEW_WORLD);
  }
View Full Code Here

  public void removeTown(Town town) {

    removeTownBlocks(town);

    List<Resident> toSave = new ArrayList<Resident>(town.getResidents());
    TownyWorld world = town.getWorld();

    try {
      if (town.hasNation()) {
        Nation nation = town.getNation();
        nation.removeTown(town);
View Full Code Here

TOP

Related Classes of com.palmergames.bukkit.towny.object.TownyWorld

Copyright © 2018 www.massapicom. 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.