Examples of TownBlock


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

              TownyWorld world = getWorld(tokens[0]);
             
              try {
                int x = Integer.parseInt(tokens[1]);
                int z = Integer.parseInt(tokens[2]);
                TownBlock homeBlock = world.getTownBlock(x, z);
                town.setHomeBlock(homeBlock);
              } catch (NumberFormatException e) {
                System.out.println("[Towny] [Warning] " + town.getName() + " homeBlock tried to load invalid location.");
              } catch (NotRegisteredException e) {
                System.out.println("[Towny] [Warning] " + town.getName() + " homeBlock tried to load invalid TownBlock.");
View Full Code Here

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

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

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

            if (resident != null && townblock.hasTown())
              townblock.setResident(resident);

                        if (blockTypeData != null) {
                            utilLoadTownBlockTypeData(townblock, blockTypeData);
                        }

            //if present set the plot price
            if (tokens.length >= 3) {
              if (tokens[2] == "true")
                townblock.setPlotPrice(town.getPlotPrice());
              else
                townblock.setPlotPrice(Double.parseDouble(tokens[2]));
                        }
           
          } catch (NumberFormatException e) {
          } catch (NotRegisteredException e) {
          }
View Full Code Here

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

  @Override
  public PlotBlockData loadPlotData(String worldName, int x, int z) {
   
    try {
      TownyWorld world = getWorld(worldName);
      TownBlock townBlock = new TownBlock(x,z,world);
     
      return loadPlotData(townBlock);
    } catch (NotRegisteredException e) {
      // Failed to get world
      e.printStackTrace();
View Full Code Here

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

            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);
          TownyMessaging.sendDebugMsg("[War]   damaged");
View Full Code Here

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

                                  } catch (InvalidNameException e) {
                                    TownyMessaging.sendErrorMsg(player, e.getMessage());
                  }
                        } else if (split[0].equalsIgnoreCase("homeblock")) {
                                Coord coord = Coord.parseCoord(player);
                                TownBlock townBlock;
                                TownyWorld world;
                                try {
                                        if (plugin.getTownyUniverse().isWarTime())
                                                throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));
                                       
View Full Code Here

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

                world.newTownBlock(key);
                TownyUniverse.getDataSource().newTown(name);
                Town town = TownyUniverse.getDataSource().getTown(name);
                town.addResident(resident);
                town.setMayor(resident);
                TownBlock townBlock = world.getTownBlock(key);
                townBlock.setTown(town);
                town.setHomeBlock(townBlock);
                town.setSpawn(spawn);
                //world.addTown(town);
               
                if (world.isUsingPlotManagementRevert()) {
View Full Code Here

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

                        System.out.print("[Towny] Debug: isEdgeBlock(" + worldCoord.toString() + ") = ");
               
                int[][] offset = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
                for (int i = 0; i < 4; i++)
                        try {
                                TownBlock edgeTownBlock = worldCoord.getWorld().getTownBlock(new Coord(worldCoord.getX() + offset[i][0], worldCoord.getZ() + offset[i][1]));
                                if (edgeTownBlock.isOwner(owner)) {
                                        if (TownySettings.getDebug())
                                                System.out.println("true");
                                        return true;
                                }
                        } catch (NotRegisteredException e) {
View Full Code Here

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

            // 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) {
                  plugin.getTownyUniverse().deleteTownBlockMaterial(townBlock, Material.getMaterial(material).getId());
                  player.sendMessage(String.format(TownySettings.getLangString("msg_clear_plot_material"), material));
                } else
                  throw new TownyException(String.format(TownySettings.getLangString("msg_err_invalid_property"), material));
            } else
              throw new TownyException(String.format(TownySettings.getLangString("msg_already_claimed"), townBlock.getResident().getName()));

          } else {
            // Shouldn't ever reach here as a null townBlock should be caught already in WorldCoord.
            player.sendMessage(TownySettings.getLangString("msg_err_empty_area_selection"));
          }
View Full Code Here

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

   * @throws TownyException
   */
  public void setPlotType(Resident resident, WorldCoord worldCoord, String type) throws TownyException {
    if (resident.hasTown())
      try {
        TownBlock townBlock = worldCoord.getTownBlock();
       
        // Test we are allowed to work on this plot
        plotTestOwner(resident, townBlock); //ignore the return as we are only checking for an exception
       
        townBlock.setType(type);
       
      } catch (NotRegisteredException e) {
        throw new TownyException(TownySettings.getLangString("msg_err_not_part_town"));
      }
    else
View Full Code Here

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

   * @throws TownyException
   */
  public void setPlotForSale(Resident resident, WorldCoord worldCoord, double forSale) throws TownyException {
    if (resident.hasTown())
      try {
        TownBlock townBlock = worldCoord.getTownBlock();

        // Test we are allowed to work on this plot
        plotTestOwner(resident, townBlock); //ignore the return as we are only checking for an exception

        townBlock.setPlotPrice(forSale);

        if (forSale != -1)
          TownyMessaging.sendTownMessage(townBlock.getTown(), TownySettings.getPlotForSaleMsg(resident.getName(), worldCoord));
        else
          TownyUniverse.getPlayer(resident).sendMessage(TownySettings.getLangString("msg_err_plot_nfs"));
      } catch (NotRegisteredException e) {
        throw new TownyException(TownySettings.getLangString("msg_err_not_part_town"));
      }
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.