Examples of TownBlock


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

    }
   
    private void townClaim(Town town, WorldCoord worldCoord) throws TownyException {              
        try {
                TownBlock townBlock = worldCoord.getTownBlock();
                try {
                        throw new AlreadyRegisteredException(String.format(TownySettings.getLangString("msg_already_claimed"), townBlock.getTown().getName()));
                } catch (NotRegisteredException e) {
                        throw new AlreadyRegisteredException(TownySettings.getLangString("msg_already_claimed_2"));
                }
        } catch (NotRegisteredException e) {
                TownBlock townBlock = worldCoord.getWorld().newTownBlock(worldCoord);
                townBlock.setTown(town);
                if (!town.hasHomeBlock())
                        town.setHomeBlock(townBlock);
               
                // Set the plot permissions to mirror the towns.
                townBlock.setType(townBlock.getType());
                TownyUniverse.getDataSource().saveTownBlock(townBlock);
               
                if (town.getWorld().isUsingPlotManagementRevert()) {
                  PlotBlockData plotChunk = TownyRegenAPI.getPlotChunk(townBlock);
                if (plotChunk != null) {
                  TownyRegenAPI.deletePlotChunk(plotChunk); // just claimed so stop regeneration.
                  townBlock.setLocked(false);
                } else {
                  //plotChunk = new PlotBlockData(townBlock); // Not regenerating so create a new snapshot.
                  //plotChunk.initialize();
                 
                  // Push the TownBlock location to the queue for a snapshot.
                  TownyRegenAPI.addWorldCoord(townBlock.getWorldCoord());
                  townBlock.setLocked(true);
                 
                  TownyUniverse.getDataSource().saveTownBlock(townBlock);
                }
                //if (!plotChunk.getBlockList().isEmpty() && !(plotChunk.getBlockList() == null))
                //  TownyRegenAPI.addPlotChunkSnapshot(plotChunk); // Save a snapshot.
View Full Code Here

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

        }
    }
   
    private void townUnclaim(Town town, WorldCoord worldCoord, boolean force) throws TownyException {
        try {
                final TownBlock townBlock = worldCoord.getTownBlock();
                if (town != townBlock.getTown() && !force)
                        throw new TownyException(TownySettings.getLangString("msg_area_not_own"));
               
                Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

              @Override
View Full Code Here

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

    int x, y = 0;
    for (int tby = pos.getX() + (lineWidth-halfLineWidth-1); tby >= pos.getX() - halfLineWidth; tby--) {
      x = 0;
      for (int tbx = pos.getZ() - halfLineHeight; tbx <= pos.getZ() + (lineHeight-halfLineHeight-1); tbx++) {
        try {
          TownBlock townblock = world.getTownBlock(tby, tbx);
          //TODO: possibly claim outside of towns
          if (!townblock.hasTown())
            throw new TownyException();
          if (x == halfLineHeight && y == halfLineWidth)
            // location
            townyMap[y][x] = Colors.Gold;
          else if (hasTown) {
            if (resident.getTown() == townblock.getTown()) {
              // own town
              townyMap[y][x] = Colors.LightGreen;
              try {
                if (resident == townblock.getResident())
                  //own plot
                  townyMap[y][x] = Colors.Yellow;
              } catch(NotRegisteredException e) {
              }
            } else if (resident.hasNation()) {
              if (resident.getTown().getNation().hasTown(townblock.getTown()))
                // towns
                townyMap[y][x] = Colors.Green;
              else if (townblock.getTown().hasNation()) {
                Nation nation = resident.getTown().getNation();
                if (nation.hasAlly(townblock.getTown().getNation()))
                  townyMap[y][x] = Colors.Green;
                else if (nation.hasEnemy(townblock.getTown().getNation()))
                  // towns
                  townyMap[y][x] = Colors.Red;
                else
                  townyMap[y][x] = Colors.White;
              } else
                townyMap[y][x] = Colors.White;
            } else
              townyMap[y][x] = Colors.White;
          } else
            townyMap[y][x] = Colors.White;

          // Registered town block
          if (townblock.getPlotPrice() != -1) {
            // override the colour if it's a shop plot for sale
            if (townblock.getType().equals(TownBlockType.COMMERCIAL))
              townyMap[y][x] = Colors.Blue;
            townyMap[y][x] += "$";
          } else if (townblock.isHomeBlock())
            townyMap[y][x] += "H";
          else
            townyMap[y][x] += townblock.getType().getAsciiMapKey();
        } catch (TownyException e) {
          if (x == halfLineHeight && y == halfLineWidth)
            townyMap[y][x] = Colors.Gold;
          else
            townyMap[y][x] = Colors.Gray;

          // Unregistered town block
          townyMap[y][x] += "-";
        }
        x++;
      }
      y++;
    }
   
    String[] compass = generateCompass(player);
   
    // Output
    player.sendMessage(ChatTools.formatTitle("Towny Map " + Colors.White + "(" + pos.toString() + ")"));
    String line;
    int lineCount = 0;
    // Variables have been rotated to fit N/S/E/W properly
    for (int my = 0; my < lineHeight; my++) {
      line = compass[0];
      if (lineCount < compass.length)
        line = compass[lineCount];

      for (int mx = lineWidth-1; mx >= 0; mx--)
        line += townyMap[mx][my];
     
      if (lineCount < help.length)
        line += help[lineCount];
     
      player.sendMessage(line);
      lineCount++;
    }
   
    // Current town block data
    try {
      TownBlock townblock = world.getTownBlock(pos);
      TownyMessaging.sendMsg(player, ("Town: " + (townblock.hasTown() ? townblock.getTown().getName() : "None") + " : "
          + "Owner: " + (townblock.hasResident() ? townblock.getResident().getName() : "None")));
    } catch (TownyException e) {
      //plugin.sendErrorMsg(player, e.getError());
      // Send a blank line instead of an error, to keep the map position tidy.
      player.sendMessage ("");
    }
View Full Code Here

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

          event.setCancelled(true);
        }

      //remove from towns if in the list and set to remove           
      try {
        TownBlock townBlock = townyWorld.getTownBlock(coord);
        if (townyWorld.isUsingTowny() && !townyWorld.isForceTownMobs()) {
          if (!townBlock.getTown().hasMobs() && !townBlock.getPermissions().mobs) {
            if (MobRemovalTimerTask.isRemovingTownEntity(livingEntity)) {
              //TownyMessaging.sendDebugMsg("onCreatureSpawn town: Canceled " + event.getCreatureType() + " from spawning within "+coord.toString()+".");
              event.setCancelled(true);
            }
          }
View Full Code Here

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

    }

    Block block = event.getBlock();

    TownyWorld townyWorld = null;
    TownBlock townBlock;

    try {
      townyWorld = TownyUniverse.getDataSource().getWorld(block.getLocation().getWorld().getName());
     
      if (!townyWorld.isUsingTowny())
        return;
     
      if (townyWorld.isEndermanProtect())
        try {
          townBlock = townyWorld.getTownBlock(new Coord(Coord.parseCoord(block)));
          if (!townyWorld.isForceTownMobs() && !townBlock.getPermissions().mobs && !townBlock.getTown().hasMobs())
            event.setCancelled(true);
        } catch (NotRegisteredException e) {
          // not in a townblock
          event.setCancelled(true);
        }
View Full Code Here

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

      event.setCancelled(true);
      return;
    }

    TownyWorld townyWorld = null;
    TownBlock townBlock;

    try {
      townyWorld = TownyUniverse.getDataSource().getWorld(event.getLocation().getWorld().getName());
     
      if (!townyWorld.isUsingTowny())
        return;
     
      if (townyWorld.isEndermanProtect())
        try {
          townBlock = townyWorld.getTownBlock(new Coord(Coord.parseCoord(event.getLocation())));
          if (!townyWorld.isForceTownMobs() && !townBlock.getPermissions().mobs && !townBlock.getTown().hasMobs())
            event.setCancelled(true);
        } catch (NotRegisteredException e) {
          // not in a townblock
          event.setCancelled(true);
        }
View Full Code Here

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

        return;
      }

      //TODO: expand to protect neutrals during a war
      try {
        TownBlock townBlock = townyWorld.getTownBlock(coord);

        // If explosions are off, or it's wartime and explosions are off and the towns has no nation
        if (townyWorld.isUsingTowny() && !townyWorld.isForceExpl()) {
          if ((!townBlock.getPermissions().explosion) || (plugin.getTownyUniverse().isWarTime() && TownySettings.isAllowWarBlockGriefing() && !townBlock.getTown().hasNation() && !townBlock.getTown().isBANG())) {
            if (event.getEntity() != null)
              TownyMessaging.sendDebugMsg("onEntityExplode: Canceled " + event.getEntity().getEntityId() + " from exploding within " + coord.toString() + ".");
            event.setCancelled(true);
          }
        }
View Full Code Here

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

          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()))
View Full Code Here

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

        return true;
    }

    try {
      // Check Town PvP status
      TownBlock townblock = world.getTownBlock(coord);
      if (!townblock.getTown().isPVP() && !world.isForcePVP() && !townblock.getPermissions().pvp) {
        if (bp != null && (ap != null || a instanceof Arrow || a instanceof ThrownPotion))
          return true;

        if (b instanceof Wolf) {
          Wolf wolf = (Wolf) b;
          if (wolf.isTamed() && !wolf.getOwner().equals((AnimalTamer) a)) {
            return true;
          }
        }

        if (b instanceof Animals) {
          Resident resident = TownyUniverse.getDataSource().getResident(ap.getName());
          if ((!resident.hasTown()) || (resident.hasTown() && (resident.getTown() != townblock.getTown())))
            return true;
        }
      }
    } catch (NotRegisteredException e) {
      // Not in a town
View Full Code Here

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

  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.
        return 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.