Examples of Coord


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

  }
 
  private boolean onBurn(Block block) {

    Location loc = block.getLocation();
    Coord coord = Coord.parseCoord(loc);
    TownyWorld townyWorld;
   
    try {
      townyWorld = TownyUniverse.getDataSource().getWorld(loc.getWorld().getName());
     
      if (!townyWorld.isUsingTowny())
        return false;
   
      try {
       
        if (townyWorld.isWarZone(coord)) {
          if (TownyWarConfig.isAllowingFireInWarZone()) {
            return false;
          } else {
            TownyMessaging.sendDebugMsg("onBlockIgnite: Canceled " + block.getTypeId() + " from igniting within "+coord.toString()+".");
            return true;
          }
        }
       
        TownBlock townBlock = townyWorld.getTownBlock(coord);
        if ((block.getRelative(BlockFace.DOWN).getType() != Material.OBSIDIAN && !townBlock.getTown().isFire() && !townyWorld.isForceFire() && !townBlock.getPermissions().fire)
            || (block.getRelative(BlockFace.DOWN).getType() != Material.OBSIDIAN && plugin.getTownyUniverse().isWarTime() && TownySettings.isAllowWarBlockGriefing() && !townBlock.getTown().hasNation())) {
          TownyMessaging.sendDebugMsg("onBlockIgnite: Canceled " + block.getTypeId() + " from igniting within "+coord.toString()+".");
          return true;
        }
      } catch (TownyException x) {
        // Not a town so check the world setting for fire
        if (!townyWorld.isFire()) {
          TownyMessaging.sendDebugMsg("onBlockIgnite: Canceled " + block.getTypeId() + " from igniting within "+coord.toString()+".");
          return true;
        }
      }
     
    } catch (NotRegisteredException e) {
View Full Code Here

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

      }
       
      // Regen this chunk
      if (player != null) {
        try {
          Coord coord = Coord.parseCoord(player);
          TownyUniverse.getDataSource().getResident(player.getName())
            .addUndo(Bukkit.getWorld(player.getWorld().getName()).getChunkAt(player.getLocation()).getChunkSnapshot());
         
          Bukkit.getWorld(player.getWorld().getName()).regenerateChunk(coord.getX(), coord.getZ());
         
        } catch (NotRegisteredException e) {
          // Failed to get resident
        }
      }
View Full Code Here

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

    }
    if (!world.isUsingTowny()) {
      TownyMessaging.sendErrorMsg(player, "This world is not using towny.");
      return;
    }
    Coord pos = Coord.parseCoord(plugin.getCache(player).getLastLocation());

    // Generate Map
    int halfLineHeight = lineHeight / 2;
    String[][] townyMap = new String[lineWidth][lineHeight];
    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];
View Full Code Here

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

    }
   
    if (event.getEntity() instanceof LivingEntity) {
      LivingEntity livingEntity = (LivingEntity) event.getEntity();
      Location loc = event.getLocation();
      Coord coord = Coord.parseCoord(loc);
      TownyWorld townyWorld = null;

      try {
        townyWorld = TownyUniverse.getDataSource().getWorld(loc.getWorld().getName());
      } catch (NotRegisteredException e) {
View Full Code Here

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

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

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

      event.setCancelled(true);
      return;
    }

    Location loc;
    Coord coord;
    List<Block> blocks = event.blockList();
    Entity entity = event.getEntity();
    int count = 0;

    Collections.sort(blocks, ArraySort.getInstance());

    for (Block block : blocks) {
      loc = block.getLocation();
      coord = Coord.parseCoord(loc);
      count++;
      TownyWorld townyWorld;

      try {
        townyWorld = TownyUniverse.getDataSource().getWorld(loc.getWorld().getName());
       
        if (!townyWorld.isUsingTowny())
          return;
       
      } catch (NotRegisteredException e) {
        // failed to get world so abort
        return;
      }

      // Warzones
      if (townyWorld.isWarZone(coord)) {
        if (!TownyWarConfig.isAllowingExplosionsInWarZone()) {
          if (event.getEntity() != null)
            TownyMessaging.sendDebugMsg("onEntityExplode: Canceled " + event.getEntity().getEntityId() + " from exploding within " + coord.toString() + ".");
          event.setCancelled(true);
          break;
        } else {
          if (TownyWarConfig.explosionsBreakBlocksInWarZone()) {
            if (TownyWarConfig.regenBlocksAfterExplosionInWarZone()) {
              // ***********************************
              // TODO

              // On completion, remove TODO from config.yml comments.

              /*
              if (!plugin.getTownyUniverse().hasProtectionRegenTask(new BlockLocation(block.getLocation()))) {
                ProtectionRegenTask task = new ProtectionRegenTask(plugin.getTownyUniverse(), block, false);
                task.setTaskId(plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, task, ((TownySettings.getPlotManagementWildRegenDelay() + count)*20)));
                plugin.getTownyUniverse().addProtectionRegenTask(task);
              }
              */

              // TODO
              // ***********************************
            }

            // Break the block
          } else {
            event.blockList().remove(block);
          }
        }
        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);
          }
        }
      } catch (TownyException x) {
        // Wilderness explosion regeneration
View Full Code Here

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

  public boolean preventDamageCall(TownyWorld world, Entity a, Entity b, Player ap, Player bp) {
    // World using Towny
    if (!world.isUsingTowny())
      return false;

    Coord coord = Coord.parseCoord(b);

    if (ap != null && bp != null) {
      if (world.isWarZone(coord))
        return false;
View Full Code Here

Examples of mines.MinefieldContainer.Coord

    MinefieldContainer<GUI_FIELD> instance = new MinefieldContainer<GUI_FIELD>(1);

    List<Coord> coords = instance.getAroundFields(0, 0);
   
    List<Coord> expectedCoords = new ArrayList<Coord>();
    expectedCoords.add(new Coord(0,0));
   
    TestSuite.assertListsEquals(expectedCoords, coords);
  }
View Full Code Here

Examples of mines.MinefieldContainer.Coord

    Set<Coord> real = new HashSet<Coord>(coords);

    Assert.assertEquals(coords.size(), real.size());

    Set<Coord> expectedCoords = new HashSet<Coord>();
    expectedCoords.add(new Coord(0,0));
    expectedCoords.add(new Coord(0,1));
    expectedCoords.add(new Coord(1,0));
    expectedCoords.add(new Coord(1,1));
    expectedCoords.add(new Coord(2,0));
    expectedCoords.add(new Coord(2,1));
    expectedCoords.add(new Coord(3,0));
    expectedCoords.add(new Coord(4,0));
   
    TestSuite.assertSetsEquals(expectedCoords, real);
  }
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.