Examples of WorldCoord


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

  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

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

    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

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

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

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

  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

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

          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

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

                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

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

            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

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

                                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

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

        if (split[0].equalsIgnoreCase("claim")) {

          if (plugin.getTownyUniverse().isWarTime())
            throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));

          List<WorldCoord> selection = TownyUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.remFirstArg(split));
          //selection = TownyUtil.filterUnownedPlots(selection);

          if (selection.size() > 0) {

            double cost = 0;

            // Remove any plots Not for sale (if not the mayor) and tally up costs.
            for (WorldCoord worldCoord : new ArrayList<WorldCoord>(selection)) {
              try {
                double price = worldCoord.getTownBlock().getPlotPrice();
                if (price > -1)
                  cost += worldCoord.getTownBlock().getPlotPrice();
                else {
                  if (!worldCoord.getTownBlock().getTown().isMayor(resident)) // || worldCoord.getTownBlock().getTown().hasAssistant(resident))
                    selection.remove(worldCoord);
                }
              } catch (NotRegisteredException e) {
                selection.remove(worldCoord);
              }
            }
           
            int maxPlots = TownySettings.getMaxResidentPlots(resident);
            if (maxPlots >= 0 && resident.getTownBlocks().size() + selection.size() > maxPlots)
              throw new TownyException(String.format(TownySettings.getLangString("msg_max_plot_own"), maxPlots));

            if (TownySettings.isUsingEconomy() && (!resident.canPayFromHoldings(cost)))
              throw new TownyException(String.format(TownySettings.getLangString("msg_no_funds_claim"), selection.size(), TownyEconomyObject.getFormattedBalance(cost)));

            // Start the claim task
            new PlotClaim(plugin, player, resident, selection, PlotClaim.Action.CLAIM).start();

          } else {
            player.sendMessage(TownySettings.getLangString("msg_err_empty_area_selection"));
          }
        } else if (split[0].equalsIgnoreCase("unclaim")) {

          if (plugin.getTownyUniverse().isWarTime())
            throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));

          if (split.length == 2 && split[1].equalsIgnoreCase("all")) {
            // Start the unclaim task
            new PlotClaim(plugin, player, resident, null, PlotClaim.Action.UNCLAIM).start();

          } else {
            List<WorldCoord> selection = TownyUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.remFirstArg(split));
            selection = TownyUtil.filterOwnedBlocks(resident, selection);

            if (selection.size() > 0) {

              // Start the unclaim task
              new PlotClaim(plugin, player, resident, selection, PlotClaim.Action.UNCLAIM).start();

            } else {
              player.sendMessage(TownySettings.getLangString("msg_err_empty_area_selection"));
            }
          }
        } else if (split[0].equalsIgnoreCase("notforsale") || split[0].equalsIgnoreCase("nfs")) {
          List<WorldCoord> selection = TownyUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.remFirstArg(split));
          selection = TownyUtil.filterOwnedBlocks(resident.getTown(), selection);

          for (WorldCoord worldCoord : selection) {
            setPlotForSale(resident, worldCoord, -1);
          }
        } else if (split[0].equalsIgnoreCase("forsale") || split[0].equalsIgnoreCase("fs")) {
          WorldCoord pos = new WorldCoord(world, Coord.parseCoord(player));
          double plotPrice = pos.getTownBlock().getTown().getPlotTypePrice(pos.getTownBlock().getType());

          if (split.length > 1) {

            int areaSelectPivot = TownyUtil.getAreaSelectPivot(split);
            List<WorldCoord> selection;
            if (areaSelectPivot >= 0) {
              selection = TownyUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.subArray(split, areaSelectPivot + 1, split.length));
              selection = TownyUtil.filterOwnedBlocks(resident.getTown(), selection);
              if (selection.size() == 0) {
                player.sendMessage(TownySettings.getLangString("msg_err_empty_area_selection"));
                return;
              }
            } else {
              selection = new ArrayList<WorldCoord>();
              selection.add(pos);
            }

            // Check that it's not: /plot forsale within rect 3
            if (areaSelectPivot != 1) {
              try {
                // command was 'plot fs $'
                plotPrice = Double.parseDouble(split[1]);
                if (plotPrice < 0) {
                                TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_negative_money"));
                                return;
                            }
              } catch (NumberFormatException e) {
                throw new TownyException(String.format(TownySettings.getLangString("msg_error_must_be_num")));
              }
            }

            for (WorldCoord worldCoord : selection) {
              if (selection.size() > 1)
                plotPrice = worldCoord.getTownBlock().getTown().getPlotTypePrice(worldCoord.getTownBlock().getType());
               
              setPlotForSale(resident, worldCoord, plotPrice);
            }
          } else {
            // basic 'plot fs' command
            setPlotForSale(resident, pos, plotPrice);
          }
        } else if (split[0].equalsIgnoreCase("perm")) {

          TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
          TownyMessaging.sendMessage(player, TownyFormatter.getStatus(townBlock));

        } else if (split[0].equalsIgnoreCase("toggle")) {
          TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
          // Runs tests to make sure we are allowed to work on this plot.
          // Ignore the returns as we are only checking for an exception
          plotTestOwner(resident, townBlock);
          townBlock.getTown();

          plotToggle(player, new WorldCoord(world, Coord.parseCoord(player)).getTownBlock(), StringMgmt.remFirstArg(split));

        } else if (split[0].equalsIgnoreCase("set")) {

          split = StringMgmt.remFirstArg(split);
          Town town = resident.getTown();

          if (split.length > 0) {
            if (split[0].equalsIgnoreCase("perm")) {

              //Set plot level permissions (if the plot owner) or Mayor/Assistant of the town.

              TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
              // Test we are allowed to work on this plot
              TownBlockOwner owner = plotTestOwner(resident, townBlock);
              town = townBlock.getTown();

              // Check we are allowed to set these perms
              toggleTest(player, townBlock, StringMgmt.join(StringMgmt.remFirstArg(split), ""));

              TownCommand.setTownBlockPermissions(player, owner, townBlock.getPermissions(), StringMgmt.remFirstArg(split), true);
              townBlock.setChanged(true);
              TownyUniverse.getDataSource().saveTownBlock(townBlock);
              return;
            }

            if ((!TownyUniverse.getPermissionSource().isTownyAdmin(player)) && ((plugin.isPermissions())
              && (!TownyUniverse.getPermissionSource().hasPermission(player, PermissionNodes.TOWNY_TOWN_PLOTTYPE.getNode())))
              && !town.isMayor(resident)
              && !town.hasAssistant(resident))
              throw new TownyException(String.format(TownySettings.getLangString("msg_cache_block_error_town_resident"), "change plot types"));
           
            WorldCoord worldCoord = new WorldCoord(world, Coord.parseCoord(player));
            TownBlock townBlock = worldCoord.getTownBlock();
            setPlotType(resident, worldCoord, split[0]);
            townBlock.setChanged(true);
            TownyUniverse.getDataSource().saveTownBlock(townBlock);
            player.sendMessage(String.format(TownySettings.getLangString("msg_plot_set_type"), split[0]));

          } else {
            player.sendMessage(ChatTools.formatCommand("", "/plot set", "reset", ""));
            player.sendMessage(ChatTools.formatCommand("", "/plot set", "shop|embassy|arena|wilds|spleef", ""));
            player.sendMessage(ChatTools.formatCommand("", "/plot set perm", "?", ""));
          }
        } else if (split[0].equalsIgnoreCase("clear")) {

          if (!resident.isMayor())
            throw new TownyException(TownySettings.getLangString("msg_not_mayor"));

          TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();

          if (townBlock != null) {
            if (townBlock.isOwner(resident.getTown()) && (!townBlock.hasResident())) {
              for (String material : world.getPlotManagementMayorDelete())
                if (Material.matchMaterial(material) != null) {
View Full Code Here

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

          throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));

        world = TownyUniverse.getDataSource().getWorld(player.getWorld().getName());

        List<WorldCoord> selection;
        selection = TownyUtil.selectWorldCoordArea(null, new WorldCoord(world, Coord.parseCoord(player)), split);

        new TownClaim(plugin, player, null, selection, false, true).start();

      } catch (TownyException x) {
        TownyMessaging.sendErrorMsg(player, x.getMessage());
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.