Examples of WorldCoord


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

      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

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

  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

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

    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

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

      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

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

    //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

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

   
    //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

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

  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

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

  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

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

    if (event instanceof PaintingBreakByEntityEvent) {
      PaintingBreakByEntityEvent evt = (PaintingBreakByEntityEvent) event;
      Painting painting = evt.getPainting();
      Object remover = evt.getRemover();
      WorldCoord worldCoord;
     
      try {
        TownyWorld townyWorld = TownyUniverse.getDataSource().getWorld(painting.getWorld().getName());
         
        if (!townyWorld.isUsingTowny())
          return;
       
        worldCoord = new WorldCoord(townyWorld, Coord.parseCoord(painting.getLocation()));
      } catch (NotRegisteredException e1) {
        //TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_not_configured"));
        event.setCancelled(true);
        return;
      }
     
      if (remover instanceof Player) {
        Player player = (Player) evt.getRemover();

        //Get destroy permissions (updates if none exist)
        boolean bDestroy = TownyUniverse.getCachePermissions().getCachePermission(player, painting.getLocation(), TownyPermission.ActionType.DESTROY);

        PlayerCache cache = plugin.getCache(player);
        cache.updateCoord(worldCoord);
        TownBlockStatus status = cache.getStatus();
        if (status == TownBlockStatus.UNCLAIMED_ZONE && TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, painting.getEntityId(), TownyPermission.ActionType.DESTROY))
          return;
        if (!bDestroy)
          event.setCancelled(true);
        if (cache.hasBlockErrMsg())
          TownyMessaging.sendErrorMsg(player, cache.getBlockErrMsg());
       
      } else if ((remover instanceof Fireball) || (remover instanceof LightningStrike)) {
       
        try {
          TownBlock townBlock = worldCoord.getTownBlock();
         
          // Explosions are blocked in this plot
          if ((!townBlock.getPermissions().explosion) && (!townBlock.getWorld().isForceExpl()))
            event.setCancelled(true);         
         
        } catch (NotRegisteredException e) {
          // Not in a town
          if ((!worldCoord.getWorld().isExpl()) && (!worldCoord.getWorld().isForceExpl()))
            event.setCancelled(true);
        }

      }
View Full Code Here

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

    long start = System.currentTimeMillis();

    Player player = event.getPlayer();
    Painting painting = event.getPainting();

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

    //Get build permissions (updates if none exist)
    boolean bBuild = TownyUniverse.getCachePermissions().getCachePermission(player, painting.getLocation(), TownyPermission.ActionType.BUILD);

    PlayerCache cache = plugin.getCache(player);
    TownBlockStatus status = cache.getStatus();

    if (status == TownBlockStatus.UNCLAIMED_ZONE && TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, painting.getEntityId(), TownyPermission.ActionType.BUILD))
      return;

    if (!bBuild)
      event.setCancelled(true);
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.