Package com.palmergames.bukkit.towny.object

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


        }
        if (r > 1000) r = 1000;
        for (int z = - r; z <= r; z++)
          for (int x = - r; x <= r; x++)
            if (out.size() < available)
            out.add(new WorldCoord(pos.getWorld(), pos.getX()+x, pos.getZ()+z));
      } else {
        throw new TownyException(TownySettings.getLangString("msg_err_invalid_radius"));
      }
    }
View Full Code Here


        }
        if (r > 1000) r = 1000;
        for (int z = -r; z <= r; z++)
          for (int x = -r; x <= r; x++)
            if ((x*x+z*z <= r*r) && (out.size() < available))
              out.add(new WorldCoord(pos.getWorld(), pos.getX()+x, pos.getZ()+z));
      } else {
        throw new TownyException(TownySettings.getLangString("msg_err_invalid_radius"));
      }
    }

View Full Code Here

      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

  public void onPlayerInteractEvent(PlayerInteractEvent event) {
   
    Player player = event.getPlayer();

    Block block = event.getClickedBlock();
    WorldCoord worldCoord;
    TownyWorld world = null;
    //System.out.println("onPlayerInteractEvent");

    try {
      world = TownyUniverse.getDataSource().getWorld(player.getWorld().getName());
      if (block != null)
        worldCoord = new WorldCoord(world, Coord.parseCoord(block));
      else
        worldCoord = new WorldCoord(world, Coord.parseCoord(player));
    } catch (NotRegisteredException e1) {
      TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_not_configured"));
      event.setCancelled(true);
      return;
    }

    //Get itemUse permissions (updates if none exist)
    boolean bItemUse;
   
    if (block != null)
      bItemUse = TownyUniverse.getCachePermissions().getCachePermission(player, block.getLocation(), TownyPermission.ActionType.ITEM_USE);
    else
      bItemUse = TownyUniverse.getCachePermissions().getCachePermission(player, player.getLocation(), TownyPermission.ActionType.ITEM_USE);
   
    boolean wildOverride = TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, event.getItem().getTypeId(), TownyPermission.ActionType.ITEM_USE);

    PlayerCache cache = plugin.getCache(player);
    //cache.updateCoord(worldCoord);
    try {
View Full Code Here

    Block block = event.getClickedBlock();

    if (!TownySettings.isSwitchId(block.getTypeId()))
      return;

    WorldCoord worldCoord;
    TownyWorld world;
    try {
      world = TownyUniverse.getDataSource().getWorld(player.getWorld().getName());
      worldCoord = new WorldCoord(world, Coord.parseCoord(block));
    } catch (NotRegisteredException e1) {
      TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_not_configured"));
      event.setCancelled(true);
      return;
    }

    //Get switch permissions (updates if none exist)
    boolean bSwitch = TownyUniverse.getCachePermissions().getCachePermission(player, block.getLocation(), TownyPermission.ActionType.SWITCH);
   
    boolean wildOverride = TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, block.getTypeId(), TownyPermission.ActionType.SWITCH);

    PlayerCache cache = plugin.getCache(player);
   
    TownBlockStatus status = cache.getStatus();
    if (status == TownBlockStatus.UNCLAIMED_ZONE && wildOverride)
View Full Code Here

      return;
    }

    try {
      TownyWorld fromWorld = TownyUniverse.getDataSource().getWorld(from.getWorld().getName());
      WorldCoord fromCoord = new WorldCoord(fromWorld, Coord.parseCoord(from));
      TownyWorld toWorld = TownyUniverse.getDataSource().getWorld(to.getWorld().getName());
      WorldCoord toCoord = new WorldCoord(toWorld, Coord.parseCoord(to));
      if (!fromCoord.equals(toCoord))
        onPlayerMoveChunk(player, fromCoord, toCoord, from, to);
      else {
        //plugin.sendDebugMsg("    From: " + fromCoord);
        //plugin.sendDebugMsg("    To:   " + toCoord);
View Full Code Here

    //long start = System.currentTimeMillis();

    Player player = event.getPlayer();
    Block block = event.getBlock();
    WorldCoord worldCoord;
     
    try {
      TownyWorld world = TownyUniverse.getDataSource().getWorld(block.getWorld().getName());
      worldCoord = new WorldCoord(world, Coord.parseCoord(block));

      //Get build permissions (updates if none exist)
      boolean bDestroy = TownyUniverse.getCachePermissions().getCachePermission(player, block.getLocation(), TownyPermission.ActionType.DESTROY);
      boolean wildOverride = TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, event.getBlock().getTypeId(), TownyPermission.ActionType.DESTROY);
     
      PlayerCache cache = plugin.getCache(player);
      TownBlockStatus status = cache.getStatus();

      // Allow destroy if we are in wilds and have an override.
View Full Code Here

   
    //long start = System.currentTimeMillis();

    Player player = event.getPlayer();
    Block block = event.getBlock();
    WorldCoord worldCoord;
    try {
      TownyWorld world = TownyUniverse.getDataSource().getWorld(block.getWorld().getName());
      worldCoord = new WorldCoord(world, Coord.parseCoord(block));
     
      //Get build permissions (updates if none exist)
      boolean bBuild = TownyUniverse.getCachePermissions().getCachePermission(player, block.getLocation(), TownyPermission.ActionType.BUILD);
      boolean wildOverride = TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, event.getBlock().getTypeId(), TownyPermission.ActionType.BUILD);
     
      PlayerCache cache = plugin.getCache(player);
      TownBlockStatus status = cache.getStatus();
     
      // Allow build if in wilds and we have an override
View Full Code Here

  public PlayerCache getCache(Player player) {
    if (!hasCache(player)) {
      newCache(player);
      try {
        getTownyUniverse();
        getCache(player).setLastTownBlock(new WorldCoord(TownyUniverse.getDataSource().getWorld(player.getWorld().getName()), Coord.parseCoord(player)));
      } catch (NotRegisteredException e) {
        deleteCache(player);
      }
    }
View Full Code Here

  public void updateCache() {
    for (Player player : getServer().getOnlinePlayers())
      try {
        getTownyUniverse();
        getCache(player).setLastTownBlock(new WorldCoord(TownyUniverse.getDataSource().getWorld(player.getWorld().getName()), Coord.parseCoord(player)));
      } catch (NotRegisteredException e) {
        deleteCache(player);
      }
  }
View Full Code Here

TOP

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

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.