Package com.palmergames.bukkit.towny.object

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


    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

  public boolean preventFriendlyFire(Player a, Player b) {
    TownyUniverse universe = plugin.getTownyUniverse();
    if (!TownySettings.getFriendlyFire() && universe.isAlly(a.getName(), b.getName())) {
      try {
        TownyWorld world = TownyUniverse.getDataSource().getWorld(b.getWorld().getName());
        TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(b)).getTownBlock();
        if (!townBlock.getType().equals(TownBlockType.ARENA))
          return true;
      } catch (TownyException x) {
        //world or townblock failure
        // But we want to prevent friendly fire in the wilderness too.
View Full Code Here

    try {
      while ((line = fin.readLine()) != null)
        if (!line.equals("")) {
          split = line.split(",");
          TownyWorld world = getWorld(split[0]);
          WorldCoord worldCoord = new WorldCoord(world, Integer.parseInt(split[1]),Integer.parseInt(split[2]));
          TownyRegenAPI.addWorldCoord(worldCoord);
        }

    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

     
      //System.out.print("[Towny] save active snapshot queue");
     
      BufferedWriter fout = new BufferedWriter(new FileWriter(rootFolder + dataFolder + FileMgmt.fileSeparator() + "snapshot_queue.txt"));
      while (TownyRegenAPI.hasWorldCoords()) {
        WorldCoord worldCoord = TownyRegenAPI.getWorldCoord();
        fout.write(worldCoord.getWorld().getName() + "," + worldCoord.getX() + "," + worldCoord.getZ() + newLine);
      }
      fout.close();
      return true;
    } catch (Exception e) {
      System.out.println("[Towny] Saving Error: Exception while saving snapshot_queue file");
View Full Code Here

  private String blockErrMsg;
  private Location lastLocation;
  //TODO: cache last entity attacked

  public PlayerCache(TownyWorld world, Player player) {
    this(new WorldCoord(world, Coord.parseCoord(player)));
    setLastLocation(player.getLocation());
  }
View Full Code Here

          if (!warEvent.isWarringNation(nation))
            continue;
          TownyMessaging.sendDebugMsg("[War]   warringNation");
          //TODO: Cache player coord & townblock
         
          WorldCoord worldCoord = new WorldCoord(TownyUniverse.getDataSource().getWorld(player.getWorld().getName()), Coord.parseCoord(player));
          if (!warEvent.isWarZone(worldCoord))
            continue;
          TownyMessaging.sendDebugMsg("[War]   warZone");
          if (player.getLocation().getBlockY() < TownySettings.getMinWarHeight())
            continue;
          TownyMessaging.sendDebugMsg("[War]   aboveMinHeight");
          TownBlock townBlock = worldCoord.getTownBlock(); //universe.getWorld(player.getWorld().getName()).getTownBlock(worldCoord);
          if (nation == townBlock.getTown().getNation() || townBlock.getTown().getNation().hasAlly(nation))
            continue;
          TownyMessaging.sendDebugMsg("[War]   notAlly");
          //Enemy nation
          warEvent.damage(resident.getTown(), townBlock);
View Full Code Here

                townScores.put(town, townScores.get(town) + n);
                TownyMessaging.sendTownMessage(town, TownySettings.getWarTimeScoreMsg(town, n));
        }
       
        public void damage(Town attacker, TownBlock townBlock) throws NotRegisteredException {
                WorldCoord worldCoord = townBlock.getWorldCoord();
                int hp = warZone.get(worldCoord) - 1;
                if (hp > 0) {
                        warZone.put(worldCoord, hp);
                        //if (hp % 10 == 0) {
                                universe.sendMessageTo(townBlock.getTown(),
View Full Code Here

            if (world.getMinDistanceFromOtherTowns(key) < TownySettings.getMinDistanceFromTownHomeblocks())
              throw new TownyException(TownySettings.getLangString("msg_too_close"));

            selection = new ArrayList<WorldCoord>();
            selection.add(new WorldCoord(world, key));
            blockCost = TownySettings.getOutpostCost();
            attachedToEdge = false;
          } else
            throw new TownyException(TownySettings.getLangString("msg_outpost_disable"));
        } else {
          selection = TownyUtil.selectWorldCoordArea(town, new WorldCoord(world, key), split);
          blockCost = TownySettings.getClaimPrice();
        }

        TownyMessaging.sendDebugMsg("townClaim: Pre-Filter Selection " + Arrays.toString(selection.toArray(new WorldCoord[0])));
        selection = TownyUtil.filterTownOwnedBlocks(selection);
View Full Code Here

                                List<WorldCoord> selection;
                                if (split.length == 1 && split[0].equalsIgnoreCase("all"))
                                  new TownClaim(plugin, player, town, null, false, false).start();
                                        //townUnclaimAll(town);
                                else {
                                        selection = TownyUtil.selectWorldCoordArea(town, new WorldCoord(world, Coord.parseCoord(plugin.getCache(player).getLastLocation())), split);
                                        selection = TownyUtil.filterOwnedBlocks(town, selection);
                                       
                                        // Set the area to unclaim
                                        new TownClaim(plugin, player, town, selection, false, false).start();
                                       
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.