Пример #1
0
 /** Removes from the whitelist. Used when breaking blocks. */
 public static void removeFromWhitelist(
     Class<? extends TileEntity> te, int dim, int x, int y, int z, Town town) {
   for (Protection prot : Protections.instance.getProtectionList()) {
     if (prot.isTileTracked(te))
       for (FlagType flagType : prot.getFlagsForTile(te)) {
         BlockWhitelist bw = town.getBlockWhitelist(dim, x, y, z, flagType);
         if (bw != null) {
           bw.delete();
         }
       }
   }
 }
Пример #2
0
 /** Searches if the specified block is whitelisted in any town */
 public static boolean isBlockWhitelisted(int dim, int x, int y, int z, FlagType flagType) {
   Town town = getTownAtPosition(dim, x >> 4, z >> 4);
   if (town == null) return false;
   BlockWhitelist bw = town.blockWhitelistsContainer.get(dim, x, y, z, flagType);
   if (bw != null) {
     if (bw.isDeleted()) {
       getDatasource().deleteBlockWhitelist(bw, town);
       return false;
     }
     return true;
   }
   return false;
 }
Пример #3
0
  public static boolean isBlockWhitelistValid(BlockWhitelist bw) {
    // Delete if the town is gone
    if (MyTownUtils.getTownAtPosition(bw.getDim(), bw.getX() >> 4, bw.getZ() >> 4) == null) {
      return false;
    }

    if (!bw.getFlagType().isWhitelistable) {
      return false;
    }

    /*
    if (bw.getFlagType() == FlagType.ACTIVATE
            && !checkActivatedBlocks(MinecraftServer.getServer().worldServerForDimension(bw.getDim()).getBlock(bw.getX(), bw.getY(), bw.getZ()), MinecraftServer.getServer().worldServerForDimension(bw.getDim()).getBlockMetadata(bw.getX(), bw.getY(), bw.getZ())))
        return false;
    if (bw.getFlagType() == FlagType.MODIFY || bw.getFlagType() == FlagType.ACTIVATE || bw.getFlagType() == FlagType.USAGE) {
        TileEntity te = MinecraftServer.getServer().worldServerForDimension(bw.getDim()).getTileEntity(bw.getX(), bw.getY(), bw.getZ());
        if (te == null)
            return false;
        return getFlagsForTile(te.getClass()).contains(bw.getFlagType());
    }
    */
    return true;
  }
Пример #4
0
  /** Checks if the block whitelist is still valid */
  public static boolean isBlockWhitelistValid(BlockWhitelist bw) {
    // Delete if the town is gone
    if (MyTownUtils.getTownAtPosition(bw.getDim(), bw.getX() >> 4, bw.getZ() >> 4) == null)
      return false;

    if (bw.getFlagType() == FlagType.ACTIVATE
        && !checkActivatedBlocks(
            DimensionManager.getWorld(bw.getDim()).getBlock(bw.getX(), bw.getY(), bw.getZ()),
            DimensionManager.getWorld(bw.getDim())
                .getBlockMetadata(bw.getX(), bw.getY(), bw.getZ()))) return false;
    if (bw.getFlagType() == FlagType.MODIFY
        || bw.getFlagType() == FlagType.ACTIVATE
        || bw.getFlagType() == FlagType.USAGE) {
      TileEntity te =
          DimensionManager.getWorld(bw.getDim()).getTileEntity(bw.getX(), bw.getY(), bw.getZ());
      if (te == null) return false;
      return getFlagsForTile(te.getClass()).contains(bw.getFlagType());
    }
    return true;
  }